in reply to Slice Madness
Why do we have to have nasty things like this in our language? :-(
From perlop: Binary ".." is the range operator, which is really two different operators depending on the context. (emphasis mine)
I always felt this was a point of needless confusion in perl. If the operator is really two operators, why not create two operators? Just make a range operator (array context only), and a flip flop operator (scalar context only), and report an error if the wrong one is used in the wrong context? That would eliminate this kind of error altogether, and make life easier to all concerned.
Wouldn't that have been wiser? Is it too late to fix it? Will Perl6 have the same mistake?
Me, I don't like the flip-flop operator; I didn't understand it when I first ran across it, and now that I do, I still prefer to write my conditionals more verbosely. But I'd put up with it to appease the sed people (if the are any left), and create a range operator (or function), rather than deal with this kind of ugliness for newcomers (or for me when I'm sick, overtired, or called into work in the middle of the night).
Even a function called "range" that returned a list from the first argument to the last argument would probably do.
Given that I can write this:
it shouldn't be that much more confusing to write this:@range = $x .. $y; @slice = @x[ @range ];
and leave the .. for the flip flop.@range = range($x,$y); @slice = @x[ @range ];
Just a thought...
--
Ytrew
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Slice Madness
by TimToady (Parson) on Nov 09, 2005 at 19:33 UTC | |
by Anonymous Monk on Nov 09, 2005 at 23:48 UTC | |
Re^2: Slice Madness
by Roy Johnson (Monsignor) on Nov 09, 2005 at 23:02 UTC | |
by Anonymous Monk on Nov 10, 2005 at 00:08 UTC | |
by Roy Johnson (Monsignor) on Nov 10, 2005 at 04:00 UTC | |
by Anonymous Monk on Nov 09, 2005 at 23:18 UTC | |
by TimToady (Parson) on Nov 10, 2005 at 00:56 UTC | |
by SciDude (Friar) on Nov 12, 2005 at 00:37 UTC | |
by diotalevi (Canon) on Nov 10, 2005 at 14:43 UTC | |
by Roy Johnson (Monsignor) on Nov 10, 2005 at 14:01 UTC | |
Re^2: Slice Madness
by dragonchild (Archbishop) on Nov 09, 2005 at 18:50 UTC | |
A reply falls below the community's threshold of quality. You may see it by logging in. |