Compiler And Evaluate Block Bug?

R. A. Harmon harmonra at webname.com
Sat Dec 11 16:32:30 UTC 1999


At 11:11 AM 12/10/99 -0500, you wrote:
>"R. A. Harmon" <harmonra at webname.com> wrote:
>> At 07:52 PM 12/7/99 +0100, Bert Freudenberg wrote:
>> >On Tue, 7 Dec 1999, R. A. Harmon wrote:
>> [snip]
>> >> (Compiler evaluate: '[ :xxx | ^xxx].'
>> >> ) value: 2
>> >> 
>> >> signals a block cannot return error exception
>> [snip]
>> >If you omit the ^ it works just fine.
>> >
>> >I'm not sure if this is to be considered a bug. Compiler>>evaluate: 
>> >compiles that code into a temporary method, executes this method, and
>> >returns the result. At the time you send #value to the resulting block the
>> >method context doesn't exist anymore, so you can't return from it either.
>> 
>> Thanks.  I start getting a little light-headed when I think about block
>> context and the world get sort of all wavy.
>> 
>> I want to be able to give an object the source code of a block (example: a
>> SortedCollection sort block but in source code, not the block object).  The
>> object compiles and saves it.   At a latter time, the saved block can then
>> be evaluated to sort the collection.
>> 
>> The object I want to do this with needs more complicated code than that of
>> the default sort block ([:x :y | x <= y]).  I'd like to be able to use a
>> return (as an early exit), but I can get along without it.  Is there a
>> relatively simple way to do it and keep the context?
>> 
>
>If it's that complicated, perhaps you could implement some helper
>methods in x's and y's class(es)?  In fact, you could conceivably
>implement your version of <= as a method, thus making the sort block
>much simpler.

It isn't that complicated, just a little easier for me.  I tried to figure
out how to do something similar to what you suggest, and it just seemed that
was more involved than allowing a return deserves.  Thanks for the suggestion.

I guess there isn't any simple way to do it, so I'll just live with it for now.

Thanks all for the help.


--
Richard A. Harmon          "The only good zombie is a dead zombie"
harmonra at webname.com           E. G. McCarthy
Spencer, Iowa





More information about the Squeak-dev mailing list