Iterators? (Was: Squeak practical use? ...)
Andrew C. Greenberg
werdna at mucow.com
Thu Jan 31 06:11:09 UTC 2002
Ok, but what exactly are you criticizing here? The functional semantics
or the block closure semantics? Clearly, the standard optimization
discussed earlier in these threads is no different from the mechanical
one I suggested, more or less (except that the generated code WOULD
probably change the parameters)? Are you observing that present Squeak
block semantics make that optimization semantically unstable, or
Indeed, perhaps all we are doing here is observing that the apparent
tail recursion in this example doesn't actually occur in a tail context
(and, by at least some definitions, isn't a tail recursion)? Does the
new block closure semantics harmonize these issues?
foo: x ifSucces: succBlock ifFail: failBlock
| newSuccBlock theX theSuccBlock theFailBlock | "you would need a
definition in your example of newSuccBlock ,b.t.w"
theX := x. theSuccBlock := succBlock. theFailBlock := failBlock.
[blah1 ifTrue: [ theSuccBlock value ]
blah2 ifTrue: [ theFailBlock value ]
newSuccBlock := [ blah . [newSuccBlock value]].
" iterative substitute for: ^self bar: y ifSuccess: newSuccBlock
theX := y.
theSuccBlock := newSuccBlock.
theFailBlock := failBlock]
(Of course, extra expressions and variable can be simplified in the
obvious ways -- I did the substitution mechanically to show how I was
doing this). The real culprit in this not doing what YOU intended is
the lack of genuine blockcontexts
On Thursday, January 31, 2002, at 12:47 AM, Scott A Crosby wrote:
> On Wed, 30 Jan 2002, Tim Rowledge wrote:
>> Scott A Crosby <crosby at qwes.math.cmu.edu> is claimed by the
>> authorities to have written:
>>> foo: x ifSucces: succBlock ifFail: failBlock
>>> blah1 ifTrue: [ ^succBlock value ]
>>> blah2 ifTrue: [ ^failBlock value ]
>>> succBlock := [ blah . [^sucBlock value]]
>> Improper code I'm afraid. Can't assign to a parameter.
> Ok. Unintended error.
> foo: x ifSucces: succBlock ifFail: failBlock
> blah1 ifTrue: [ succBlock value ]
> blah2 ifTrue: [ failBlock value ]
> newSuccBlock := [ blah . [sucBlock value]]
> ^self bar: y ifSuccess: newSuccBlock ifFail: failBlock.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 2295 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20020131/a3454dc4/attachment.bin
More information about the Squeak-dev