<div dir="ltr"><div dir="ltr"><div>Thank you yary. </div><div><br></div><div>I'm not sure we've seen any clarification on this. There's a reference to "Literal Lists" in the Perl 6 docs that looks related, but I don't have a "plain-speak" explanation for how semicolons, lists, push() and arrays inter-relate.</div><div><br></div><div><a href="https://docs.perl6.org/language/list" target="_blank">https://docs.perl6.org/language/list</a><br></div><div><br></div><div>Hoping a Perl_6 guru can chime in? </div><div><br></div><div>Thank you.</div><div><br></div><div>--Bill.</div><div><br></div><div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Apr 14, 2019 at 1:26 PM yary <<a href="mailto:not.com@gmail.com" target="_blank">not.com@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Looks like perl6 semicolon has different meaning in a list vs a capture. In a list, it "makes sense to me"<div><br><div><div>> perl6 --version</div><div>This is Rakudo Star version 2018.10 built on MoarVM version 2018.10</div><div>implementing Perl 6.c.</div></div><div><div>>perl6</div><div>To exit type 'exit' or '^D'</div><div>> ('a').perl</div><div>"a"</div><div>> ('a';).perl</div><div>"a"</div><div>> ('a', 'b' ;).perl</div><div>("a", "b")</div><div>> ('a', 'b' ; 'c').perl</div><div>(("a", "b"), "c")</div><div>> ('a', 'b' ; 'c' ;).perl</div><div>(("a", "b"), "c")</div><div>> ('a', 'b' ; 'c' ; ;).perl</div><div>(("a", "b"), "c", Nil)</div></div><div><div>> ('a', 'b' ; 'c' , ; ;).perl</div><div>(("a", "b"), ("c",), Nil)</div></div><div><br></div><div>- the rule "a single thing is a scalar, a single thing followed by a comma is a list" applies in the last example</div><div><br></div><div>But there's inconsistency with captures.</div><div><br></div><div><div><div>>\('a').perl</div><div>\("a")</div><div>> \('a';).perl; # Unexpected empty list at end</div><div>\(("a",), ())</div><div>> \('a', 'b' ;).perl; # Unexpected empty list at end</div><div>\(("A", "b"), ())</div><div>> \('a', 'b' ; 'c').perl; # unexpected "c" as list</div><div>\(("a", "b"), ("c",))</div><div>> \('a', 'b' ; 'c' ;).perl; # "c" as list, and empty list at end</div><div>\(("a", "b"), ("c",), ())</div><div>> \('a', 'b' ; 'c' ; ;).perl; # "c" as list, and 2 empty lists instead of single nil at end</div><div>\(("a", "b"), ("c",), (), ())</div><div>> \('a', 'b' ; 'c' , ; ;).perl; # 2 empty lists instead of single nil at end</div><div>\(("a", "b"), ("c",), (), ())</div><br>This cries for an explanation, or a bug report.</div></div><div><br></div><div><div><div dir="ltr" class="m_4128553335740111576gmail-m_3578546783037744036m_-4063380590967921333m_-7362789417834142765gmail-m_2294546808588829132gmail_signature">-y<br></div></div><br></div></div></div></div></div></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Apr 14, 2019 at 11:57 AM Joseph Brenner <<a href="mailto:doomvox@gmail.com" target="_blank">doomvox@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">Just in case it wasn't clear from Bill's discussion, I think the<br>
reason this case seems weird is normally we expect trailing separators<br>
to be ignored, as with the extra comma here:<br>
<br>
   > my @monsters = ('ghidora', 'mothera', 'wolfman', 'zuckerberg',);<br>
  [ghidora mothera wolfman zuckerberg]<br>
<br>
If you do this, and type in a trailing semi-colon in the wrong place,<br>
you stumble across some odd behavior:<br>
<br>
   > @monsters.push('tingler';)<br>
  [ghidora mothera wolfman zuckerberg (tingler) ()]<br>
<br>
It seems a bit LTA, though it might be unavoidable because this is valid:<br>
<br>
   my @monsters = ('ghidora', 'mothera'; 'frankenstein',<br>
'wolfman';'purple-people-eater')<br>
   [(ghidora mothera) (frankenstein wolfman) purple-people-eater]<br>
<br>
Though even here, the behavior seems a bit strange, because<br>
"purple-people-eater" ended up as an element in the top-level list.<br>
Hm, no empty list is appended if you do this:<br>
<br>
  my @monsters = ('ghidora', 'mothera'; 'frankenstein', 'wolfman';)<br>
  [(ghidora mothera) (frankenstein wolfman)]<br>
<br>
But the push method seems to interpret it differently:<br>
<br>
  @monsters.push('purple-people-eater';)<br>
  [(ghidora mothera) (frankenstein wolfman) (purple-people-eater) ()]<br>
