Compiler And Evaluate Block Bug?

Lex Spoon lex at cc.gatech.edu
Fri Dec 10 16:11:26 UTC 1999


"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.


Lex





More information about the Squeak-dev mailing list