push() practice: misplaced semicolon creates list elements within array?

Hello,

I've been working through Patrick Michaud's excellent videos from the
The Perl Conference 2016. At about 35:45 of the following 2016 video
(Part 1 of 2), Patrick discusses arrays:

https://www.youtube.com/watch?v=ySch4xpoPA0

At this point in the video, Patrick also discusses push() and pop()
calls on arrays. For practice I tried pushing and popping strings in
the REPL. However, I discovered an unusual property when I misplaced a
semicolon during call to push(). See what happens below when a
semicolon is included within the parentheses of push():

"This is Rakudo version 2018.12 built on MoarVM version 2018.12
implementing Perl 6.d."

> my @countries = "UK", "Spain", "Slovakia", "Sweden";
[UK Spain Slovakia Sweden]
> @countries.push("Finland");
[UK Spain Slovakia Sweden Finland]
> my @countries = "UK", "Spain", "Slovakia", "Sweden";
[UK Spain Slovakia Sweden]
> @countries.push("Finland";)
[UK Spain Slovakia Sweden (Finland) ()]
> my @countries = "UK", "Spain", "Slovakia", "Sweden";
[UK Spain Slovakia Sweden]
> @countries.push("Finland";);
[UK Spain Slovakia Sweden (Finland) ()]

Misplacing a semicolon within the push() call adds two elements to the
array. When I examine these two elements, I see that they are both
"List" elements:

> @countries[3].WHAT
(Str)
> @countries[4].WHAT
(List)
> @countries[5].WHAT
(List)

Apparently, multiple semicolons within push() will add multiple list
elements to the end of the intended array:

> my @countries = "UK", "Spain", "Slovakia", "Sweden";
[UK Spain Slovakia Sweden]
> @countries.push("Finland";;);
[UK Spain Slovakia Sweden (Finland) () ()]
> my @countries = "UK", "Spain", "Slovakia", "Sweden";
[UK Spain Slovakia Sweden]
> @countries.push(;;;;;;;);
[UK Spain Slovakia Sweden () () () () () () () ()]

It is surprising to me that "List" elements are appended to the array
with push() as described above. If one tries to add one or more
elements via indexing and there 'aren't enough elements' so to speak
(by accident or design), the array grows by inserting "Any" elements,
not "List" elements:

> my @countries = "UK", "Spain", "Slovakia", "Sweden";
[UK Spain Slovakia Sweden]
> @countries[5] = "Finland";
Finland
> say @countries
[UK Spain Slovakia Sweden (Any) Finland]
>
> my @countries = "UK", "Spain", "Slovakia", "Sweden";
[UK Spain Slovakia Sweden]
> @countries[6..7] = "Finland", "Norway";
(Finland Norway)
> say @countries
[UK Spain Slovakia Sweden (Any) (Any) Finland Norway]

I've briefly checked pop() to see if there are similar issues, but 1)
placing a string within the parentheses of pop() will throw an error,
and 2) placing a semicolon within the parentheses of pop() will throw
an error. However, these error message are slightly different. A
string argument to pop() will result in an error that says "Too many
positionals passed; expected 1 argument but got 2" while a semicolon
argument to pop() will result in an error that says "Too many
positionals passed; expected 1 argument but got 3".

> my @countries = "UK", "Spain", "Slovakia", "Sweden";
[UK Spain Slovakia Sweden]
> @countries.pop("Finland")
Too many positionals passed; expected 1 argument but got 2
  in block <unit> at <unknown file> line 1

> @countries.pop(;)
Too many positionals passed; expected 1 argument but got 3
  in block <unit> at <unknown file> line 1

>


Any help appreciated,

Bill.

William Michels, Ph.D.

PS Thanks to Joe Brenner for talking over this Perl6 code with me.
0
perl6
4/14/2019 7:07:39 AM
perl.perl6.users 1163 articles. 0 followers. Follow

7 Replies
13 Views

Similar Articles

[PageSpeed] 58

A semicolon is the syntax used for multidimensional arrays.

See https://docs.perl6.org/language/subscripts#Multiple_dimensions


On 14/04/2019 15:07, William Michels via perl6-users wrote:
> Hello,
>
> I've been working through Patrick Michaud's excellent videos from the
> The Perl Conference 2016. At about 35:45 of the following 2016 video
> (Part 1 of 2), Patrick discusses arrays:
>
> https://www.youtube.com/watch?v=ySch4xpoPA0
>
> At this point in the video, Patrick also discusses push() and pop()
> calls on arrays. For practice I tried pushing and popping strings in
> the REPL. However, I discovered an unusual property when I misplaced a
> semicolon during call to push(). See what happens below when a
> semicolon is included within the parentheses of push():
>
> "This is Rakudo version 2018.12 built on MoarVM version 2018.12
> implementing Perl 6.d."
>
>> my @countries = "UK", "Spain", "Slovakia", "Sweden";
> [UK Spain Slovakia Sweden]
>> @countries.push("Finland");
> [UK Spain Slovakia Sweden Finland]
>> my @countries = "UK", "Spain", "Slovakia", "Sweden";
> [UK Spain Slovakia Sweden]
>> @countries.push("Finland";)
> [UK Spain Slovakia Sweden (Finland) ()]
>> my @countries = "UK", "Spain", "Slovakia", "Sweden";
> [UK Spain Slovakia Sweden]
>> @countries.push("Finland";);
> [UK Spain Slovakia Sweden (Finland) ()]
>
> Misplacing a semicolon within the push() call adds two elements to the
> array. When I examine these two elements, I see that they are both
> "List" elements:
>
>> @countries[3].WHAT
> (Str)
>> @countries[4].WHAT
> (List)
>> @countries[5].WHAT
> (List)
>
> Apparently, multiple semicolons within push() will add multiple list
> elements to the end of the intended array:
>
>> my @countries = "UK", "Spain", "Slovakia", "Sweden";
> [UK Spain Slovakia Sweden]
>> @countries.push("Finland";;);
> [UK Spain Slovakia Sweden (Finland) () ()]
>> my @countries = "UK", "Spain", "Slovakia", "Sweden";
> [UK Spain Slovakia Sweden]
>> @countries.push(;;;;;;;);
> [UK Spain Slovakia Sweden () () () () () () () ()]
>
> It is surprising to me that "List" elements are appended to the array
> with push() as described above. If one tries to add one or more
> elements via indexing and there 'aren't enough elements' so to speak
> (by accident or design), the array grows by inserting "Any" elements,
> not "List" elements:
>
>> my @countries = "UK", "Spain", "Slovakia", "Sweden";
> [UK Spain Slovakia Sweden]
>> @countries[5] = "Finland";
> Finland
>> say @countries
> [UK Spain Slovakia Sweden (Any) Finland]
>> my @countries = "UK", "Spain", "Slovakia", "Sweden";
> [UK Spain Slovakia Sweden]
>> @countries[6..7] = "Finland", "Norway";
> (Finland Norway)
>> say @countries
> [UK Spain Slovakia Sweden (Any) (Any) Finland Norway]
>
> I've briefly checked pop() to see if there are similar issues, but 1)
> placing a string within the parentheses of pop() will throw an error,
> and 2) placing a semicolon within the parentheses of pop() will throw
> an error. However, these error message are slightly different. A
> string argument to pop() will result in an error that says "Too many
> positionals passed; expected 1 argument but got 2" while a semicolon
> argument to pop() will result in an error that says "Too many
> positionals passed; expected 1 argument but got 3".
>
>> my @countries = "UK", "Spain", "Slovakia", "Sweden";
> [UK Spain Slovakia Sweden]
>> @countries.pop("Finland")
> Too many positionals passed; expected 1 argument but got 2
>    in block <unit> at <unknown file> line 1
>
>> @countries.pop(;)
> Too many positionals passed; expected 1 argument but got 3
>    in block <unit> at <unknown file> line 1
>
>
> Any help appreciated,
>
> Bill.
>
> William Michels, Ph.D.
>
> PS Thanks to Joe Brenner for talking over this Perl6 code with me.
0
rnhainsworth
4/14/2019 7:39:02 AM
Richard Hainsworth <rnhainsworth@gmail.com> wrote:
> A semicolon is the syntax used for multidimensional arrays.
>
> See https://docs.perl6.org/language/subscripts#Multiple_dimensions

Thanks.  I was trying to help Bill with that question, and I couldn't
quite see what was going on there.   You can't really do a web search
on "<computer language>" and ";"  and expect to learn anything.

And reading through that section on multidimensional arrays, it
doesn't immediately leap out why Bill would be seeing this behavior.
It's mostly a discussion of dereferencing complex data structures, not
creating them.   Where it does create multiple levels it uses the
comma.


