Hi everyone,
when recently working with future sends I noticed that future sends did not always return Promises when I expected them to.
I dug into the implementation and found that FutureNode yields futureDo or futureSend message sends, depending on whether the result of the send is being used or not. The difference between the two is that only futureSend returns a Promise.
The logic for determining whether the result is being used seems incomplete. E.g. the following example does not work:
result := [(2 future: 100) + 3] on: Error do: []. result then: [:sum | Transcript showln: sum].
The attached changeset fixes this and adds two corresponding tests. Could someone with some experience with the Compiler package review these changes? :)
Cheers Patrick
Hi Patrick --
I tried to find some documentation in the parse/generation code for the concepts "effect" and "value" but could not find much. Though, I could roughly understand the meaning behind "emitCode" and "sizeCode" :-)
In this case, it looks like a copy/paste mistake as I would also think that the implementation behind "BlockValue" should be similar to "Value" and not "Effect".
Would you also add a test for
[(2 future: 100) + 3. 5 negated]
We do not want to see a promise result in this case. :-)
And instead of #on:do: a simple #value would suffice, I think.
+1 on the change set
Best, Marcel
Am 27.07.2023 09:50:35 schrieb Patrick R patrick.rein@hpi.uni-potsdam.de: Hi everyone,
when recently working with future sends I noticed that future sends did not always return Promises when I expected them to.
I dug into the implementation and found that FutureNode yields futureDo or futureSend message sends, depending on whether the result of the send is being used or not. The difference between the two is that only futureSend returns a Promise.
The logic for determining whether the result is being used seems incomplete. E.g. the following example does not work:
result := [(2 future: 100) + 3] on: Error do: []. result then: [:sum | Transcript showln: sum].
The attached changeset fixes this and adds two corresponding tests. Could someone with some experience with the Compiler package review these changes? :)
Cheers Patrick
squeak-dev@lists.squeakfoundation.org