<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le lun. 19 août 2019 à 03:37, John Pfersich via Squeak-dev <<a href="mailto:squeak-dev@lists.squeakfoundation.org">squeak-dev@lists.squeakfoundation.org</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto">The full definition from the draft standards (don’t have the standard handy) is:<div><br></div><div><div><block constructor> ::= '[' <block body> ']'</div><div><block body> ::= [<block argument>* '|'] [<temporaries>] [<statements>]</div><div><block argument> ::= ':' identifier</div><div><br></div><div>The last line is on the next page of the draft.</div><br><div id="gmail-m_-430685579486011620AppleMailSignature" dir="ltr"><span style="font-size:13pt">/————————————————————/</span><div><span style="font-size:13pt">For encrypted mail use <a href="mailto:jgpfersich@protonmail.com" target="_blank">jgpfersich@protonmail.com</a></span><div>Get a free account at <a href="http://ProtonMail.com" target="_blank">ProtonMail.com</a></div><div>Web: <a href="http://www.objectnets.net" target="_blank">www.objectnets.net</a> and <a href="http://www.objectnets.org" target="_blank">www.objectnets.org</a></div></div></div><div dir="ltr"><br>On Aug 18, 2019, at 12:09, JOHN SARKELA via Squeak-dev <<a href="mailto:squeak-dev@lists.squeakfoundation.org" target="_blank">squeak-dev@lists.squeakfoundation.org</a>> wrote:<br><br></div><blockquote type="cite"><div dir="ltr"><div style="overflow-wrap: break-word;"><div style="overflow-wrap: break-word;">The ANSI standard has the following rules for blocks:<div>
                
        
        
                <div class="gmail-m_-430685579486011620page" title="Page 21">
                        <div class="gmail-m_-430685579486011620layoutArea">
                                <div class="gmail-m_-430685579486011620column"><p><span style="font-size:10pt;font-family:"ArialMT""><block constructor> ::= '[' <block body> ']'<br>
<block body> ::= [<block argument>* '|'] [<temporaries>] [<statements>]
</span></p>
                                </div>
                        </div>
                        The standard does not recognize [:x] as legal syntax for a block.<page21image64736448.png>
                        <page21image37471328.png>
                        <page21image64735680.png>
                        <page21image64733952.png>
                        <page21image64746816.png>
                </div><div><br></div></div></div></div></div></blockquote></div></div></blockquote><div>Yes, same as blue book. (block temporaries apart, this did not exist in st-80), bar is mandatory. <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto"><div><blockquote type="cite"><div dir="ltr"><div style="overflow-wrap: break-word;"><div style="overflow-wrap: break-word;"><div><div><blockquote type="cite"><div>On Aug 18, 2019, at 3:03 PM, Levente Uzonyi <<a href="mailto:leves@caesar.elte.hu" target="_blank">leves@caesar.elte.hu</a>> wrote:</div><br class="gmail-m_-430685579486011620Apple-interchange-newline"><div><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline">Hi Nicolas,</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline">Thanks for investigating this.</span></div></blockquote></div></div></div></div></div></blockquote></div></div></blockquote><div>It's been a pretext for playing with historical material ;) <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto"><div><blockquote type="cite"><div dir="ltr"><div style="overflow-wrap: break-word;"><div style="overflow-wrap: break-word;"><div><div><blockquote type="cite"><div><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline">I still think that it's just a parser bug, which is accidentally "used" sometimes, especially because it only works when the block is empty.</span></div></blockquote></div></div></div></div></div></blockquote></div></div></blockquote><div>Seeing the code, it's the & (hereType ~~ #rightBracket) condition following (t1 size > 0 which makes [:x ] syntax possible.</div><div>Since it has been added
 explicitely, my bet is that it has been added purposely and deliberataly rather than accidentally.</div><div><br></div><div>It seems [:x ] was not accepted in earlier version 00:<br></div><div>
<pre>[block | blk argNodes argument |
         " '[' {:var.} (:var|statements) ']'   BlockNode"
        argNodes ← (Vector new: 1) asStream.
        (self match: #leftBracket)
          ifTrue:
                [[(self match: #colon) and: [((argument ← self match: #word)
                  ifTrue: [argNodes next← encoder autoBind: argument]
                  ifFalse: [↑self expected: 'Argument name'])]] whileTrueDo: [].
                (argNodes empty or: [(self match: #verticalBar)])   false
                  ifTrue: [↑self expected: 'Vertical bar'].
                ((blk ← self statements: argNodes contents doit: false) and: [(self match: #rightBracket)])
                  ifTrue: [↑blk].
                ↑self expected: 'Period or right bracket']
          ifFalse: [↑self expected: 'Left bracket']].</pre>

</div><div></div><div></div><div> 
<a href="http://xeroxalto.computerhistory.org/Indigo/BasicDisks/Smalltalk14.bfs!1_/.st80sources.v00.html">http://xeroxalto.computerhistory.org/Indigo/BasicDisks/Smalltalk14.bfs!1_/.st80sources.v00.html</a>

</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto"><div><blockquote type="cite"><div dir="ltr"><div style="overflow-wrap: break-word;"><div style="overflow-wrap: break-word;"><div><div><blockquote type="cite"><div><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline">Or does it work in other dialects with non-empty blocks?</span></div></blockquote></div></div></div></div></div></blockquote></div></div></blockquote><div><br></div><div>Nope, the syntax is only for empty blocks.<br></div><div>It could have worked for any block if we wanted to, because that vertical bar is just a decoration in blocks.</div><div>From disambiguation POV, it's absolutely unecessary, the block arguments are already delimited by colon prefix :x</div><div>Symetrically, we don't use such delimitation between method pattern and statements... But it evolved across history:<br></div><div><br></div><div>Historically, Smalltalk-76 did use a single (optional) bar for declaring temporaries (if any):</div><div>methodDefnition := pattern [ '|' temporaries ] '[' statements ']'<br></div><div><br></div><div>Then early Smalltalk-80 method definitions did use empty temps systematically '[' pattern '|' '|' statements ']'</div><div>The two bars were mandatory at that time</div><div></div><div>
<pre>"374" LADParser$'Parser'
[temporaries | vars |
         "[ '|' {variable} ]   {variable, ..., variable}"
        (self match: #verticalBar) and: [((self match: #verticalBar)
          ifTrue: [↑#()].
        vars ← (Vector new: 8) asStream.
        [hereType   #word] whileTrueDo: [vars next← encoder bind: self advance].
        (self match: #verticalBar)
          ifTrue: [↑vars contents])].
        ↑self expected: 'Vertical bar'].</pre>

</div><div>
<a href="http://xeroxalto.computerhistory.org/Indigo/BasicDisks/Smalltalk14.bfs!1_/.st80sources.v00.html">http://xeroxalto.computerhistory.org/Indigo/BasicDisks/Smalltalk14.bfs!1_/.st80sources.v00.html</a> <br></div><div><br></div><div>I guess that current block syntax is the legacy from all these syntax evolutions/experiments...</div><div><br></div><div>Personnally, I like the bar, because it reminds me mathematical notation I learned at school for ensemble comprehension <a href="https://fr.wikipedia.org/wiki/Ensemble.">https://fr.wikipedia.org/wiki/Ensemble.</a>..</div><div><br></div><div>     {x 


E | x even }</div><div><br></div><div>translated in Smalltalk:</div><div><br></div><div>    E select: [:x | x even].</div><div><br></div><div>without bar, I'm really NOT used to it:
<div><br></div><div>    E select: [:x x even].</div>

</div><div><br></div><div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto"><div><blockquote type="cite"><div dir="ltr"><div style="overflow-wrap: break-word;"><div style="overflow-wrap: break-word;"><div><div><blockquote type="cite"><div><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline">Is it used in other dialects?</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"></div></blockquote></div></div></div></div></div></blockquote></div></div></blockquote><div></div><div>It is used in Squeak:</div><div><br></div><div>Context>>runSimulated: aBlock<br>           "Simulate the execution of the argument, current. Answer the result it <br>    returns."<br><br>     ^ thisContext sender<br>              runSimulated: aBlock<br>              contextAtEachStep: [:ignored]<br><br>           "Context runSimulated: [Pen new defaultNib: 5; go: 100]"</div><div><br></div><div>See also MCMcdReader>>#loadPatch MCPatch>>#initializeWithBase:target:</div><div><br></div><div>I also see two usages in VW, MethodContext>>#selector and BlockContext>>#selector.</div><div>The fact that these two methods still have undescore (left arrow) assignment in source code and have same argument signature
[:ignored]

 speaks for itself!!!</div><div>I'm convinced that it's been an easy hack/feature originating in early 80s (probably by Dan Ingalls), and forgotten since, that never made it into the offical specifications.</div><div>Smalltalk is malleable enough :)</div><div><br></div><div>We can deprecate it if we want, but we will have to support backward compatibility in the Parser. The boring side of frozen specs...<br></div><div>In this case,we'd better not support it in Shout.<br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto"><div><blockquote type="cite"><div dir="ltr"><div style="overflow-wrap: break-word;"><div style="overflow-wrap: break-word;"><div><div><blockquote type="cite"><div><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline">Levente</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline">On Sun, 18 Aug 2019, Nicolas Cellier wrote:</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><blockquote type="cite" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">Le jeu. 15 août 2019 à 12:21, Levente Uzonyi <<a href="mailto:leves@caesar.elte.hu" target="_blank">leves@caesar.elte.hu</a>> a écrit :<br>     On Thu, 15 Aug 2019, Tobias Pape wrote:<br><br>     ><br>     >> On 15.08.2019, at 03:29, Levente Uzonyi <<a href="mailto:leves@caesar.elte.hu" target="_blank">leves@caesar.elte.hu</a>> wrote:<br>     >><br>     >> On Wed, 14 Aug 2019, <a href="mailto:commits@source.squeak.org" target="_blank">commits@source.squeak.org</a> wrote:<br>     >><br>     >>> A new version of ShoutCore was added to project The Inbox:<br>     >>> <a href="http://source.squeak.org/inbox/ShoutCore-ct.69.mcz" target="_blank">http://source.squeak.org/inbox/ShoutCore-ct.69.mcz</a><br>     >>><br>     >>> ==================== Summary ====================<br>     >>><br>     >>> Name: ShoutCore-ct.69<br>     >>> Author: ct<br>     >>> Time: 14 August 2019, 10:43:04.7164 pm<br>     >>> UUID: 7d165f4e-09bf-a445-a664-5e8edb9867b8<br>     >>> Ancestors: ShoutCore-ul.68<br>     >>><br>     >>> Fix bug in SHParserST80: Wrong styling after blocks with arguments without statements<br>     >><br>     >> If you mean that Shout should accept [ :x ], then no, I'm pretty sure that's not valid smalltalk syntax, even if Parser accepts it.<br>     >> The vertical bar, even though I consider it unnecessary in all cases, is mandatory when there are arguments.<br>     ><br>     > I only got to know this "shortcut syntax" because eliot used it either Cog or somewhere in trunk when preparing something (Spur? full block closures? I forgot). So this is a syntax idiosyncrasy that is in active use, not only "old code".<br>     ><br>     > Either we forbid it in the parser and change all of the image or allow it in Shout.<br><br>     Can you give me examples?<br>     I suspect those are just typos, which the parser accidentally accepted<br>     (and Shout as well before my fixes).<br><br>     Levente<br>I don't remember seeing this syntax before and found it a bit surprising.<br>So, for the sake of curiosity, I tried in some other dialects.<br>[:x ] is accepted syntax in<br>- Visualworks (8.3),<br>- Pharo (v7 with OpalCompiler)<br>- Smalltalk-80 (apple v0.?)<br>[:x ] is invalid in<br>- Dolphin<br>- Smalltalk/X (jv branch)<br>So it seems that it's something originating from original Smalltalk-80, but not reproducted in non derivated dialects...<br>The bar is mandatory in blue book specification (see the last pages)<br>Capture d’écran 2019-08-18 à 17.11.53.png<br>So it seems that implementation did not agree with specifications for ages...<br>Capture d’écran 2019-08-18 à 18.56.05.png<br><br>     ><br>     > Best regards<br>     >       -Tobias<br>     ><br>     >><br>     >> Levente<br>     >><br>     >>><br>     >>> Thanks Jakob for the report!<br>     >>><br>     >>> =============== Diff against ShoutCore-ul.68 ===============<br>     >>><br>     >>> Item was changed:<br>     >>> ----- Method: SHParserST80>>parseBlockArguments (in category 'parse') -----<br>     >>> parseBlockArguments<br>     >>><br>     >>>     currentTokenFirst == $: ifFalse: [ ^self ].<br>     >>>     [ currentTokenFirst == $: ] whileTrue: [<br>     >>>             self<br>     >>>                     scanPast: #blockArgColon;<br>     >>>                     parseArgument: #blockPatternArg ].<br>     >>> +   ((self parseVerticalBarForTemporaries: #blockArgsBar) and: [<br>     >>> +           currentTokenFirst ~= $] ])<br>     >>> +                   ifFalse: [<br>     >>> +                           self fail ": Missing block args bar" ]!<br>     >>> -   (self parseVerticalBarForTemporaries: #blockArgsBar) ifFalse: [<br>     >>> -           self fail ": Missing block args bar" ]!<br>     >></blockquote></div></blockquote></div><br></div></div></div></div></blockquote><blockquote type="cite"><div dir="ltr"><span></span><br></div></blockquote></div></div><br>
</blockquote></div></div>