Richard Hainsworth <rnhainsworth@gmail.com> wrote:
> A semicolon is the syntax used for multidimensional arrays.
>
> See https://docs.perl6.org/language/subscripts#Multiple_dimensions
>
>
> On 14/04/2019 15:07, William Michels via perl6-users wrote:
>> Hello,
>>
>> I've been working through Patrick Michaud's excellent videos from the
>> The Perl Conference 2016. At about 35:45 of the following 2016 video
>> (Part 1 of 2), Patrick discusses arrays:
>>
>> https://www.youtube.com/watch?v=ySch4xpoPA0
>>
>> At this point in the video, Patrick also discusses push() and pop()
>> calls on arrays. For practice I tried pushing and popping strings in
>> the REPL. However, I discovered an unusual property when I misplaced a
>> semicolon during call to push(). See what happens below when a
>> semicolon is included within the parentheses of push():
>>
>> "This is Rakudo version 2018.12 built on MoarVM version 2018.12
>> implementing Perl 6.d."
>>
>>> my @countries = "UK", "Spain", "Slovakia", "Sweden";
>> [UK Spain Slovakia Sweden]
>>> @countries.push("Finland");
>> [UK Spain Slovakia Sweden Finland]
>>> my @countries = "UK", "Spain", "Slovakia", "Sweden";
>> [UK Spain Slovakia Sweden]
>>> @countries.push("Finland";)
>> [UK Spain Slovakia Sweden (Finland) ()]
>>> my @countries = "UK", "Spain", "Slovakia", "Sweden";
>> [UK Spain Slovakia Sweden]
>>> @countries.push("Finland";);
>> [UK Spain Slovakia Sweden (Finland) ()]
>>
>> Misplacing a semicolon within the push() call adds two elements to the
>> array. When I examine these two elements, I see that they are both
>> "List" elements:
>>
>>> @countries[3].WHAT
>> (Str)
>>> @countries[4].WHAT
>> (List)
>>> @countries[5].WHAT
>> (List)
>>
>> Apparently, multiple semicolons within push() will add multiple list
>> elements to the end of the intended array:
>>
>>> my @countries = "UK", "Spain", "Slovakia", "Sweden";
>> [UK Spain Slovakia Sweden]
>>> @countries.push("Finland";;);
>> [UK Spain Slovakia Sweden (Finland) () ()]
>>> my @countries = "UK", "Spain", "Slovakia", "Sweden";
>> [UK Spain Slovakia Sweden]
>>> @countries.push(;;;;;;;);
>> [UK Spain Slovakia Sweden () () () () () () () ()]
>>
>> It is surprising to me that "List" elements are appended to the array
>> with push() as described above. If one tries to add one or more
>> elements via indexing and there 'aren't enough elements' so to speak
>> (by accident or design), the array grows by inserting "Any" elements,
>> not "List" elements:
>>
>>> my @countries = "UK", "Spain", "Slovakia", "Sweden";
>> [UK Spain Slovakia Sweden]
>>> @countries[5] = "Finland";
>> Finland
>>> say @countries
>> [UK Spain Slovakia Sweden (Any) Finland]
>>> my @countries = "UK", "Spain", "Slovakia", "Sweden";
>> [UK Spain Slovakia Sweden]
>>> @countries[6..7] = "Finland", "Norway";
>> (Finland Norway)
>>> say @countries
>> [UK Spain Slovakia Sweden (Any) (Any) Finland Norway]
>>
>> I've briefly checked pop() to see if there are similar issues, but 1)
>> placing a string within the parentheses of pop() will throw an error,
>> and 2) placing a semicolon within the parentheses of pop() will throw
>> an error. However, these error message are slightly different. A
>> string argument to pop() will result in an error that says "Too many
>> positionals passed; expected 1 argument but got 2" while a semicolon
>> argument to pop() will result in an error that says "Too many
>> positionals passed; expected 1 argument but got 3".
>>
>>> my @countries = "UK", "Spain", "Slovakia", "Sweden";
>> [UK Spain Slovakia Sweden]
>>> @countries.pop("Finland")
>> Too many positionals passed; expected 1 argument but got 2
>>    in block <unit> at <unknown file> line 1
>>
>>> @countries.pop(;)
>> Too many positionals passed; expected 1 argument but got 3
>>    in block <unit> at <unknown file> line 1
>>
>>
>> Any help appreciated,
>>
>> Bill.
>>
>> William Michels, Ph.D.
>>
>> PS Thanks to Joe Brenner for talking over this Perl6 code with me.
>
0
doomvox
4/14/2019 5:28:46 PM
--00000000000058a5cf058680feff
Content-Type: text/plain; charset="UTF-8"

I don't know much about PDL (the Perl Data Lanuage) but I do remember that
the semicolon as a "higher-level" array separator in P6 is a nod to PDL. It
is a bit of stub feature until someone needs it and specs out, prototypes
more of that data-slicing style. It's likely under-documented due to that
history.

-y


On Sun, Apr 14, 2019 at 10:29 AM Joseph Brenner <doomvox@gmail.com> wrote:

> Richard Hainsworth <rnhainsworth@gmail.com> wrote:
> > A semicolon is the syntax used for multidimensional arrays.
> >
> > See https://docs.perl6.org/language/subscripts#Multiple_dimensions
>
> Thanks.  I was trying to help Bill with that question, and I couldn't
> quite see what was going on there.   You can't really do a web search
> on "<computer language>" and ";"  and expect to learn anything.
>
> And reading through that section on multidimensional arrays, it
> doesn't immediately leap out why Bill would be seeing this behavior.
> It's mostly a discussion of dereferencing complex data structures, not
> creating them.   Where it does create multiple levels it uses the
> comma.
>
>
> Richard Hainsworth <rnhainsworth@gmail.com> wrote:
> > A semicolon is the syntax used for multidimensional arrays.
> >
> > See https://docs.perl6.org/language/subscripts#Multiple_dimensions
> >
> >
> > On 14/04/2019 15:07, William Michels via perl6-users wrote:
> >> Hello,
> >>
> >> I've been working through Patrick Michaud's excellent videos from the
> >> The Perl Conference 2016. At about 35:45 of the following 2016 video
> >> (Part 1 of 2), Patrick discusses arrays:
> >>
> >> https://www.youtube.com/watch?v=ySch4xpoPA0
> >>
> >> At this point in the video, Patrick also discusses push() and pop()
> >> calls on arrays. For practice I tried pushing and popping strings in
> >> the REPL. However, I discovered an unusual property when I misplaced a
> >> semicolon during call to push(). See what happens below when a
> >> semicolon is included within the parentheses of push():
> >>
> >> "This is Rakudo version 2018.12 built on MoarVM version 2018.12
> >> implementing Perl 6.d."
> >>
> >>> my @countries = "UK", "Spain", "Slovakia", "Sweden";
> >> [UK Spain Slovakia Sweden]
> >>> @countries.push("Finland");
> >> [UK Spain Slovakia Sweden Finland]
> >>> my @countries = "UK", "Spain", "Slovakia", "Sweden";
> >> [UK Spain Slovakia Sweden]
> >>> @countries.push("Finland";)
> >> [UK Spain Slovakia Sweden (Finland) ()]
> >>> my @countries = "UK", "Spain", "Slovakia", "Sweden";
> >> [UK Spain Slovakia Sweden]
> >>> @countries.push("Finland";);
> >> [UK Spain Slovakia Sweden (Finland) ()]
> >>
> >> Misplacing a semicolon within the push() call adds two elements to the
> >> array. When I examine these two elements, I see that they are both
> >> "List" elements:
> >>
> >>> @countries[3].WHAT
> >> (Str)
> >>> @countries[4].WHAT
> >> (List)
> >>> @countries[5].WHAT
> >> (List)
> >>
> >> Apparently, multiple semicolons within push() will add multiple list
> >> elements to the end of the intended array:
> >>
> >>> my @countries = "UK", "Spain", "Slovakia", "Sweden";
> >> [UK Spain Slovakia Sweden]
> >>> @countries.push("Finland";;);
> >> [UK Spain Slovakia Sweden (Finland) () ()]
> >>> my @countries = "UK", "Spain", "Slovakia", "Sweden";
> >> [UK Spain Slovakia Sweden]
> >>> @countries.push(;;;;;;;);
> >> [UK Spain Slovakia Sweden () () () () () () () ()]
> >>
> >> It is surprising to me that "List" elements are appended to the array
> >> with push() as described above. If one tries to add one or more
> >> elements via indexing and there 'aren't enough elements' so to speak
> >> (by accident or design), the array grows by inserting "Any" elements,
> >> not "List" elements:
> >>
> >>> my @countries = "UK", "Spain", "Slovakia", "Sweden";
> >> [UK Spain Slovakia Sweden]
> >>> @countries[5] = "Finland";
> >> Finland
> >>> say @countries
> >> [UK Spain Slovakia Sweden (Any) Finland]
> >>> my @countries = "UK", "Spain", "Slovakia", "Sweden";
> >> [UK Spain Slovakia Sweden]
> >>> @countries[6..7] = "Finland", "Norway";
> >> (Finland Norway)
> >>> say @countries
> >> [UK Spain Slovakia Sweden (Any) (Any) Finland Norway]
> >>
> >> I've briefly checked pop() to see if there are similar issues, but 1)
> >> placing a string within the parentheses of pop() will throw an error,
> >> and 2) placing a semicolon within the parentheses of pop() will throw
> >> an error. However, these error message are slightly different. A
> >> string argument to pop() will result in an error that says "Too many
> >> positionals passed; expected 1 argument but got 2" while a semicolon
> >> argument to pop() will result in an error that says "Too many
> >> positionals passed; expected 1 argument but got 3".
> >>
> >>> my @countries = "UK", "Spain", "Slovakia", "Sweden";
> >> [UK Spain Slovakia Sweden]
> >>> @countries.pop("Finland")
> >> Too many positionals passed; expected 1 argument but got 2
> >>    in block <unit> at <unknown file> line 1
> >>
> >>> @countries.pop(;)
> >> Too many positionals passed; expected 1 argument but got 3
> >>    in block <unit> at <unknown file> line 1
> >>
> >>
> >> Any help appreciated,
> >>
> >> Bill.
> >>
> >> William Michels, Ph.D.
> >>
> >> PS Thanks to Joe Brenner for talking over this Perl6 code with me.
> >
>

