Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
Keep It Simple, Stupid
 
PerlMonks  

(tye)Re: Why not support this syntax?

by tye (Sage)
on Apr 24, 2001 at 15:17 UTC ( [id://75089]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Why not support this syntax?

The other common case you want is that $x is outside some range. So will people try to write this: if(  $min > $x < $max  ) { which would always be false (provided $min < $max).

Or would you only allow inequalities of the same "direction" to be clustered together like that? Personally I never use > nor >= because I find the code easier to understand when the values are sort left-to-right, smallest-to-largest. (:

        - tye (but my friends call me "Tye")

Replies are listed 'Best First'.
Re: (tye)Re: Why not support this syntax?
by MeowChow (Vicar) on Apr 24, 2001 at 16:27 UTC
    I think you meant:
    if ($min > $x > $max) { ... }
    What you're implicitly suggesting is that Perl would change symantics from && between inequalities to ||, but how could perl possibly know when to do this and when not to? Eg. in my original expression, what would Perl do if $x was greater than $max? I think your example can more sensibly be expressed as:
    unless ($min < $x < $max) { ... }
       MeowChow                                   
                   s aamecha.s a..a\u$&owag.print

      See, I told you I can't understand code that uses >. (:

      But you just illustrated more problems with this. For example, your last line should have been: unless(  $min <= $x <= $max  ) But I don't find those compelling reasons to not implement it. If someone actually managed to produce a patch for this I wouldn't be opposed to it.

              - tye (but my friends call me "Tye")

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://75089]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.