Multiple Returns, was Re: Common Lisp style macros inSmalltalk?

Dan Ingalls Dan.Ingalls at disney.com
Wed Jan 19 04:10:11 UTC 2000


>On Tue, Jan 11, 2000, agree at carltonfields.com wrote:
>[...]  
>> The "strict" Smalltalkologist might observe (and it has been
>> observed many times in these letters), that the proper
>> methodological solution is that every such aggregating should have
>> its own aggregating class.  Thus:
>> 
>> 	^ Foo with: expresion1 with: expression2 with: expression3.

Chris Reuter <cgreuter at calum.csclub.uwaterloo.ca> replied:
>I would think that creating a new class just to return multiple
>objects is overkill unless the class is also needed to do something
>more.  What's the rationale for doing this rather than just returning
>an array?

Just to keep this topic from dying, it would be fun (maybe it has been done already) to create a class of named tuples, where you could say,

	^ Tuple voltage: 220 current: 7.5 startingTorque: 185

This would intercept messageNotUnderstood: on the first go-round, and create a simple subclass with three fields named, uh, 'voltage', 'current', and 'startingTorque', and with the appropriate creation and access methods.

It could all run about as fast as arrays, but be clearer, and not require any extra classes in the "library", as all such examples would be created on the fly as needed.

	- Dan






More information about the Squeak-dev mailing list