<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto">Hi Christoph,<div dir="ltr"><br><blockquote type="cite">On Sep 14, 2020, at 5:17 AM, Thiede, Christoph <Christoph.Thiede@student.hpi.uni-potsdam.de> wrote:<br><br></blockquote></div><blockquote type="cite"><div dir="ltr"><div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p>Hi all,</p>
<p>I just evaluated the following line and was surprised by the result:</p>
<blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;">
<p><span>Compiler evaluate: '' for: 42.</span></p></blockquote>
<p>The answer was nil, whereas I rather would have expected <span><strike>the answer to life the universe and everything</strike> 42, as it is the case for full methods compiled on an object. What do you think about this, which should be the right output?</span></p>
<p><span>I was even more surprised after taking a look into the relevant Parser implementation, which is #<span>statements:innerBlock:blockNode:. Actually, the 'inner' argument's sole purpose is to use 'nil' instead of 'self' as a return value if there are
 zero statements. If we would not like to have this extra rule for doIt snippets, we would only have to change #<span>method:context:[encoder:] and pass 'false' instead of 'doit' to #<span>statements:innerBlock:.</span></span></span></span></p>
<p><span><span><span><span>I'm probably missing some logical consequences of the syntactic concept of blocks, methods, and doits, so I would like to hear your thoughts on this.</span></span></span></span></p></div></div></blockquote><div><br></div>Smells like my bug.  I agree with you that the null statement should evaluate to self at method level.  IIRC, the ANSI standard says that the null statement evaluated to the last block argument did blocks with arguments (to legalize a quirk in Peter Deutsch’s closure compiler for ObjectWorks 2.5 and subsequent).  And clearly the null statement in a block evaluates to nil.  I hunk that the null statement should evaluate to self at method level and nil at block level, irrespective of the number of block arguments.<div><br></div><div>To be clear I would have these tests</div><div><br></div><div>self assert: (Compiler <span style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;">evaluate: '' for: 42) equals: 42.</span></div><div><font face="Calibri, Helvetica, sans-serif" size="3">self assert: ([:arg|] value: 42) </font><span style="font-family: Calibri, Helvetica, sans-serif; font-size: 16px;">equals: nil.</span></div><div><font face="Calibri, Helvetica, sans-serif" size="3">self assert: [] value </font><span style="font-family: Calibri, Helvetica, sans-serif; font-size: 16px;">equals: nil.</span></div><div><font face="Calibri, Helvetica, sans-serif"><font size="3"><br></font></font><blockquote type="cite"><div dir="ltr"><div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p><span style="font-size: 12pt;">Best,</span></p>
<p><span><span><span><span>Christoph</span></span></span></span></p></div></div></blockquote></div></body></html>