--00000000000058a5cf058680feff
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I don&#39;t know much about PDL (the Perl Data Lanuage) bu=
t I do remember that the semicolon as a &quot;higher-level&quot; array sepa=
rator in P6 is a nod to PDL. It is a bit of stub feature until someone need=
s it and specs out, prototypes more of that data-slicing style. It&#39;s li=
kely under-documented due to that history.<div><br clear=3D"all"><div><div =
dir=3D"ltr" class=3D"gmail_signature" data-smartmail=3D"gmail_signature">-y=
<br></div></div><br></div></div><br><div class=3D"gmail_quote"><div dir=3D"=
ltr" class=3D"gmail_attr">On Sun, Apr 14, 2019 at 10:29 AM Joseph Brenner &=
lt;<a href=3D"mailto:doomvox@gmail.com">doomvox@gmail.com</a>&gt; wrote:<br=
></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;=
border-left:1px solid rgb(204,204,204);padding-left:1ex">Richard Hainsworth=
 &lt;<a href=3D"mailto:rnhainsworth@gmail.com" target=3D"_blank">rnhainswor=
th@gmail.com</a>&gt; wrote:<br>
&gt; A semicolon is the syntax used for multidimensional arrays.<br>
&gt;<br>
&gt; See <a href=3D"https://docs.perl6.org/language/subscripts#Multiple_dim=
ensions" rel=3D"noreferrer" target=3D"_blank">https://docs.perl6.org/langua=
ge/subscripts#Multiple_dimensions</a><br>
<br>
Thanks.=C2=A0 I was trying to help Bill with that question, and I couldn&#3=
9;t<br>
quite see what was going on there.=C2=A0 =C2=A0You can&#39;t really do a we=
b search<br>
on &quot;&lt;computer language&gt;&quot; and &quot;;&quot;=C2=A0 and expect=
 to learn anything.<br>
<br>
And reading through that section on multidimensional arrays, it<br>
doesn&#39;t immediately leap out why Bill would be seeing this behavior.<br=
>
It&#39;s mostly a discussion of dereferencing complex data structures, not<=
br>
creating them.=C2=A0 =C2=A0Where it does create multiple levels it uses the=
<br>
comma.<br>
<br>
<br>
Richard Hainsworth &lt;<a href=3D"mailto:rnhainsworth@gmail.com" target=3D"=
_blank">rnhainsworth@gmail.com</a>&gt; wrote:<br>
&gt; A semicolon is the syntax used for multidimensional arrays.<br>
&gt;<br>
&gt; See <a href=3D"https://docs.perl6.org/language/subscripts#Multiple_dim=
ensions" rel=3D"noreferrer" target=3D"_blank">https://docs.perl6.org/langua=
ge/subscripts#Multiple_dimensions</a><br>
&gt;<br>
&gt;<br>
&gt; On 14/04/2019 15:07, William Michels via perl6-users wrote:<br>
&gt;&gt; Hello,<br>
&gt;&gt;<br>
&gt;&gt; I&#39;ve been working through Patrick Michaud&#39;s excellent vide=
os from the<br>
&gt;&gt; The Perl Conference 2016. At about 35:45 of the following 2016 vid=
eo<br>
&gt;&gt; (Part 1 of 2), Patrick discusses arrays:<br>
&gt;&gt;<br>
&gt;&gt; <a href=3D"https://www.youtube.com/watch?v=3DySch4xpoPA0" rel=3D"n=
oreferrer" target=3D"_blank">https://www.youtube.com/watch?v=3DySch4xpoPA0<=
/a><br>
&gt;&gt;<br>
&gt;&gt; At this point in the video, Patrick also discusses push() and pop(=
)<br>
&gt;&gt; calls on arrays. For practice I tried pushing and popping strings =
in<br>
&gt;&gt; the REPL. However, I discovered an unusual property when I misplac=
ed a<br>
&gt;&gt; semicolon during call to push(). See what happens below when a<br>
&gt;&gt; semicolon is included within the parentheses of push():<br>
&gt;&gt;<br>
&gt;&gt; &quot;This is Rakudo version 2018.12 built on MoarVM version 2018.=
12<br>
&gt;&gt; implementing Perl 6.d.&quot;<br>
&gt;&gt;<br>
&gt;&gt;&gt; my @countries =3D &quot;UK&quot;, &quot;Spain&quot;, &quot;Slo=
vakia&quot;, &quot;Sweden&quot;;<br>
&gt;&gt; [UK Spain Slovakia Sweden]<br>
&gt;&gt;&gt; @countries.push(&quot;Finland&quot;);<br>
&gt;&gt; [UK Spain Slovakia Sweden Finland]<br>
&gt;&gt;&gt; my @countries =3D &quot;UK&quot;, &quot;Spain&quot;, &quot;Slo=
vakia&quot;, &quot;Sweden&quot;;<br>
&gt;&gt; [UK Spain Slovakia Sweden]<br>
&gt;&gt;&gt; @countries.push(&quot;Finland&quot;;)<br>
&gt;&gt; [UK Spain Slovakia Sweden (Finland) ()]<br>
&gt;&gt;&gt; my @countries =3D &quot;UK&quot;, &quot;Spain&quot;, &quot;Slo=
vakia&quot;, &quot;Sweden&quot;;<br>
&gt;&gt; [UK Spain Slovakia Sweden]<br>
&gt;&gt;&gt; @countries.push(&quot;Finland&quot;;);<br>
&gt;&gt; [UK Spain Slovakia Sweden (Finland) ()]<br>
&gt;&gt;<br>
&gt;&gt; Misplacing a semicolon within the push() call adds two elements to=
 the<br>
&gt;&gt; array. When I examine these two elements, I see that they are both=
<br>
&gt;&gt; &quot;List&quot; elements:<br>
&gt;&gt;<br>
&gt;&gt;&gt; @countries[3].WHAT<br>
&gt;&gt; (Str)<br>
&gt;&gt;&gt; @countries[4].WHAT<br>
&gt;&gt; (List)<br>
&gt;&gt;&gt; @countries[5].WHAT<br>
&gt;&gt; (List)<br>
&gt;&gt;<br>
&gt;&gt; Apparently, multiple semicolons within push() will add multiple li=
st<br>
&gt;&gt; elements to the end of the intended array:<br>
&gt;&gt;<br>
&gt;&gt;&gt; my @countries =3D &quot;UK&quot;, &quot;Spain&quot;, &quot;Slo=
vakia&quot;, &quot;Sweden&quot;;<br>
&gt;&gt; [UK Spain Slovakia Sweden]<br>
&gt;&gt;&gt; @countries.push(&quot;Finland&quot;;;);<br>
&gt;&gt; [UK Spain Slovakia Sweden (Finland) () ()]<br>
&gt;&gt;&gt; my @countries =3D &quot;UK&quot;, &quot;Spain&quot;, &quot;Slo=
vakia&quot;, &quot;Sweden&quot;;<br>
&gt;&gt; [UK Spain Slovakia Sweden]<br>
&gt;&gt;&gt; @countries.push(;;;;;;;);<br>
&gt;&gt; [UK Spain Slovakia Sweden () () () () () () () ()]<br>
&gt;&gt;<br>
&gt;&gt; It is surprising to me that &quot;List&quot; elements are appended=
 to the array<br>
