On 11 Sep 2007 at 13:04, Chas Owens wrote:
> Negative indexing has been around at least since Perl 5 (and I think
> it goes back much farther than that).  As for compatibility with
> future versions of Perl, you should have no problem with the Perl 5
> line (e.g. 5.10, the next and possibly last Perl 5 release, although I
> believe they are planning Perl 5.12 now).  That specific feature is
> changing in Perl 6 (which will be released eventually).  In Perl 6 a
> negative index refers to elements before element 0*.  That is this
>
> my @a = 1,2,3,4,5
> @a[-1] = 6;
>
> will create a new element before the one holding 1 and put 6 there; so
> @a will now hold (6,1,2,3,4,5).  If you wish to set the last element
> of a Perl 6 array you must use the whatever** symbol minus the number
> of elements you want to go back.  So the Perl 5 code
>
> my @a = 1,2,3,4,5;
> $a[-1] = 6;
>
> would be
>
> my @a = 1,2,3,4,5;
> @a[*-1] = 6;
>
> The relevant Synopsis is S09:
> http://dev.perl.org/perl6/doc/design/syn/S09.html
>
> * Pugs appears to be broken in this regard, it still treats indexes
> like Perl 5 does and the whatever symbol maps to 0.
>
> ** from S02
> <<Ordinarily a term beginning with * indicates a global function or
> type name, but by itself, the * term captures the notion of
> "Whatever", which is applied lazily by whatever operator it is an
> argument to. Generally it can just be thought of as a "glob" that
> gives you everything it can in that argument position.>>

OH MY !

Yet another reason to stay away from Perl6.

After reading that part of S09 I can't keep from thinking that Perl6
was designed specifically for golf and obfu. Well *.

Jenda
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
        -- Terry Pratchett in Sourcery


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to