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

Stephan Rudlof sr at evolgo.de
Thu Jan 20 01:12:31 UTC 2000


Stewart MacLean 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
> > ....
> 
> So may ways of skinning that cat ...
> 
> In the past, rather than creating a new class I've used a class called
> OpenObject which has an IdentityDictionary to store key/value pairs, where
> the key is the instance variable name.
> 
> I use the doesNotUnderstand trick to dynamically create getter/setters which
> lookup or add to the dictionary based on the message selector.
> 
> Doesn't carry the overhead of extra classes but access time would be higher.
> Very useful for design and build (or is that build and design? :)).
> 
> One could use an instance of this class to return as many values as you want
> with clarity.


You pay another price for avoiding the overhead of extra classes:

If you use OpenObject in different contexts as different object you get
more and more getters/selectors all belonging to just this one class...

Regards,

Stephan
-- 
Stephan Rudlof (sr at evolgo.de)
   "Genius doesn't work on an assembly line basis.
    You can't simply say, 'Today I will be brilliant.'"
    -- Kirk, "The Ultimate Computer", stardate 4731.3





More information about the Squeak-dev mailing list