&gt;&gt; with push() as described above. If one tries to add one or more<br=
>
&gt;&gt; elements via indexing and there &#39;aren&#39;t enough elements&#3=
9; so to speak<br>
&gt;&gt; (by accident or design), the array grows by inserting &quot;Any&qu=
ot; elements,<br>
&gt;&gt; not &quot;List&quot; elements:<br>
&gt;&gt;<br>
&gt;&gt;&gt; my @countries =3D &quot;UK&quot;, &quot;Spain&quot;, &quot;Slo=
vakia&quot;, &quot;Sweden&quot;;<br>
&gt;&gt; [UK Spain Slovakia Sweden]<br>
&gt;&gt;&gt; @countries[5] =3D &quot;Finland&quot;;<br>
&gt;&gt; Finland<br>
&gt;&gt;&gt; say @countries<br>
&gt;&gt; [UK Spain Slovakia Sweden (Any) Finland]<br>
&gt;&gt;&gt; my @countries =3D &quot;UK&quot;, &quot;Spain&quot;, &quot;Slo=
vakia&quot;, &quot;Sweden&quot;;<br>
&gt;&gt; [UK Spain Slovakia Sweden]<br>
&gt;&gt;&gt; @countries[6..7] =3D &quot;Finland&quot;, &quot;Norway&quot;;<=
br>
&gt;&gt; (Finland Norway)<br>
&gt;&gt;&gt; say @countries<br>
&gt;&gt; [UK Spain Slovakia Sweden (Any) (Any) Finland Norway]<br>
&gt;&gt;<br>
&gt;&gt; I&#39;ve briefly checked pop() to see if there are similar issues,=
 but 1)<br>
&gt;&gt; placing a string within the parentheses of pop() will throw an err=
or,<br>
&gt;&gt; and 2) placing a semicolon within the parentheses of pop() will th=
row<br>
&gt;&gt; an error. However, these error message are slightly different. A<b=
r>
&gt;&gt; string argument to pop() will result in an error that says &quot;T=
oo many<br>
&gt;&gt; positionals passed; expected 1 argument but got 2&quot; while a se=
micolon<br>
&gt;&gt; argument to pop() will result in an error that says &quot;Too many=
<br>
&gt;&gt; positionals passed; expected 1 argument but got 3&quot;.<br>
&gt;&gt;<br>
&gt;&gt;&gt; my @countries =3D &quot;UK&quot;, &quot;Spain&quot;, &quot;Slo=
vakia&quot;, &quot;Sweden&quot;;<br>
&gt;&gt; [UK Spain Slovakia Sweden]<br>
&gt;&gt;&gt; @countries.pop(&quot;Finland&quot;)<br>
&gt;&gt; Too many positionals passed; expected 1 argument but got 2<br>
&gt;&gt;=C2=A0 =C2=A0 in block &lt;unit&gt; at &lt;unknown file&gt; line 1<=
br>
&gt;&gt;<br>
&gt;&gt;&gt; @countries.pop(;)<br>
&gt;&gt; Too many positionals passed; expected 1 argument but got 3<br>
&gt;&gt;=C2=A0 =C2=A0 in block &lt;unit&gt; at &lt;unknown file&gt; line 1<=
br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; Any help appreciated,<br>
&gt;&gt;<br>
&gt;&gt; Bill.<br>
&gt;&gt;<br>
&gt;&gt; William Michels, Ph.D.<br>
&gt;&gt;<br>
&gt;&gt; PS Thanks to Joe Brenner for talking over this Perl6 code with me.=
<br>
&gt;<br>
</blockquote></div>

--00000000000058a5cf058680feff--
0
not
4/14/2019 5:37:19 PM
Great, now I'm trouble finding semicolon examples in PDL, too.

(Bill: PDL is the "perl data language", a perl5 descendent of
stuff like Matlab, which you'd probably recognize as being a bit
like R.)

Larry Wall does discuss this stuff in the 9th Synopsis (one
of the original design documents, which may be out-of-date):

https://design.perl6.org/S09.html#The_semicolon_operator

People talk about it here, too:

https://grokbase.com/t/perl/perl6-language/05183ndht7/dimension-of-slices-scalars-versus-1-element-arrays


On 4/14/19, yary <not.com@gmail.com> wrote:
> I don't know much about PDL (the Perl Data Lanuage) but I do remember that
> the semicolon as a "higher-level" array separator in P6 is a nod to PDL. It
> is a bit of stub feature until someone needs it and specs out, prototypes
> more of that data-slicing style. It's likely under-documented due to that
> history.
>
> -y
>
>
> On Sun, Apr 14, 2019 at 10:29 AM Joseph Brenner <doomvox@gmail.com> wrote:
>
>> Richard Hainsworth <rnhainsworth@gmail.com> wrote:
>> > A semicolon is the syntax used for multidimensional arrays.
>> >
>> > See https://docs.perl6.org/language/subscripts#Multiple_dimensions
>>
>> Thanks.  I was trying to help Bill with that question, and I couldn't
>> quite see what was going on there.   You can't really do a web search
>> on "<computer language>" and ";"  and expect to learn anything.
>>
>> And reading through that section on multidimensional arrays, it
>> doesn't immediately leap out why Bill would be seeing this behavior.
>> It's mostly a discussion of dereferencing complex data structures, not
>> creating them.   Where it does create multiple levels it uses the
>> comma.
>>
>>
>> Richard Hainsworth <rnhainsworth@gmail.com> wrote:
>> > A semicolon is the syntax used for multidimensional arrays.
>> >
>> > See https://docs.perl6.org/language/subscripts#Multiple_dimensions
>> >
>> >
>> > On 14/04/2019 15:07, William Michels via perl6-users wrote:
>> >> Hello,
>> >>
>> >> I've been working through Patrick Michaud's excellent videos from the
>> >> The Perl Conference 2016. At about 35:45 of the following 2016 video
>> >> (Part 1 of 2), Patrick discusses arrays:
>> >>
>> >> https://www.youtube.com/watch?v=ySch4xpoPA0
>> >>
>> >> At this point in the video, Patrick also discusses push() and pop()
>> >> calls on arrays. For practice I tried pushing and popping strings in
>> >> the REPL. However, I discovered an unusual property when I misplaced a
>> >> semicolon during call to push(). See what happens below when a
>> >> semicolon is included within the parentheses of push():
>> >>
>> >> "This is Rakudo version 2018.12 built on MoarVM version 2018.12
>> >> implementing Perl 6.d."
>> >>
>> >>> my @countries = "UK", "Spain", "Slovakia", "Sweden";
>> >> [UK Spain Slovakia Sweden]
>> >>> @countries.push("Finland");
>> >> [UK Spain Slovakia Sweden Finland]
>> >>> my @countries = "UK", "Spain", "Slovakia", "Sweden";
>> >> [UK Spain Slovakia Sweden]
>> >>> @countries.push("Finland";)
>> >> [UK Spain Slovakia Sweden (Finland) ()]
>> >>> my @countries = "UK", "Spain", "Slovakia", "Sweden";
>> >> [UK Spain Slovakia Sweden]
>> >>> @countries.push("Finland";);
>> >> [UK Spain Slovakia Sweden (Finland) ()]
>> >>
>> >> Misplacing a semicolon within the push() call adds two elements to the
>> >> array. When I examine these two elements, I see that they are both
>> >> "List" elements:
>> >>
>> >>> @countries[3].WHAT
>> >> (Str)
>> >>> @countries[4].WHAT
>> >> (List)
>> >>> @countries[5].WHAT
>> >> (List)
>> >>
>> >> Apparently, multiple semicolons within push() will add multiple list
>> >> elements to the end of the intended array:
>> >>
>> >>> my @countries = "UK", "Spain", "Slovakia", "Sweden";
>> >> [UK Spain Slovakia Sweden]
>> >>> @countries.push("Finland";;);
>> >> [UK Spain Slovakia Sweden (Finland) () ()]
>> >>> my @countries = "UK", "Spain", "Slovakia", "Sweden";
>> >> [UK Spain Slovakia Sweden]
>> >>> @countries.push(;;;;;;;);
>> >> [UK Spain Slovakia Sweden () () () () () () () ()]
>> >>
>> >> It is surprising to me that "List" elements are appended to the array
>> >> with push() as described above. If one tries to add one or more
>> >> elements via indexing and there 'aren't enough elements' so to speak
>> >> (by accident or design), the array grows by inserting "Any" elements,
>> >> not "List" elements:
>> >>
>> >>> my @countries = "UK", "Spain", "Slovakia", "Sweden";
>> >> [UK Spain Slovakia Sweden]
>> >>> @countries[5] = "Finland";
>> >> Finland
>> >>> say @countries
>> >> [UK Spain Slovakia Sweden (Any) Finland]
>> >>> my @countries = "UK", "Spain", "Slovakia", "Sweden";
>> >> [UK Spain Slovakia Sweden]
>> >>> @countries[6..7] = "Finland", "Norway";
>> >> (Finland Norway)
>> >>> say @countries
>> >> [UK Spain Slovakia Sweden (Any) (Any) Finland Norway]
>> >>
>> >> I've briefly checked pop() to see if there are similar issues, but 1)
>> >> placing a string within the parentheses of pop() will throw an error,
>> >> and 2) placing a semicolon within the parentheses of pop() will throw
>> >> an error. However, these error message are slightly different. A
>> >> string argument to pop() will result in an error that says "Too many
>> >> positionals passed; expected 1 argument but got 2" while a semicolon
>> >> argument to pop() will result in an error that says "Too many
>> >> positionals passed; expected 1 argument but got 3".
>> >>
>> >>> my @countries = "UK", "Spain", "Slovakia", "Sweden";
>> >> [UK Spain Slovakia Sweden]
>> >>> @countries.pop("Finland")
>> >> Too many positionals passed; expected 1 argument but got 2
>> >>    in block <unit> at <unknown file> line 1
>> >>
>> >>> @countries.pop(;)
>> >> Too many positionals passed; expected 1 argument but got 3
>> >>    in block <unit> at <unknown file> line 1
>> >>
>> >>
>> >> Any help appreciated,
>> >>
>> >> Bill.
>> >>
>> >> William Michels, Ph.D.
>> >>
>> >> PS Thanks to Joe Brenner for talking over this Perl6 code with me.
>> >
>>
>
0
doomvox
4/14/2019 6:41:11 PM
Just in case it wasn't clear from Bill's discussion, I think the
reason this case seems weird is normally we expect trailing separators
to be ignored, as with the extra comma here:

   > my @monsters = ('ghidora', 'mothera', 'wolfman', 'zuckerberg',);
  [ghidora mothera wolfman zuckerberg]

