SmallJS icon indicating copy to clipboard operation
SmallJS copied to clipboard

Compiler: Allow local variable declarations within block

Open FunctionPoint opened this issue 6 months ago • 1 comments

Example

myMethod
    [ :a1 :a2 | 
        | v | v := 1. self onValue: v ] value.
!

Pharo has this too. Its is especially useful when blocks are called async, that need the correct variable instance.

FunctionPoint avatar Aug 16 '25 20:08 FunctionPoint

But... as a workaround you can just declare (extra) block arguments temp vars. Those are not passed to the block and initialized to JS undefined by default (not nil !).

FunctionPoint avatar Aug 16 '25 21:08 FunctionPoint