<div dir="ltr">Yes, when the compiler sees   exp or: [ ... ] then it assumes that "exp" is a boolean-valued expression and generates code that fails if it isn't.    Not all Smalltalk compilers perform this optimization, but it is very common.  There are a bunch of methods treated like this, ifTrue:ifFalse: is another.<div><br></div><div>whileTrue: is an interesting slightly different case.   The compiler usually optimizes whileTrue: only when both receiver and the argument are blocks.    So, you can define whileTrue: in other classes without any problem.<br><div><br></div><div>-Ralph Johnson</div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Sep 10, 2017 at 6:33 AM, Lorenz Köhl <span dir="ltr"><<a href="mailto:rainbowtwigs@gmail.com" target="_blank">rainbowtwigs@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="font-size:12px;color:#777;font-family:'Lucida Grande',Helvetica,Arial,sans-serif;background-color:#fff;padding:4px">
<a href="https://www.boxbe.com/overview" style="text-decoration:none;color:#5e96ea" target="_blank"><img alt="Boxbe" src="http://www.boxbe.com/images/logo_dark_small.png" width="64px" style="margin-left:0px;border:none"></a>

<img src="http://www.boxbe.com/stfopen?tc_serial=32680703685&tc_rand=509028261&utm_source=stf&utm_medium=email&utm_campaign=ANNO_CLEANUP_ADD&utm_content=001">

This message is eligible for Automatic Cleanup! (<a href="mailto:rainbowtwigs@gmail.com" target="_blank">rainbowtwigs@gmail.com</a>) 
<a style="text-decoration:none;color:#5e96ea" href="https://www.boxbe.com/popup?url=https%3A%2F%2Fwww.boxbe.com%2Fcleanup%3Fkey%3Dd8UdKk6XBKefiw6WgR5jxiRs%252Bz4ZhdYH4NLF8y3Q1yo%253D%26token%3DCBHKUay%252FXiASnIShRk4i8Xwq5eeRqmxypuV1cDN%252BApJJ2u4Z4%252FQyrGmN6UBKpep9V2BaY%252FdQlkUFgiXKdY2jjkjIPnsaoNhAT20BWqPqLuX%252FZk%252BKFBJtacqPIMXss6tKcVEsQBe%252FncsPJAsw1rMWyw%253D%253D&tc_serial=32680703685&tc_rand=509028261&utm_source=stf&utm_medium=email&utm_campaign=ANNO_CLEANUP_ADD&utm_content=001" title="Add a new automatic cleanup rule" target="_blank">Add cleanup rule</a>
 | <a style="text-decoration:none;color:#5e96ea" href="http://blog.boxbe.com/general/boxbe-automatic-cleanup?tc_serial=32680703685&tc_rand=509028261&utm_source=stf&utm_medium=email&utm_campaign=ANNO_CLEANUP_ADD&utm_content=001" title="Get info on automatic cleanup" target="_blank">More info</a>
<br>

    </div>

<br><div dir="ltr">I don't understand why Smalltalk doesn't allow me to have an or:<div>method that takes a block argument (except on Boolean). For example:</div><div><br></div><div>Set or: 1. ==> MNU as expected.</div><div><br></div><div>Set or: [1]. ==> NonBooleanReceiver exception.</div><div><br></div><div>Set or: [:x | x] ==> Argument has too many arguments</div><div><br></div><div>Is it because the compiler specializes this to boolean when it sees</div><div>the or: [ ... ] syntax? Is this a tradeoff made for performance?</div><div><br></div><div>greetings,</div><div>  Lorenz</div></div>
<br>______________________________<wbr>_________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@lists.squeakfoundation.org">Beginners@lists.<wbr>squeakfoundation.org</a><br>
<a href="http://lists.squeakfoundation.org/mailman/listinfo/beginners" rel="noreferrer" target="_blank">http://lists.squeakfoundation.<wbr>org/mailman/listinfo/beginners</a><br>
<br></blockquote></div><br></div>