[Q] Fiddling with system innards, was [Q] Newbie - Multiple
Return Values
Jon Hylands
jon at huv.com
Fri May 2 11:40:27 UTC 2003
On Fri, 2 May 2003 15:02:32 +1200 (NZST), "Richard A. O'Keefe"
<ok at cs.otago.ac.nz> wrote:
> (3) Do the Scheme thing, use a block.
>
> SomeClass>>multivalueMethod: resultBlock
> ...
> ^resultBlock value: x value: y value: z
>
> This is accessed like
> foo multivalueMethod: [:x :y :z | a := x. b := y. c := z].
>
> The thing I like about this approach is that while there still
> _is_ an object being created (the new Block) it doesn't _feel_
> like an object. I'm not _doing_ anything to pick the result
> apart, I'm _given_ the result pieces.
The other nice thing about this approach, is that the result pieces are
*named*, which is why I don't like using Arrays for that purpose.
Later,
Jon
--------------------------------------------------------------
Jon Hylands Jon at huv.com http://www.huv.com/jon
Project: Micro Seeker (Micro Autonomous Underwater Vehicle)
http://www.huv.com
More information about the Squeak-dev
mailing list
|