On Aug 27, 2007, at 16:08 , Alan Lovejoy wrote:
Blake wrote:
b := a msg. b msg1. b msg2.
Do I misunderstand? (And at what point does the potential for
confusion and ambiguity outweigh the feature?)
Yes.
The message sent to a is #asPipe, not msg:
p := a asPipe. p msg. p msg1. p msg2
Or alternatively:
a asPipe msg; msg1; msg2
The Pipe arranges for each message to be sent to the right object.
and it does so by retaining the previous value inside the Pipe object, so this is equivalent to
p := a asPipe. "p value: a" p msg. "p value: p value msg" p msg1. "p value: p value msg1" p msg2. "p value: p value msg2"
(And at what point does the potential for confusion and ambiguity outweigh the feature?)
At the point where this code would leave my machine ... as I said, I'd not use that in production. In that sense, adding new syntax actually provides clarity.
Which reminds me - actually spelling this out using a running value is what I would use in production:
val := a. val := val msg. val := val msg1. val := val msg2. ^val
I use this code pattern sometimes. You couldn't do this in a statically typed language, but in Smalltalk
- Bert -
"Bert" == Bert Freudenberg bert@freudenbergs.de writes:
Bert> Which reminds me - actually spelling this out using a running value is what I Bert> would use in production:
Bert> val := a. Bert> val := val msg. Bert> val := val msg1. Bert> val := val msg2. Bert> ^val
Yeah, and this is single-steppable, and "self halt"-able. These pipe schemes seem more like pipe dreams. :)
Bert> val := a. Bert> val := val msg. Bert> val := val msg1. Bert> val := val msg2. Bert> ^val
Yeah, and this is single-steppable, and "self halt"-able. These pipe schemes seem more like pipe dreams. :)
-- Randal L. Schwartz - Stonehenge Consulting Services, Inc. -
I wouldn't say that, while the above may be simple, it's not very concise, and it's no more debuggable. Once in the dubugger you could easily highlight and inspect the value of any inner expression without the need to shove it into a temporary first.
Burt's pipe hack is quite nice and with the addition I posted the meta stuff is optimized out very quickly and you end up with a pipe object doing ordinary message sends. It's also far more concise than the above without being at all cryptic.
I'll take this any day
^val asPipe msg; msg1; msg2
Ramon Leon http://onsmalltalk.com
squeak-dev@lists.squeakfoundation.org