Hi Levente, Hi Marcel,<br>
<br>
currently, this expression:<br>
<br>
    <font color="#800000">self</font><font color="#000000"> </font><font color="#000080">assert:</font><font color="#000000"> </font><font color="#800000">42</font><font color="#000000"> </font><font color="#000080">equals:</font><font color="#000000"> </font><font color="#000000">(</font><font color="#800000">6</font><font color="#000000"> </font><font color="#000080">caseOf:</font><font color="#000000"> </font><font color="#000000">{</font><font color="#000000"> </font><font color="#008000">[</font><font color="#FF0000">a</font><font color="#008000">]</font><font color="#000000"> </font><font color="#000080">-></font><font color="#000000"> </font><font color="#008000">[</font><font color="#FF0000">b</font><font color="#008000">]</font><font color="#000000">.</font><font color="#000000"> </font><font color="#008000">[</font><font color="#FF0000">b</font><font color="#008000">]</font><font color="#000000"> </font><font color="#000080">-></font><font color="#000000"> </font><font color="#008000">[</font><font color="#FF0000">c</font><font color="#008000">]</font><font color="#000000">.</font><font color="#000000"> </font><font color="#008000">[</font><font color="#FF0000">c</font><font color="#008000">]</font><font color="#000000"> </font><font color="#000080">-></font><font color="#000000"> </font><font color="#008000">[</font><font color="#FF0000">a</font><font color="#008000">]</font><font color="#000000"> </font><font color="#000000">}</font><font color="#000000"> </font><font color="#000080">otherwise:</font><font color="#000000"> </font><font color="#008000">[</font><font color="#000000">:</font><font color="#000080">x</font><font color="#000000"> </font><font color="#808080">|</font><font color="#000000"> </font><font color="#000080">x</font><font color="#000000"> </font><font color="#000080">*</font><font color="#000000"> </font><font color="#800000">7</font><font color="#008000">]</font><font color="#000000">)</font><font color="#000000">.</font><br>
<br>
is decompiled like that:<br>
<br>
    <font color="#800000">self</font><font color="#000000"><br>
        </font><font color="#000080">assert:</font><font color="#000000"> </font><font color="#800000">42</font><font color="#000000"><br>
        </font><font color="#000080">equals:</font><font color="#000000"> </font><font color="#000000">(</font><font color="#008000">(</font><font color="#FF0000">x</font><font color="#000000"> </font><b>:=</b><font color="#000000"> </font><font color="#800000">6</font><font color="#008000">)</font><font color="#000000"> </font><font color="#000080">caseOf:</font><font color="#000000"> </font><font color="#000000">{</font><font color="#000000"><br>
                </font><font color="#008000">[</font><font color="#FF0000">a</font><font color="#008000">]</font><font color="#000000"> </font><font color="#000080">-></font><font color="#000000"> </font><font color="#008000">[</font><font color="#FF0000">b</font><font color="#008000">]</font><font color="#000000">.</font><font color="#000000"><br>
                </font><font color="#008000">[</font><font color="#FF0000">b</font><font color="#008000">]</font><font color="#000000"> </font><font color="#000080">-></font><font color="#000000"> </font><font color="#008000">[</font><font color="#FF0000">c</font><font color="#008000">]</font><font color="#000000">.</font><font color="#000000"><br>
                </font><font color="#008000">[</font><font color="#FF0000">c</font><font color="#008000">]</font><font color="#000000"> </font><font color="#000080">-></font><font color="#000000"> </font><font color="#008000">[</font><font color="#FF0000">a</font><font color="#008000">]</font><font color="#000000">}</font><font color="#000000"><br>
                 </font><font color="#000080">otherwise:</font><font color="#000000"> </font><font color="#008000">[</font><font color="#FF0000">x</font><font color="#000000"> </font><font color="#000080">*</font><font color="#000000"> </font><font color="#800000">7</font><font color="#008000">]</font><font color="#000000">)</font><br>
