in reply to Re^6: [Perl 6] $ and @ - what is it coming to?
in thread [Perl 6] $ and @ - what is it coming to?
Bingo.
Do I take it that is not agreement?
As for operations on the container, they are just member functions. Call a suitable one.
So, you are advocating instead of say:
@data[ @ordered[ 0, -1 ] ] = @data[ @ordered[ -1, 0 ] ];
something like this?:
@data.setSlice( items_to_set => [ @ordered.getSlice( 0, @ordered.last ) ], values_to_set => [ @data.getSlice( @ordered.getSlice( @ordered.las +t, 0 ) ], );
Because if you are, it strikes me that is moving much further away from both the syntax and spirit of Perl than the minor correction of the historical inconsistency that you are up in arms about.
From Re^2: [Perl 6] $ and @ - what is it coming to?:
What if an Object is a collection class of some kind? And it only is useful on the top-level, as anything already inside another collection is a scalar.
The elements of a collection are always scalars. There is no ambiguity there.
When I first came to Perl, the unique requirement to use a different sigil when referring to an individual element of a collection, than when referring to the whole collection, or part thereof, was one of the most confusing things I encountered. Totally different from any other language I had used. And from what I've seen here I do not think I am unique in that. Sure you get used to it, but it never made much sense (to me).
For example, there is the whole dichotomy of this (an empty slice) being perfectly legal and useful:
## an empty slice at runtime c:\test>perl -mstrict -wle"my @a='a'..'z'; print @a[ grep $_ == 10, 1. +.9 ];" ## no output and no errors
And this being illegal:
## an empty slice at compile time c:\test>perl -mstrict -wle"my @a='a'..'z'; print @a[ ];" Scalar value @a[ ] better written as $a[ ] at -e line 1. syntax error at -e line 1, near "[ ]" Execution of -e aborted due to compilation errors.
Same for one-element slice:
## a slice of one element at runtime c:\test>perl -mstrict -wle"my @a='a'..'z'; print @a[ grep $_ == 5, 1.. +9 ];" f
And this being illegal:
## a slice of one element at compile time c:\test>perl -mstrict -wle"my @a='a'..'z'; print @a[ 5 ];" Scalar value @a[ 5 ] better written as $a[ 5 ] at -e line 1. f
Both are inconsistent and illogical. It is making a distinction between zero or single element lists and a multi-element lists, when there should be none.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: [Perl 6] $ and @ - what is it coming to?
by John M. Dlugosz (Monsignor) on Mar 29, 2008 at 08:25 UTC |