This post originated from an RSS feed registered with Agile Buzz
by James Robertson.
Original Post: Everything old is new again
Feed Title: Cincom Smalltalk Blog - Smalltalk with Rants
Feed URL: http://www.cincomsmalltalk.com/rssBlog/rssBlogView.xml
Feed Description: James Robertson comments on Cincom Smalltalk, the Smalltalk development community, and IT trends and issues in general.
The MS guys are rediscovering yet another old Smalltalk idea - treating an object as if it were an array. Take a look at #instVarAt: and #instVarAtPut: in class Object (never mind that doing this sort of thing is typically a very, very bad idea):
C# introduces a new concept known as Indexers which are used for treating an object as an array. The indexers are usually known as smart arrays in C# community. Defining a C# indexer is much like defining properties. We can say that an indexer is a member that enables an object to be indexed in the same way as an array.
%A0 this [argument list]
{
%A0 get
%A0 {
%A0%A0 // Get codes goes here
%A0 }
%A0 set
%A0 {
%A0%A0 // Set codes goes here
%A0 }
}
Of course, the beauty of this is that C# had to add new syntax to do this, while the equivalent Smalltalk functionality is just another set of methods. So the C# guy has to memorize yet another set of reserved words, while the Smalltalker simply looks at the library. Sometimes I'm amazed at how Java and C# are examples of Smalltalk being re-invented - but with a crufty, inelegant syntax....