[Q] Newbie - Multiple Return Values
Dan Ingalls
Dan at SqueakLand.org
Sat May 3 00:05:34 UTC 2003
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
|