If you do this, and type in a trailing semi-colon in the wrong place,
you stumble across some odd behavior:

   > @monsters.push('tingler';)
  [ghidora mothera wolfman zuckerberg (tingler) ()]

It seems a bit LTA, though it might be unavoidable because this is valid:

   my @monsters = ('ghidora', 'mothera'; 'frankenstein',
'wolfman';'purple-people-eater')
   [(ghidora mothera) (frankenstein wolfman) purple-people-eater]

Though even here, the behavior seems a bit strange, because
"purple-people-eater" ended up as an element in the top-level list.
Hm, no empty list is appended if you do this:

  my @monsters = ('ghidora', 'mothera'; 'frankenstein', 'wolfman';)
  [(ghidora mothera) (frankenstein wolfman)]

But the push method seems to interpret it differently:

  @monsters.push('purple-people-eater';)
  [(ghidora mothera) (frankenstein wolfman) (purple-people-eater) ()]



On 4/14/19, William Michels via perl6-users <perl6-users@perl.org> wrote:
> Hello,
>
> I've been working through Patrick Michaud's excellent videos from the
> The Perl Conference 2016. At about 35:45 of the following 2016 video
> (Part 1 of 2), Patrick discusses arrays:
>
> https://www.youtube.com/watch?v=ySch4xpoPA0
>
> At this point in the video, Patrick also discusses push() and pop()
> calls on arrays. For practice I tried pushing and popping strings in
> the REPL. However, I discovered an unusual property when I misplaced a
> semicolon during call to push(). See what happens below when a
> semicolon is included within the parentheses of push():
>
> "This is Rakudo version 2018.12 built on MoarVM version 2018.12
> implementing Perl 6.d."
>
>> my @countries = "UK", "Spain", "Slovakia", "Sweden";
> [UK Spain Slovakia Sweden]
>> @countries.push("Finland");
> [UK Spain Slovakia Sweden Finland]
>> my @countries = "UK", "Spain", "Slovakia", "Sweden";
> [UK Spain Slovakia Sweden]
>> @countries.push("Finland";)
> [UK Spain Slovakia Sweden (Finland) ()]
>> my @countries = "UK", "Spain", "Slovakia", "Sweden";
> [UK Spain Slovakia Sweden]
>> @countries.push("Finland";);
> [UK Spain Slovakia Sweden (Finland) ()]
>
> Misplacing a semicolon within the push() call adds two elements to the
> array. When I examine these two elements, I see that they are both
> "List" elements:
>
>> @countries[3].WHAT
> (Str)
>> @countries[4].WHAT
> (List)
>> @countries[5].WHAT
> (List)
>
> Apparently, multiple semicolons within push() will add multiple list
> elements to the end of the intended array:
>
>> my @countries = "UK", "Spain", "Slovakia", "Sweden";
> [UK Spain Slovakia Sweden]
>> @countries.push("Finland";;);
> [UK Spain Slovakia Sweden (Finland) () ()]
>> my @countries = "UK", "Spain", "Slovakia", "Sweden";
> [UK Spain Slovakia Sweden]
>> @countries.push(;;;;;;;);
> [UK Spain Slovakia Sweden () () () () () () () ()]
>
> It is surprising to me that "List" elements are appended to the array
> with push() as described above. If one tries to add one or more
> elements via indexing and there 'aren't enough elements' so to speak
> (by accident or design), the array grows by inserting "Any" elements,
> not "List" elements:
>
>> my @countries = "UK", "Spain", "Slovakia", "Sweden";
> [UK Spain Slovakia Sweden]
>> @countries[5] = "Finland";
> Finland
>> say @countries
> [UK Spain Slovakia Sweden (Any) Finland]
>>
>> my @countries = "UK", "Spain", "Slovakia", "Sweden";
> [UK Spain Slovakia Sweden]
>> @countries[6..7] = "Finland", "Norway";
> (Finland Norway)
>> say @countries
> [UK Spain Slovakia Sweden (Any) (Any) Finland Norway]
>
> I've briefly checked pop() to see if there are similar issues, but 1)
> placing a string within the parentheses of pop() will throw an error,
> and 2) placing a semicolon within the parentheses of pop() will throw
> an error. However, these error message are slightly different. A
> string argument to pop() will result in an error that says "Too many
> positionals passed; expected 1 argument but got 2" while a semicolon
> argument to pop() will result in an error that says "Too many
> positionals passed; expected 1 argument but got 3".
>
>> my @countries = "UK", "Spain", "Slovakia", "Sweden";
> [UK Spain Slovakia Sweden]
>> @countries.pop("Finland")
> Too many positionals passed; expected 1 argument but got 2
>   in block <unit> at <unknown file> line 1
>
>> @countries.pop(;)
> Too many positionals passed; expected 1 argument but got 3
>   in block <unit> at <unknown file> line 1
>
>>
>
>
> Any help appreciated,
>
> Bill.
>
> William Michels, Ph.D.
>
> PS Thanks to Joe Brenner for talking over this Perl6 code with me.
>
0
doomvox
4/14/2019 6:57:13 PM
--0000000000007fa2580586835bd7
Content-Type: text/plain; charset="UTF-8"

Looks like perl6 semicolon has different meaning in a list vs a capture. In
a list, it "makes sense to me"

> perl6 --version
This is Rakudo Star version 2018.10 built on MoarVM version 2018.10
implementing Perl 6.c.
>perl6
To exit type 'exit' or '^D'
> ('a').perl
"a"
> ('a';).perl
"a"
> ('a', 'b' ;).perl
("a", "b")
> ('a', 'b' ; 'c').perl
(("a", "b"), "c")
> ('a', 'b' ; 'c' ;).perl
(("a", "b"), "c")
> ('a', 'b' ; 'c' ; ;).perl
(("a", "b"), "c", Nil)
> ('a', 'b' ; 'c' , ; ;).perl
(("a", "b"), ("c",), Nil)

- the rule "a single thing is a scalar, a single thing followed by a comma
is a list" applies in the last example

But there's inconsistency with captures.

>\('a').perl
\("a")
> \('a';).perl; # Unexpected empty list at end
\(("a",), ())
> \('a', 'b' ;).perl; # Unexpected empty list at end
\(("A", "b"), ())
> \('a', 'b' ; 'c').perl; # unexpected "c" as list
\(("a", "b"), ("c",))
> \('a', 'b' ; 'c' ;).perl; # "c" as list, and empty list at end
\(("a", "b"), ("c",), ())
> \('a', 'b' ; 'c' ; ;).perl; # "c" as list, and 2 empty lists instead of
single nil at end
\(("a", "b"), ("c",), (), ())
> \('a', 'b' ; 'c' , ; ;).perl; # 2 empty lists instead of single nil at end
\(("a", "b"), ("c",), (), ())

