> It's an Array inside a Scalar.

This is really disturbing from a newcommer perspective. I don't know
much about the Perl6 internals so maybe i can explain it better (or
someone can fix me):

Let's try: 

Everything is an object in Perl6, which comes with roles and
inheritances and [Sigils](http://doc.perl6.org/language/variables#Sigils)
are just shortcuts to the default behaviors of the object.

the table must be read this way:

Type constraint :
   the variable *must* be from this class or having this role
Default type
   the default behavior of the object will be provided by this class or
   role
Flattens
    the object will flatten or not in a "list context" ? i haven't see
    such a notion in the doc.
Assignment
    while assigning the object, the rhs of '=' can be ...

so when you write 

my $z = ['a', 'b', 'c'];

you store an Array (which is just an object that is a List, cf.
[http://doc.perl6.org/type/Array]) in a variable that doesn't flatten by
default.

so say $z

i store an Array () in a variable (because an Array is just a class that
is a List) but as this variable has the sigil, it will not flatten by
default. $z is still an Array so you can call everything available in
[Array](http://doc.perl6.org/type/Array) class to iter on $z like 

    .say for @$z;
    .say for $z.flat;
    $z.flatmap: &say;

(the last one confuse me as i iter on reversed Array).

so Gabor asked 

> What is the value behind this complexity?

Well ... I have to admit that this is the very frustrating point of
Perl6 for the moment: i struggle a lot getting what i want from
splitting lines, merging structures and so on but you also can imagine
the potential of having an object that can have methods and can act both
as a hash and and array (in perl6, you'll say "which is both Positionnal
and Associative").

HTH.
(also hope it's correct)

-- 
Marc Chantreux (eiro on github and freenode)
http://eiro.github.com/
http://eiro.github.com/atom.xml
"Don't believe everything you read on the Internet"
    -- Abraham Lincoln

Reply via email to