<div dir="ltr"><div dir="auto"><div><h1 class="gmail-citation__title" style="box-sizing:border-box;font-size:1.75rem;margin:0px;line-height:35px;color:rgb(51,51,51);font-family:"Open Sans",sans-serif"><span style="font-family:Arial,Helvetica,sans-serif;font-size:small;font-weight:normal;color:rgb(34,34,34)">Dan Ingalls talks about the indexing operator in "The evolution of Smalltalk: from Smalltalk-72 through Squeak" [1]</span><br></h1></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><div>In Smalltalk--76</div></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><div>a • i ← b • i</div></div></div></blockquote><div><div><div>In Smalltalk--80</div></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><div>a at: i put: (b at: i)</div></div></div></blockquote><div><div><div>Smalltalk--80--didnahappen</div></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><div>a @ i := b @ i</div></div></div></blockquote><div><div><div>or</div></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><div>a ! i := b ! i</div></div></div></blockquote></blockquote><div dir="auto"><div><br></div></div><div dir="auto"><div><div>[1] <a href="http://worrydream.com/refs/Ingalls%20-%20The%20Evolution%20of%20Smalltalk.pdf">http://worrydream.com/refs/Ingalls%20-%20The%20Evolution%20of%20Smalltalk.pdf</a><br></div><div><div id="m_-7116098293796523862m_7780317447773535294AppleMailSignature" dir="ltr"><div><br></div></div><div dir="ltr">On 16 Jul 2022, at 10:51, Luciano Notarfrancesco <<a href="mailto:luchiano@gmail.com" target="_blank">luchiano@gmail.com</a>> wrote:<br><br></div><blockquote type="cite"><div dir="ltr"><div dir="auto">Hola!</div><div dir="auto">Interesting. Actually methods written like this look more complicated than the original Smalltalk-80 syntax to me, but it’s an interesting idea, maybe looks complicated just because I’m not used to it. Let us know how it goes.</div><div dir="auto"><br></div><div dir="auto">Note that in Cuis #: is a valid binary message. I use it, maybe I’m the only one who uses it.</div><div dir="auto"><br></div><div dir="auto">Another idea we discussed before was to compile ‘f(x)’ as ‘f value: x’. Note that this is not ambiguous with Smalltalk-80. We could also compile ‘a[i]’ as ‘a at: i’. I’m not sure if it’s worth to complicate the Smalltalk-80 syntax with things like this, tho, I also value simplicity.<br></div><div dir="auto"><br></div><div dir="auto"><br></div><div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, 16 Jul 2022 at 01:39 Francisco Garau via Cuis-dev <<a href="mailto:cuis-dev@lists.cuis.st" target="_blank">cuis-dev@lists.cuis.st</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)"><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" style="font-family:monospace;color:rgb(0,0,0)">[ : 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" style="font-family:monospace;color:rgb(0,0,0)">succ := [:n | n + 1]</font> we could write <font face="monospace" style="font-family:monospace;color:rgb(0,0,0)">[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" style="font-family:monospace;color:rgb(0,0,0)">(succ: 3) = 4</font> instead of <font face="monospace" style="font-family:monospace;color:rgb(0,0,0)">(succ value: 3) = 4</font>. </div><div><br></div><div>A short example will make this clear. </div><div><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div>Vanilla Smalltalk</div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div>succ := [:n | n + 1].</div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div>(succ value: 3) = 4. </div></blockquote><div><br></div><div>Extended Block Syntax</div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div>[succ: n | n + 1]. </div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div>(succ: 3 ) = 4. </div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div>"the above is equivalent to" </div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div>(succ perform: #: with: 3) = 4. </div></blockquote><blockquote style="margin:0px 0px 0px 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:0px 0px 0px 40px;border:none;padding:0px"><div><div>"Point class>x:y:" </div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div>[x: xInteger y: yInteger | </div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div> ^self basicNew setX: xInteger setY: yInteger].</div></div></blockquote></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><br></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div>"Point>>abs"</div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div>[abs | </div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div> ^x abs @ y abs]. </div></div></blockquote></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><br></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div>"Point>>extent:" </div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div>[extent: aPoint |</div></div></blockquote><blockquote style="margin:0px 0px 0px 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><div dir="ltr"><div><br></div><div><br></div></div>
-- <br>
Cuis-dev mailing list<br>
<a href="mailto:Cuis-dev@lists.cuis.st" target="_blank">Cuis-dev@lists.cuis.st</a><br>
<a href="https://lists.cuis.st/mailman/listinfo/cuis-dev" rel="noreferrer" target="_blank">https://lists.cuis.st/mailman/listinfo/cuis-dev</a><br>
</blockquote></div></div>
</div></blockquote></div></div></div></div>