[Q] Newbie - Multiple Return Values
Delbert Murphy
dmurphy at infratecture.com
Sat May 3 00:26:08 UTC 2003
I think that Dan's observation is spot on..."if there is no other reason for
the tuple", then you can use the multiple arguement block. But, I contend,
just as Juaneta Ewing did (see Steph's mail), that you very rarely use the
tuple for just a return value. I'll wager that the tuple (and other
associated responsibilities) belong in a class of it's own. Then, as I said
before, it's just a matter of keeping track of another class...
Delbert
---- Original message ----
>Date: Fri, 2 May 2003 17:05:34 -0700
>From: Dan Ingalls <Dan at SqueakLand.org>
>Subject: Re: [Q] Newbie - Multiple Return Values
>To: The general-purpose Squeak developers list <squeak-
dev at lists.squeakfoundation.org>
>
>Just in case anyone wants more about this, the topic ran the gamut about
three years ago on this list (about 15 messages on 1/18 and 1/19 of 2000. It
included Bert Freudenberg's nice presentation of multiple argument blocks:
>
>>There is (at least) one other "strict" solution to this, which already is
>>utilized throughout the image - a multiple arg block:
>>
>>Something>>voltageCurrentTorqueIn: aBlock
>> | voltage current startingTorque |
>> voltage := ...
>> current := ...
>> startingTorque := ...
>> ^aBlock valueWithArgumnts: {voltage. current. startingTorque}
>>
>>and the call would be
>>
>> something voltageCurrentTorqueIn:
>> [ :voltage :current :startingTorque |
>> do whatever with these values
>> ]
>
>This is my favorite solution when there is no other reason for the tuple,
among other things because the block arguments provide conveniently scoped and
named variables. There were a number of other solutions proposed including
self-constructing tuple classes and in-line dictionaries.
>
>I think it got discussed about three years before that too... ;-).
>
> - Dan
>
More information about the Squeak-dev
mailing list
|