Hi Eliot, hi all!
I am having issues with the inlining of #to:do: in combination with decompiling a block and accessing the temps.
Here is a piece of code that works as expected:
| result context |
result := OrderedCollection new.
(1 to: 5) do: [:each |
result add: [:object | object + each]].
context := (result at: 3) outerContext.
context namedTempAt: (context tempNames indexOf: 'each'). " == 3"
HOWEVER, using #to:do: the result changes because code gets inlined:
| result context |
result := OrderedCollection new.
1 to: 5 do: [:each |
result add: [:object | object + each]].
context := (result at: 3) outerContext.
context namedTempAt: (context tempNames indexOf: 'each'). " == 6"
What is my goal here? I want to unpack the block statement and fill in the temps. For all those [:object | object + each] in "result" I want to collect the strings:
-> 'object + 1'
-> 'object + 2'
-> 'object + 3'
-> 'object + 4'
-> 'object + 5'
Is there a way to access the values of temps when the block closures are created this way?
Best,
Marcel