[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: self blocks



Blocks in Self are not upwardly mobile (not non-LIFO); they may only be passed
downwards, not returned upwards.  This is mostly an implementation restriction,
not a deep language issue.  But you could simulate non-LIFO blocks (at least
in the situation you're describing) by manually building an object which
represents the closure with its lexical environment:

_AddSlots: ( |
    cond_gen: par1 = ( | closure |
        closure: ( |
	    par1.
	    value: par2 = ( par1 = par2 ).
	| ).
	closure par1: par1.
	closure ).
| )

_AddSlots: ( |
    test_if_equals_4 = cond_gen: 4
| )

test_if_equals_4 value: 4 "prints true"

(cond_gen: 'foo') value: 'bar' "prints false"

-- Craig Chambers