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

Joern Eyrich Joern.Eyrich at brokat.com
Wed Jan 19 12:04:27 UTC 2000



Dan Ingalls wrote:
> 
> 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.

What I have problems sorting out with this scheme is this:
If I decide that my return object should have one more (name,value) pair (or if I remove one), won't the subclass representing the earlier set of names just lie around? Won't these zombie classes accumulate over time as I change more and more uses of the Tuple return?

I always thought that it's a good idea to use a dictionary to return multiple values. So you can reference every element by a descriptive name.

> 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.

Ah, I see, a Dictionary would probably not be so fast, and though it would be clearer than an array, it would be slightly less clear than using simple accessors in a specialized class.

Still, it seems like a good compromise to me.

What do you think?

Joern





More information about the Squeak-dev mailing list