<br>
<font color="#FF0000">x</font> is also declared correctly in the test method. Do I understand correctly that you do not yet consider this good enough? :)<br>
<br>
Best,<br>
Christoph<br>
<br>
<font color="#808080">---<br>
</font><font color="#808080"><i>Sent from </i></font><font color="#808080"><i><a href="https://github.com/hpi-swa-lab/squeak-inbox-talk"><u><font color="#808080">Squeak Inbox Talk</font></u></a></i></font><br>
<br>
On 2021-11-18T14:04:16+01:00, marcel.taeumel@hpi.de wrote:<br>
<br>
> Hi Levente --<br>
> <br>
> Thanks. Decompiler only adds the block-arg for not-inlined caseOfs. See ObjectTest >> #testCaseOfOtherwise.<br>
> <br>
> Hmm... Christoph? =) Otherwise (ha!) I will take a look at it soon-ish.<br>
> <br>
> Best,<br>
> Marcel<br>
> Am 18.11.2021 13:51:02 schrieb Levente Uzonyi <leves at caesar.elte.hu>:<br>
> Hi Marcel,<br>
> <br>
> I just checked how this works, and noticed that the decompiler cannot<br>
> recreate the original code if the otherwise: block has an argument.<br>
> <br>
> <br>
> Levente<br>
> <br>
> On Thu, 18 Nov 2021, Marcel Taeumel wrote:<br>
> <br>
> > Merged.<br>
> ><br>
> > Am 21.02.2020 17:33:03 schrieb Thiede, Christoph :<br>
> ><br>
> > This changeset makes it possible to accept an argument in the otherwise block of a #caseOf:otherwise: call.<br>
> ><br>
> ><br>
> > Diff of the #caseOf:otherwise: implementation:<br>
> ><br>
> > caseOf: aBlockAssociationCollection otherwise: aBlock<br>
> ><br>
> > "The elements of aBlockAssociationCollection are associations between blocks.  Answer the evaluated value of the first association in aBlockAssociationCollection whose evaluated key equals the receiver.  If no<br>
> > match is found, answer the result of evaluating aBlock."<br>
> ><br>
> ><br>
> > aBlockAssociationCollection associationsDo:<br>
> ><br>
> > [:assoc | (assoc key value = self) ifTrue: [^assoc value value]].<br>
> ><br>
> > - ^ aBlock value<br>
> ><br>
> > + ^ aBlock cull: self<br>
> ><br>
> ><br>
> > "| z | z := {[#a]->[1+1]. ['b' asSymbol]->[2+2]. [#c]->[3+3]}. #b caseOf: z otherwise: [0]"<br>
> ><br>
> > "| z | z := {[#a]->[1+1]. ['d' asSymbol]->[2+2]. [#c]->[3+3]}. #b caseOf: z otherwise: [0]"<br>
> ><br>
> > "The following are compiled in-line:"<br>
> ><br>
> > "#b caseOf: {[#a]->[1+1]. ['b' asSymbol]->[2+2]. [#c]->[3+3]} otherwise: [0]"<br>
> ><br>
> > "#b caseOf: {[#a]->[1+1]. ['d' asSymbol]->[2+2]. [#c]->[3+3]} otherwise: [0]"<br>
> ><br>
> > + "#b caseOf: {[#a]->[1+1]. ['d' asSymbol]->[2+2]. [#c]->[3+3]} otherwise: [:x | x halt]"<br>
> ><br>
> ><br>
> > Furthermore, the changeset includes a necessary modification of MessageNode >> #transformCase: so that the otherwise argument can be compiled in-line.<br>
> ><br>
> > Last but not least, I wrote some tests for #caseOf:[otherwise:].<br>
> ><br>
> ><br>
> > Please review!<br>
> ><br>
> > (In a later change, it would be possible to allow arguments for the association key blocks as well. But I love short feedback loops, so let's assess this one first :-))<br>
> ><br>
> ><br>
> > Best,<br>
> ><br>
> > Christoph<br>
> ><br>
> ><br>
> ><br>
> -------------- next part --------------<br>
> An HTML attachment was scrubbed...<br>
> URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20211118/e87b1cbc/attachment.html><br>
> <br>