This cries for an explanation, or a bug report.

-y


On Sun, Apr 14, 2019 at 11:57 AM Joseph Brenner <doomvox@gmail.com> wrote:

> Just in case it wasn't clear from Bill's discussion, I think the
> reason this case seems weird is normally we expect trailing separators
> to be ignored, as with the extra comma here:
>
>    > my @monsters = ('ghidora', 'mothera', 'wolfman', 'zuckerberg',);
>   [ghidora mothera wolfman zuckerberg]
>
> If you do this, and type in a trailing semi-colon in the wrong place,
> you stumble across some odd behavior:
>
>    > @monsters.push('tingler';)
>   [ghidora mothera wolfman zuckerberg (tingler) ()]
>
> It seems a bit LTA, though it might be unavoidable because this is valid:
>
>    my @monsters = ('ghidora', 'mothera'; 'frankenstein',
> 'wolfman';'purple-people-eater')
>    [(ghidora mothera) (frankenstein wolfman) purple-people-eater]
>
> Though even here, the behavior seems a bit strange, because
> "purple-people-eater" ended up as an element in the top-level list.
> Hm, no empty list is appended if you do this:
>
>   my @monsters = ('ghidora', 'mothera'; 'frankenstein', 'wolfman';)
>   [(ghidora mothera) (frankenstein wolfman)]
>
> But the push method seems to interpret it differently:
>
>   @monsters.push('purple-people-eater';)
>   [(ghidora mothera) (frankenstein wolfman) (purple-people-eater) ()]
>
>
>
> On 4/14/19, William Michels via perl6-users <perl6-users@perl.org> wrote:
> > Hello,
> >
> > I've been working through Patrick Michaud's excellent videos from the
> > The Perl Conference 2016. At about 35:45 of the following 2016 video
> > (Part 1 of 2), Patrick discusses arrays:
> >
> > https://www.youtube.com/watch?v=ySch4xpoPA0
> >
> > At this point in the video, Patrick also discusses push() and pop()
> > calls on arrays. For practice I tried pushing and popping strings in
> > the REPL. However, I discovered an unusual property when I misplaced a
> > semicolon during call to push(). See what happens below when a
> > semicolon is included within the parentheses of push():
> >
> > "This is Rakudo version 2018.12 built on MoarVM version 2018.12
> > implementing Perl 6.d."
> >
> >> my @countries = "UK", "Spain", "Slovakia", "Sweden";
> > [UK Spain Slovakia Sweden]
> >> @countries.push("Finland");
> > [UK Spain Slovakia Sweden Finland]
> >> my @countries = "UK", "Spain", "Slovakia", "Sweden";
> > [UK Spain Slovakia Sweden]
> >> @countries.push("Finland";)
> > [UK Spain Slovakia Sweden (Finland) ()]
> >> my @countries = "UK", "Spain", "Slovakia", "Sweden";
> > [UK Spain Slovakia Sweden]
> >> @countries.push("Finland";);
> > [UK Spain Slovakia Sweden (Finland) ()]
> >
> > Misplacing a semicolon within the push() call adds two elements to the
> > array. When I examine these two elements, I see that they are both
> > "List" elements:
> >
> >> @countries[3].WHAT
> > (Str)
> >> @countries[4].WHAT
> > (List)
> >> @countries[5].WHAT
> > (List)
> >
> > Apparently, multiple semicolons within push() will add multiple list
> > elements to the end of the intended array:
> >
> >> my @countries = "UK", "Spain", "Slovakia", "Sweden";
> > [UK Spain Slovakia Sweden]
> >> @countries.push("Finland";;);
> > [UK Spain Slovakia Sweden (Finland) () ()]
> >> my @countries = "UK", "Spain", "Slovakia", "Sweden";
> > [UK Spain Slovakia Sweden]
> >> @countries.push(;;;;;;;);
> > [UK Spain Slovakia Sweden () () () () () () () ()]
> >
> > It is surprising to me that "List" elements are appended to the array
> > with push() as described above. If one tries to add one or more
> > elements via indexing and there 'aren't enough elements' so to speak
> > (by accident or design), the array grows by inserting "Any" elements,
> > not "List" elements:
> >
> >> my @countries = "UK", "Spain", "Slovakia", "Sweden";
> > [UK Spain Slovakia Sweden]
> >> @countries[5] = "Finland";
> > Finland
> >> say @countries
> > [UK Spain Slovakia Sweden (Any) Finland]
> >>
> >> my @countries = "UK", "Spain", "Slovakia", "Sweden";
> > [UK Spain Slovakia Sweden]
> >> @countries[6..7] = "Finland", "Norway";
> > (Finland Norway)
> >> say @countries
> > [UK Spain Slovakia Sweden (Any) (Any) Finland Norway]
> >
> > I've briefly checked pop() to see if there are similar issues, but 1)
> > placing a string within the parentheses of pop() will throw an error,
> > and 2) placing a semicolon within the parentheses of pop() will throw
> > an error. However, these error message are slightly different. A
> > string argument to pop() will result in an error that says "Too many
> > positionals passed; expected 1 argument but got 2" while a semicolon
> > argument to pop() will result in an error that says "Too many
> > positionals passed; expected 1 argument but got 3".
> >
> >> my @countries = "UK", "Spain", "Slovakia", "Sweden";
> > [UK Spain Slovakia Sweden]
> >> @countries.pop("Finland")
> > Too many positionals passed; expected 1 argument but got 2
> >   in block <unit> at <unknown file> line 1
> >
> >> @countries.pop(;)
> > Too many positionals passed; expected 1 argument but got 3
> >   in block <unit> at <unknown file> line 1
> >
> >>
> >
> >
> > Any help appreciated,
> >
> > Bill.
> >
> > William Michels, Ph.D.
> >
> > PS Thanks to Joe Brenner for talking over this Perl6 code with me.
> >
>

