It's a bit confusing at first that Perl 6 has different scalar contexts, called "item context".

In generic item context an array returns a capture (think reference) to an array.

But in other item contexts, like boolean ?@array, numeric +@array and string ~@array the array will return different things (for example number of elements, and a string representation).

A scalar value that holds an array capture automatically dereferences, so you can write $ary[0] instead of the cludgy $ary->[0].

I don't know why this should make sigils useless. Sigils serve two purposes: visual distinction, and name disambiguation (%foo is a different variable than @foo).

Automatic dereferencing doesn't impact any of those.

It's like in Perl 5 - you can store everything in a scalar (or scalar ref), but you shouldn't, because it makes your program less readable.

But if you decide to do that in Perl 6, the syntax is nicer ;-)

Update: as a side note the braces after a variable are nothing special or magical in Perl 6, it just calls  method postcircumfix:<[ ]>($invocant:, $argument) on the variable. So it's just natural that it works on a capture as well as on an array.


In reply to Re: [Perl 6] $ and @ - what is it coming to? by moritz
in thread [Perl 6] $ and @ - what is it coming to? by John M. Dlugosz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.