On 06/24/2016 12:01 AM, Greg London wrote:
Can't seem to wrap my head around perl6 lists.
i can stick my nose in here but don't quote me on it!
They're not arrays. They seem to exist almost as literals.
When I assign a list to an array, it stops acting like a literal list.
the big diff that i get is that arrays don't flatten automatically in
lists. that is different than autodereference which was tried in perl5
and now is dropped as it is too ambiguous.
THis does not work as expected:
my $otherlist = (11,22,33,44);
for $otherlist {say "here is $^first";}
here is 11 22 33 44;
that is looping over a single scalar. no implied dereferencing is happening.
Calling "flat" on the scalar doesn't change the output.
The only thing that seems to get it to do the right thing is to put "@" in
front of the scalar containing the list.
flat won't dereference. this is what i think flat does (pardon the syntax):
@bar = (3, 4)
@foo = (1, 2, @bar );
@foo has 3 elements. that effectively takes a reference to @bar as the
3rd element in foo. i won't guess how say prints that.
for @$otherlist {say "here is $^first";}
you explicitly dereferenced it so it is a common list now.
you seem to be confusing dereferencing from flattening. flattening needs
be done explicitly in perl6 whereas in perl5 it always happened. perl6
seems to take references to aggregates in lists instead of flattening.
and congrats on winning the apple watch from grant street at yapc^Wthe
perl conference. i was there when they picked your name but we couldn't
find you. seems you left unexpectedly but i heard they were shipping it
to you.
thanx,
uri
_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm