<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div class="moz-cite-prefix">Hi,</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">for those interested, there are some
possible Smalltalk syntax extensions considered in this talk:
<a class="moz-txt-link-freetext" href="https://www.youtube.com/watch?v=ZM2opfrGBXY">https://www.youtube.com/watch?v=ZM2opfrGBXY</a></div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix"> Mariano</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">El 15/7/22 a las 15:38, Francisco Garau
via Cuis-dev escribió:<br>
</div>
<blockquote type="cite"
cite="mid:CAKAN0GcFKH5COYFF=oHRFPXLRmgxCmVk1NSP4xni8z+qqw2cww@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">
<div>Hola Amigos -- just wanted to share with you some ideas
I've been thinking about for a while. </div>
<div><br>
</div>
<div>It all started when someone mentioned the colon in the
syntax for block arguments could have whitespace around the
argument so that you could write <font face="monospace">[ :
n | n + 1] </font></div>
<div><br>
</div>
<div>It makes perfect sense to see the block as an "inlined"
method that doesn't require any method-lookup; therefore, the
selector is superfluous. But if we accepted the selector
inside the block, it could be used as the variable holding the
block. So, instead of writing <font face="monospace">succ :=
[:n | n + 1]</font> we could write <font face="monospace">[succ:
n | n + 1]</font> </div>
<div><br>
</div>
<div>Even better if the block evaluation accepts #: as a valid
selector. So you could write <font face="monospace">(succ:
3) = 4</font> instead of <font face="monospace">(succ value:
3) = 4</font>. </div>
<div><br>
</div>
<div>A short example will make this clear. </div>
<div><br>
</div>
<blockquote style="margin:0 0 0 40px;border:none;padding:0px">
<div>Vanilla Smalltalk</div>
<blockquote style="margin:0 0 0 40px;border:none;padding:0px">
<div>succ := [:n | n + 1].</div>
</blockquote>
<blockquote style="margin:0 0 0 40px;border:none;padding:0px">
<div>(succ value: 3) = 4. </div>
</blockquote>
<div><br>
</div>
<div>Extended Block Syntax</div>
<blockquote style="margin:0 0 0 40px;border:none;padding:0px">
<div>[succ: n | n + 1]. </div>
</blockquote>
<blockquote style="margin:0 0 0 40px;border:none;padding:0px">
<div>(succ: 3 ) = 4. </div>
</blockquote>
<blockquote style="margin:0 0 0 40px;border:none;padding:0px">
<div>"the above is equivalent to" </div>
</blockquote>
<blockquote style="margin:0 0 0 40px;border:none;padding:0px">
<div>(succ perform: #: with: 3) = 4. </div>
</blockquote>
<blockquote style="margin:0 0 0 40px;border:none;padding:0px">
<div><br>
</div>
</blockquote>
<div>Being able to parse blocks with these syntax paves the
way to unify the syntax for method definition—for example, a
few hypothetical methods from the Point class. <br>
</div>
<div>
<div><br>
</div>
</div>
<blockquote style="margin:0 0 0 40px;border:none;padding:0px">
<div>
<div>"Point class>x:y:" </div>
</div>
</blockquote>
<blockquote style="margin:0 0 0 40px;border:none;padding:0px">
<div>
<div>[x: xInteger y: yInteger | </div>
</div>
</blockquote>
<blockquote style="margin:0 0 0 40px;border:none;padding:0px">
<div>
<div> ^self basicNew setX: xInteger setY: yInteger].</div>
</div>
</blockquote>
</blockquote>
<blockquote style="margin:0 0 0 40px;border:none;padding:0px">
<div><br>
</div>
</blockquote>
<blockquote style="margin:0 0 0 40px;border:none;padding:0px">
<blockquote style="margin:0 0 0 40px;border:none;padding:0px">
<div>
<div>"Point>>abs"</div>
</div>
</blockquote>
<blockquote style="margin:0 0 0 40px;border:none;padding:0px">
<div>
<div>[abs | </div>
</div>
</blockquote>
<blockquote style="margin:0 0 0 40px;border:none;padding:0px">
<div>
<div> ^x abs @ y abs]. </div>
</div>
</blockquote>
</blockquote>
<blockquote style="margin:0 0 0 40px;border:none;padding:0px">
<div><br>
</div>
</blockquote>
<blockquote style="margin:0 0 0 40px;border:none;padding:0px">
<blockquote style="margin:0 0 0 40px;border:none;padding:0px">
<div>
<div>"Point>>extent:" </div>
</div>
</blockquote>
<blockquote style="margin:0 0 0 40px;border:none;padding:0px">
<div>
<div>[extent: aPoint |</div>
</div>
</blockquote>
<blockquote style="margin:0 0 0 40px;border:none;padding:0px">
<div>
<div> ^Rectangle origin: self extent: aPoint] </div>
</div>
</blockquote>
</blockquote>
<div>
<div><br>
</div>
</div>
<div>Of course, it gets trickier when blocks have more than one
argument.. <br>
</div>
<div><br>
</div>
<div>
<blockquote style="margin:0px 0px 0px
40px;border:none;padding:0px">
<div>[add: a to: b | a + b]. </div>
</blockquote>
<blockquote style="margin:0px 0px 0px
40px;border:none;padding:0px">
<div>(add_to value: 3 value: 4) = 7. "old style block
evaluation" </div>
</blockquote>
<blockquote style="margin:0px 0px 0px
40px;border:none;padding:0px">
<div>(add: 3 to: 4) = 7. </div>
<div><br>
</div>
</blockquote>
</div>
<div>I think building a separate Parser is a sensible approach
-- is there a Smalltalk Parser as a separate package that can
be tweaked without affecting the running image?<br>
</div>
<div><br>
</div>
<div>Thanks,</div>
<div>Francisco</div>
<div><br>
</div>
<div><br>
</div>
</div>
<br>
<fieldset class="moz-mime-attachment-header"></fieldset>
</blockquote>
<p><br>
</p>
</body>
</html>