You know how in perl 5, if you do:

   my @a = qw(a b c);
   my @b = (1, @a, 2);

@b will be (1, 'a', 'b', 'c', 2)? That's flattening. $b[1] will be 'a'.
Perl 5 doesn't really understand nested data structures, so you have to
simulate them with refs. If you use [@a] instead, $b[1] will contain an
arrayref that must be dereferenced to get at its contents. (Which it tries
to hide from you by letting you say $b[1][0] instead of $b[1]->[0], which
is what it's really doing. But if you say 'my $c = $b[1]', you need $c->[0]
to get its first item, not $c[0]. Refs are better than what we had to do in
Perl 4 with globs, but they're still kinda icky.)

Perl 6 understands nested lists and other data structures, and doesn't
flatten. If you do the above in Perl 6, you get (1, ('a', 'b', 'c'), 2)
with a nested list. @b[1] is ('a', 'b', 'c') and @b[1][0] is 'a', and
there's no hidden dereference operator involved, nor a "magic" arrayref to
be dereferenced.

On Fri, Oct 5, 2018 at 7:44 PM ToddAndMargo via perl6-users <
perl6-us...@perl.org> wrote:

> On 10/5/18 3:15 PM, Ralph Mellor wrote:
> > Well I guess my first way of explaining it was a complete bust. :)
> >
> > It's not going to be worth me discussing your reply to my first attempt.
>
> Hi Ralph,
>
> Thank you!  I am going to have to save it for later and read it
> over REAL SLOW!
>
> :-)
>
> -T
>


-- 
brandon s allbery kf8nh
allber...@gmail.com

Reply via email to