<br>
<br>
<br>
On 4/14/19, William Michels via perl6-users <<a href="mailto:perl6-users@perl.org" target="_blank">perl6-users@perl.org</a>> wrote:<br>
> Hello,<br>
><br>
> I've been working through Patrick Michaud's excellent videos from the<br>
> The Perl Conference 2016. At about 35:45 of the following 2016 video<br>
> (Part 1 of 2), Patrick discusses arrays:<br>
><br>
> <a href="https://www" target="_blank">https://www</a>[dot]youtube[dot]com/watch?v=ySch4xpoPA0<br>
><br>
> At this point in the video, Patrick also discusses push() and pop()<br>
> calls on arrays. For practice I tried pushing and popping strings in<br>
> the REPL. However, I discovered an unusual property when I misplaced a<br>
> semicolon during call to push(). See what happens below when a<br>
> semicolon is included within the parentheses of push():<br>
><br>
> "This is Rakudo version 2018.12 built on MoarVM version 2018.12<br>
> implementing Perl 6.d."<br>
><br>
>> my @countries = "UK", "Spain", "Slovakia", "Sweden";<br>
> [UK Spain Slovakia Sweden]<br>
>> @countries.push("Finland");<br>
> [UK Spain Slovakia Sweden Finland]<br>
>> my @countries = "UK", "Spain", "Slovakia", "Sweden";<br>
> [UK Spain Slovakia Sweden]<br>
>> @countries.push("Finland";)<br>
> [UK Spain Slovakia Sweden (Finland) ()]<br>
>> my @countries = "UK", "Spain", "Slovakia", "Sweden";<br>
> [UK Spain Slovakia Sweden]<br>
>> @countries.push("Finland";);<br>
> [UK Spain Slovakia Sweden (Finland) ()]<br>
><br>
> Misplacing a semicolon within the push() call adds two elements to the<br>
> array. When I examine these two elements, I see that they are both<br>
> "List" elements:<br>
><br>
>> @countries[3].WHAT<br>
> (Str)<br>
>> @countries[4].WHAT<br>
> (List)<br>
>> @countries[5].WHAT<br>
> (List)<br>
><br>
> Apparently, multiple semicolons within push() will add multiple list<br>
> elements to the end of the intended array:<br>
><br>
>> my @countries = "UK", "Spain", "Slovakia", "Sweden";<br>
> [UK Spain Slovakia Sweden]<br>
>> @countries.push("Finland";;);<br>
> [UK Spain Slovakia Sweden (Finland) () ()]<br>
>> my @countries = "UK", "Spain", "Slovakia", "Sweden";<br>
> [UK Spain Slovakia Sweden]<br>
>> @countries.push(;;;;;;;);<br>
> [UK Spain Slovakia Sweden () () () () () () () ()]<br>
><br>
> It is surprising to me that "List" elements are appended to the array<br>
> with push() as described above. If one tries to add one or more<br>
> elements via indexing and there 'aren't enough elements' so to speak<br>
> (by accident or design), the array grows by inserting "Any" elements,<br>
> not "List" elements:<br>
><br>
>> my @countries = "UK", "Spain", "Slovakia", "Sweden";<br>
> [UK Spain Slovakia Sweden]<br>
>> @countries[5] = "Finland";<br>
> Finland<br>
>> say @countries<br>
> [UK Spain Slovakia Sweden (Any) Finland]<br>
>><br>
>> my @countries = "UK", "Spain", "Slovakia", "Sweden";<br>
> [UK Spain Slovakia Sweden]<br>
>> @countries[6..7] = "Finland", "Norway";<br>
> (Finland Norway)<br>
>> say @countries<br>
> [UK Spain Slovakia Sweden (Any) (Any) Finland Norway]<br>
><br>
> I've briefly checked pop() to see if there are similar issues, but 1)<br>
> placing a string within the parentheses of pop() will throw an error,<br>
> and 2) placing a semicolon within the parentheses of pop() will throw<br>
> an error. However, these error message are slightly different. A<br>
> string argument to pop() will result in an error that says "Too many<br>
> positionals passed; expected 1 argument but got 2" while a semicolon<br>
> argument to pop() will result in an error that says "Too many<br>
> positionals passed; expected 1 argument but got 3".<br>
><br>
>> my @countries = "UK", "Spain", "Slovakia", "Sweden";<br>
> [UK Spain Slovakia Sweden]<br>
>> @countries.pop("Finland")<br>
> Too many positionals passed; expected 1 argument but got 2<br>
>   in block <unit> at <unknown file> line 1<br>
><br>
>> @countries.pop(;)<br>
> Too many positionals passed; expected 1 argument but got 3<br>
>   in block <unit> at <unknown file> line 1<br>
><br>
>><br>
><br>
><br>
> Any help appreciated,<br>
><br>
> Bill.<br>
><br>
> William Michels, Ph.D.<br>
><br>
> PS Thanks to Joe Brenner for talking over this Perl6 code with me.<br>
><br>
</blockquote></div></div></div>
</blockquote></div></div></div>