Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re: the '..' operator and decreasing values

by SolidState (Scribe)
on Mar 06, 2005 at 16:57 UTC ( #437064=note: print w/replies, xml ) Need Help??

in reply to the '..' operator and decreasing values

does anybody know why this behaviour was chozen?

More important, I think, is the question "why doesn't use warnings; warn about this?
I think this is the real question here. I too have been bitten by this behaviour and while it didn't cost me hours to debug, it did slow me down and was annoying to find. I don't know why use warnings; doesn't warn about this. I wish it did :-(
After all, we already get messages such as "Useless use of a constant in void context at...". Why not something like "Useless use of an empty list in loop context at...", or something similiar.

Just my 2 cents worth...
  • Comment on Re: the '..' operator and decreasing values

Replies are listed 'Best First'.
Re^2: the '..' operator and decreasing values
by Anonymous Monk on Mar 07, 2005 at 09:46 UTC
    Because that would be another useless warning. I write
    for ($x .. $y) { .. }
    quite often, knowing that it will not do anything if $y < $x.
    @a = 1 .. 3 # 3-element list @a = 1 .. 2 # 2-element list @a = 1 .. 1 # 1-element list @a = 1 .. 0 # 0-element list
    The latter to be a 2 element list would be very surprising (and would require a lot of extra code in my programs).

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://437064]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2023-03-28 18:49 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (68 votes). Check out past polls.