--0000000000007fa2580586835bd7
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr"><div di=
r=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"lt=
r"><div dir=3D"ltr">Looks like perl6 semicolon has different meaning in a l=
ist vs a capture. In a list, it &quot;makes sense to me&quot;<div><br><div>=
<div>&gt; perl6 --version</div><div>This is Rakudo Star version 2018.10 bui=
lt on MoarVM version 2018.10</div><div>implementing Perl 6.c.</div></div><d=
iv><div>&gt;perl6</div><div>To exit type &#39;exit&#39; or &#39;^D&#39;</di=
v><div>&gt; (&#39;a&#39;).perl</div><div>&quot;a&quot;</div><div>&gt; (&#39=
;a&#39;;).perl</div><div>&quot;a&quot;</div><div>&gt; (&#39;a&#39;, &#39;b&=
#39; ;).perl</div><div>(&quot;a&quot;, &quot;b&quot;)</div><div>&gt; (&#39;=
a&#39;, &#39;b&#39; ; &#39;c&#39;).perl</div><div>((&quot;a&quot;, &quot;b&=
quot;), &quot;c&quot;)</div><div>&gt; (&#39;a&#39;, &#39;b&#39; ; &#39;c&#3=
9; ;).perl</div><div>((&quot;a&quot;, &quot;b&quot;), &quot;c&quot;)</div><=
div>&gt; (&#39;a&#39;, &#39;b&#39; ; &#39;c&#39; ; ;).perl</div><div>((&quo=
t;a&quot;, &quot;b&quot;), &quot;c&quot;, Nil)</div></div><div><div>&gt; (&=
#39;a&#39;, &#39;b&#39; ; &#39;c&#39; , ; ;).perl</div><div>((&quot;a&quot;=
, &quot;b&quot;), (&quot;c&quot;,), Nil)</div></div><div><br></div><div>- t=
he rule &quot;a single thing is a scalar, a single thing followed by a comm=
a is a list&quot; applies in the last example</div><div><br></div><div>But =
there&#39;s inconsistency with captures.</div><div><br></div><div><div><div=
>&gt;\(&#39;a&#39;).perl</div><div>\(&quot;a&quot;)</div><div>&gt; \(&#39;a=
&#39;;).perl; # Unexpected empty list at end</div><div>\((&quot;a&quot;,), =
())</div><div>&gt; \(&#39;a&#39;, &#39;b&#39; ;).perl; # Unexpected empty l=
ist at end</div><div>\((&quot;A&quot;, &quot;b&quot;), ())</div><div>&gt; \=
(&#39;a&#39;, &#39;b&#39; ; &#39;c&#39;).perl; # unexpected &quot;c&quot; a=
s list</div><div>\((&quot;a&quot;, &quot;b&quot;), (&quot;c&quot;,))</div><=
div>&gt; \(&#39;a&#39;, &#39;b&#39; ; &#39;c&#39; ;).perl; # &quot;c&quot; =
as list, and empty list at end</div><div>\((&quot;a&quot;, &quot;b&quot;), =
(&quot;c&quot;,), ())</div><div>&gt; \(&#39;a&#39;, &#39;b&#39; ; &#39;c&#3=
9; ; ;).perl; # &quot;c&quot; as list, and 2 empty lists instead of single =
nil at end</div><div>\((&quot;a&quot;, &quot;b&quot;), (&quot;c&quot;,), ()=
, ())</div><div>&gt; \(&#39;a&#39;, &#39;b&#39; ; &#39;c&#39; , ; ;).perl; =
# 2 empty lists instead of single nil at end</div><div>\((&quot;a&quot;, &q=
uot;b&quot;), (&quot;c&quot;,), (), ())</div><br>This cries for an explanat=
ion, or a bug report.</div></div><div><br></div><div><div><div dir=3D"ltr" =
class=3D"gmail_signature">-y<br></div></div><br></div></div></div></div></d=
iv></div></div></div></div></div><br><div class=3D"gmail_quote"><div dir=3D=
"ltr" class=3D"gmail_attr">On Sun, Apr 14, 2019 at 11:57 AM Joseph Brenner =
&lt;<a href=3D"mailto:doomvox@gmail.com">doomvox@gmail.com</a>&gt; wrote:<b=
r></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex=
;border-left:1px solid rgb(204,204,204);padding-left:1ex">Just in case it w=
asn&#39;t clear from Bill&#39;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>
=C2=A0 =C2=A0&gt; my @monsters =3D (&#39;ghidora&#39;, &#39;mothera&#39;, &=
#39;wolfman&#39;, &#39;zuckerberg&#39;,);<br>
=C2=A0 [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>
=C2=A0 =C2=A0&gt; @monsters.push(&#39;tingler&#39;;)<br>
=C2=A0 [ghidora mothera wolfman zuckerberg (tingler) ()]<br>
<br>
It seems a bit LTA, though it might be unavoidable because this is valid:<b=
r>
<br>
=C2=A0 =C2=A0my @monsters =3D (&#39;ghidora&#39;, &#39;mothera&#39;; &#39;f=
rankenstein&#39;,<br>
&#39;wolfman&#39;;&#39;purple-people-eater&#39;)<br>
=C2=A0 =C2=A0[(ghidora mothera) (frankenstein wolfman) purple-people-eater]=
<br>
<br>
Though even here, the behavior seems a bit strange, because<br>
&quot;purple-people-eater&quot; ended up as an element in the top-level lis=
t.<br>
Hm, no empty list is appended if you do this:<br>
<br>
=C2=A0 my @monsters =3D (&#39;ghidora&#39;, &#39;mothera&#39;; &#39;franken=
stein&#39;, &#39;wolfman&#39;;)<br>
=C2=A0 [(ghidora mothera) (frankenstein wolfman)]<br>
<br>
But the push method seems to interpret it differently:<br>
<br>
=C2=A0 @monsters.push(&#39;purple-people-eater&#39;;)<br>
=C2=A0 [(ghidora mothera) (frankenstein wolfman) (purple-people-eater) ()]<=
br>
<br>
<br>
<br>
On 4/14/19, William Michels via perl6-users &lt;<a href=3D"mailto:perl6-use=
rs@perl.org" target=3D"_blank">perl6-users@perl.org</a>&gt; wrote:<br>
&gt; Hello,<br>
&gt;<br>
&gt; I&#39;ve been working through Patrick Michaud&#39;s excellent videos f=
rom the<br>
&gt; The Perl Conference 2016. At about 35:45 of the following 2016 video<b=
r>
&gt; (Part 1 of 2), Patrick discusses arrays:<br>
&gt;<br>
&gt; <a href=3D"https://www.youtube.com/watch?v=3DySch4xpoPA0" rel=3D"noref=
errer" target=3D"_blank">https://www.youtube.com/watch?v=3DySch4xpoPA0</a><=
br>
&gt;<br>
&gt; At this point in the video, Patrick also discusses push() and pop()<br=
>
&gt; calls on arrays. For practice I tried pushing and popping strings in<b=
r>
&gt; the REPL. However, I discovered an unusual property when I misplaced a=
<br>
&gt; semicolon during call to push(). See what happens below when a<br>
&gt; semicolon is included within the parentheses of push():<br>
&gt;<br>
&gt; &quot;This is Rakudo version 2018.12 built on MoarVM version 2018.12<b=
r>
&gt; implementing Perl 6.d.&quot;<br>
&gt;<br>
&gt;&gt; my @countries =3D &quot;UK&quot;, &quot;Spain&quot;, &quot;Slovaki=
a&quot;, &quot;Sweden&quot;;<br>
&gt; [UK Spain Slovakia Sweden]<br>
&gt;&gt; @countries.push(&quot;Finland&quot;);<br>
&gt; [UK Spain Slovakia Sweden Finland]<br>
&gt;&gt; my @countries =3D &quot;UK&quot;, &quot;Spain&quot;, &quot;Slovaki=
a&quot;, &quot;Sweden&quot;;<br>
&gt; [UK Spain Slovakia Sweden]<br>
&gt;&gt; @countries.push(&quot;Finland&quot;;)<br>
&gt; [UK Spain Slovakia Sweden (Finland) ()]<br>
&gt;&gt; my @countries =3D &quot;UK&quot;, &quot;Spain&quot;, &quot;Slovaki=
a&quot;, &quot;Sweden&quot;;<br>
&gt; [UK Spain Slovakia Sweden]<br>
&gt;&gt; @countries.push(&quot;Finland&quot;;);<br>
&gt; [UK Spain Slovakia Sweden (Finland) ()]<br>
&gt;<br>
&gt; Misplacing a semicolon within the push() call adds two elements to the=
<br>
&gt; array. When I examine these two elements, I see that they are both<br>
&gt; &quot;List&quot; elements:<br>
&gt;<br>
&gt;&gt; @countries[3].WHAT<br>
&gt; (Str)<br>
&gt;&gt; @countries[4].WHAT<br>
&gt; (List)<br>
&gt;&gt; @countries[5].WHAT<br>
&gt; (List)<br>
&gt;<br>
&gt; Apparently, multiple semicolons within push() will add multiple list<b=
r>
&gt; elements to the end of the intended array:<br>
&gt;<br>
&gt;&gt; my @countries =3D &quot;UK&quot;, &quot;Spain&quot;, &quot;Slovaki=
a&quot;, &quot;Sweden&quot;;<br>
&gt; [UK Spain Slovakia Sweden]<br>
&gt;&gt; @countries.push(&quot;Finland&quot;;;);<br>
&gt; [UK Spain Slovakia Sweden (Finland) () ()]<br>
&gt;&gt; my @countries =3D &quot;UK&quot;, &quot;Spain&quot;, &quot;Slovaki=
a&quot;, &quot;Sweden&quot;;<br>
&gt; [UK Spain Slovakia Sweden]<br>
&gt;&gt; @countries.push(;;;;;;;);<br>
&gt; [UK Spain Slovakia Sweden () () () () () () () ()]<br>
&gt;<br>
&gt; It is surprising to me that &quot;List&quot; elements are appended to =
the array<br>
&gt; with push() as described above. If one tries to add one or more<br>
&gt; elements via indexing and there &#39;aren&#39;t enough elements&#39; s=
o to speak<br>
&gt; (by accident or design), the array grows by inserting &quot;Any&quot; =
elements,<br>
&gt; not &quot;List&quot; elements:<br>
&gt;<br>
&gt;&gt; my @countries =3D &quot;UK&quot;, &quot;Spain&quot;, &quot;Slovaki=
a&quot;, &quot;Sweden&quot;;<br>
&gt; [UK Spain Slovakia Sweden]<br>
&gt;&gt; @countries[5] =3D &quot;Finland&quot;;<br>
&gt; Finland<br>
&gt;&gt; say @countries<br>
&gt; [UK Spain Slovakia Sweden (Any) Finland]<br>
&gt;&gt;<br>
&gt;&gt; my @countries =3D &quot;UK&quot;, &quot;Spain&quot;, &quot;Slovaki=
a&quot;, &quot;Sweden&quot;;<br>
&gt; [UK Spain Slovakia Sweden]<br>
&gt;&gt; @countries[6..7] =3D &quot;Finland&quot;, &quot;Norway&quot;;<br>
&gt; (Finland Norway)<br>
&gt;&gt; say @countries<br>
&gt; [UK Spain Slovakia Sweden (Any) (Any) Finland Norway]<br>
&gt;<br>
&gt; I&#39;ve briefly checked pop() to see if there are similar issues, but=
 1)<br>
&gt; placing a string within the parentheses of pop() will throw an error,<=
br>
&gt; and 2) placing a semicolon within the parentheses of pop() will throw<=
br>
&gt; an error. However, these error message are slightly different. A<br>
&gt; string argument to pop() will result in an error that says &quot;Too m=
any<br>
&gt; positionals passed; expected 1 argument but got 2&quot; while a semico=
lon<br>
&gt; argument to pop() will result in an error that says &quot;Too many<br>
&gt; positionals passed; expected 1 argument but got 3&quot;.<br>
&gt;<br>
&gt;&gt; my @countries =3D &quot;UK&quot;, &quot;Spain&quot;, &quot;Slovaki=
a&quot;, &quot;Sweden&quot;;<br>
&gt; [UK Spain Slovakia Sweden]<br>
&gt;&gt; @countries.pop(&quot;Finland&quot;)<br>
&gt; Too many positionals passed; expected 1 argument but got 2<br>
&gt;=C2=A0 =C2=A0in block &lt;unit&gt; at &lt;unknown file&gt; line 1<br>
&gt;<br>
&gt;&gt; @countries.pop(;)<br>
&gt; Too many positionals passed; expected 1 argument but got 3<br>
&gt;=C2=A0 =C2=A0in block &lt;unit&gt; at &lt;unknown file&gt; line 1<br>
&gt;<br>
&gt;&gt;<br>
&gt;<br>
&gt;<br>
&gt; Any help appreciated,<br>
&gt;<br>
&gt; Bill.<br>
&gt;<br>
&gt; William Michels, Ph.D.<br>
&gt;<br>
&gt; PS Thanks to Joe Brenner for talking over this Perl6 code with me.<br>
&gt;<br>
</blockquote></div></div></div>

--0000000000007fa2580586835bd7--
0
not
4/14/2019 8:26:31 PM
Thank you, yary.

I'm not that familiar with PDL data structures, although they look
interesting. Arrays in R are pretty straight-forward.

https://cran.r-project.org/doc/manuals/r-release/R-intro.html#Arrays-and-ma=
trices



On Sun, Apr 14, 2019 at 10:37 AM yary <not.com@gmail.com> wrote:
>
> I don't know much about PDL (the Perl Data Lanuage) but I do remember tha=
t the semicolon as a "higher-level" array separator in P6 is a nod to PDL. =
It is a bit of stub feature until someone needs it and specs out, prototype=
s more of that data-slicing style. It's likely under-documented due to that=
 history.
>
> -y
>
>
> On Sun, Apr 14, 2019 at 10:29 AM Joseph Brenner <doomvox@gmail.com> wrote=
:
>>
>> Richard Hainsworth <rnhainsworth@gmail.com> wrote:
>> > A semicolon is the syntax used for multidimensional arrays.
>> >
>> > See https://docs.perl6.org/language/subscripts#Multiple_dimensions
>>
>> Thanks.  I was trying to help Bill with that question, and I couldn't
>> quite see what was going on there.   You can't really do a web search
>> on "<computer language>" and ";"  and expect to learn anything.
>>
>> And reading through that section on multidimensional arrays, it
>> doesn't immediately leap out why Bill would be seeing this behavior.
>> It's mostly a discussion of dereferencing complex data structures, not
>> creating them.   Where it does create multiple levels it uses the
>> comma.
>>
>>
>> Richard Hainsworth <rnhainsworth@gmail.com> wrote:
>> > A semicolon is the syntax used for multidimensional arrays.
>> >
>> > See https://docs.perl6.org/language/subscripts#Multiple_dimensions
>> >
>> >
>> > On 14/04/2019 15:07, William Michels via perl6-users wrote:
>> >> Hello,
>> >>
>> >> I've been working through Patrick Michaud's excellent videos from the
>> >> The Perl Conference 2016. At about 35:45 of the following 2016 video
>> >> (Part 1 of 2), Patrick discusses arrays:
>> >>
>> >> https://www[dot]youtub[dot]com/watch?v=3DySch4xpoPA0
>> >>
>> >> At this point in the video, Patrick also discusses push() and pop()
>> >> calls on arrays. For practice I tried pushing and popping strings in
>> >> the REPL. However, I discovered an unusual property when I misplaced =
a
>> >> semicolon during call to push(). See what happens below when a
>> >> semicolon is included within the parentheses of push():
>> >>
>> >> "This is Rakudo version 2018.12 built on MoarVM version 2018.12
>> >> implementing Perl 6.d."
>> >>
>> >>> my @countries =3D "UK", "Spain", "Slovakia", "Sweden";
>> >> [UK Spain Slovakia Sweden]
>> >>> @countries.push("Finland");
>> >> [UK Spain Slovakia Sweden Finland]
>> >>> my @countries =3D "UK", "Spain", "Slovakia", "Sweden";
>> >> [UK Spain Slovakia Sweden]
>> >>> @countries.push("Finland";)
>> >> [UK Spain Slovakia Sweden (Finland) ()]
>> >>> my @countries =3D "UK", "Spain", "Slovakia", "Sweden";
>> >> [UK Spain Slovakia Sweden]
>> >>> @countries.push("Finland";);
>> >> [UK Spain Slovakia Sweden (Finland) ()]
>> >>
>> >> Misplacing a semicolon within the push() call adds two elements to th=
e
>> >> array. When I examine these two elements, I see that they are both
>> >> "List" elements:
>> >>
>> >>> @countries[3].WHAT
>> >> (Str)
>> >>> @countries[4].WHAT
>> >> (List)
>> >>> @countries[5].WHAT
>> >> (List)
>> >>
>> >> Apparently, multiple semicolons within push() will add multiple list
>> >> elements to the end of the intended array:
>> >>
>> >>> my @countries =3D "UK", "Spain", "Slovakia", "Sweden";
>> >> [UK Spain Slovakia Sweden]
>> >>> @countries.push("Finland";;);
>> >> [UK Spain Slovakia Sweden (Finland) () ()]
>> >>> my @countries =3D "UK", "Spain", "Slovakia", "Sweden";
>> >> [UK Spain Slovakia Sweden]
>> >>> @countries.push(;;;;;;;);
>> >> [UK Spain Slovakia Sweden () () () () () () () ()]
>> >>
>> >> It is surprising to me that "List" elements are appended to the array
>> >> with push() as described above. If one tries to add one or more
>> >> elements via indexing and there 'aren't enough elements' so to speak
>> >> (by accident or design), the array grows by inserting "Any" elements,
>> >> not "List" elements:
>> >>
>> >>> my @countries =3D "UK", "Spain", "Slovakia", "Sweden";
>> >> [UK Spain Slovakia Sweden]
>> >>> @countries[5] =3D "Finland";
>> >> Finland
>> >>> say @countries
>> >> [UK Spain Slovakia Sweden (Any) Finland]
>> >>> my @countries =3D "UK", "Spain", "Slovakia", "Sweden";
>> >> [UK Spain Slovakia Sweden]
>> >>> @countries[6..7] =3D "Finland", "Norway";
>> >> (Finland Norway)
>> >>> say @countries
>> >> [UK Spain Slovakia Sweden (Any) (Any) Finland Norway]
>> >>
>> >> I've briefly checked pop() to see if there are similar issues, but 1)
>> >> placing a string within the parentheses of pop() will throw an error,
>> >> and 2) placing a semicolon within the parentheses of pop() will throw
>> >> an error. However, these error message are slightly different. A
>> >> string argument to pop() will result in an error that says "Too many
>> >> positionals passed; expected 1 argument but got 2" while a semicolon
>> >> argument to pop() will result in an error that says "Too many
>> >> positionals passed; expected 1 argument but got 3".
>> >>
>> >>> my @countries =3D "UK", "Spain", "Slovakia", "Sweden";
>> >> [UK Spain Slovakia Sweden]
>> >>> @countries.pop("Finland")
>> >> Too many positionals passed; expected 1 argument but got 2
>> >>    in block <unit> at <unknown file> line 1
>> >>
>> >>> @countries.pop(;)
>> >> Too many positionals passed; expected 1 argument but got 3
>> >>    in block <unit> at <unknown file> line 1
>> >>
>> >>
>> >> Any help appreciated,
>> >>
>> >> Bill.
>> >>
>> >> William Michels, Ph.D.
>> >>
>> >> PS Thanks to Joe Brenner for talking over this Perl6 code with me.
>> >
0
perl6
4/16/2019 8:56:23 PM
Reply: