Stéphane Payrard wrote:
[snip]
> Non alphabetic characters are very conspicuous, so redundancy should
> be avoided. But Sigil _and_square/curly bracket are redundant.

Not quite...

In Perl5, the dereference operator (->) is optional between pairs of
subscript operators, so $foo[$x]->[$y] can be written as $foo[$x][$y],
but the first -> isn't optional... you cannot write $bar->[$x] as
$bar[$x], since that would be an access to @bar, not $bar.

In Perl6, since array accesses are always written as @a[$b], never as
$a[$b], it's possible to write $a.[$b] (array dereference) as $a[$b],
which is rather nicer looking, imho.

Thus, in Perl6, @a[$b] is an access to the array @a, and $a[$b] is an
access to the arrayref $a.

> Space as syntax can be a device to drop the sigil when dereferncing an
> array or a hash.
> 
> a [$a]  # call the function 'a' with a
>         # reference to an array as parameter
> a[$a]   # dereference the array @a

But '@a' isn't a reference... did you mean 'index into' instead of
dereference?

Also, part of the goal of perl6 is to simplify the grammer, make it more
consistant -- this would make accesses to arrays different from accesses
to arrayreferences.

I prefer for whitespace to be mostly meaningless -- this isn't python.

> Same thing goes for C<a {$a}> and C<a{$a}>.
>
> Certainly, within double quotes one has to write C<@a[$a]> because
> without the sigil, that would be to easy to accidentally dereference
> an array.  This is a case of preferring convenience over
> consistency. Probably for the consistency freaks C<a[$a]> should be
> allowed as well as C<@a[$a]> outside double quoting context.

Allowing two different ways of writting an array access is
*in*consistant, and the one which looks like a function call instead of
an array access, and which makes the grammer more complicated -- that
is, your proposed a[$a] -- should be dropped from the language.

(Perl5 allows two different ways of writing arrayref accesses, one being
$$a[$b], the other being $a->[$b].  This is inconsistant, and I would
love it if we could drop $$a[$b], but sadly, we need to be backwards
compatible, and also, the $a->[$b] syntax doesn't support slices.)

-- 
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "[EMAIL PROTECTED]
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}

Reply via email to