Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: the '..' operator and decreasing values

by SolidState (Scribe)
on Mar 06, 2005 at 16:57 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (None)
    As of 2024-04-19 00:10 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found