1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

new conditional expression "between"

Discussion in 'Suggestions' started by Frank, Apr 18, 2012.

  1. Frank

    Joined:
    Aug 2, 2011
    Messages:
    258
    Likes Received:
    4
    how about a new conditional expression "between" (for the lazybones)?
    I like it e.g. in SQL because it is so obvious and easy to read.

    Code:
    iff %value between 100 and 500 then
     echo that's ok
    else
     echo that's out of range
    endiff
    
     
  2. mfarah

    Joined:
    Nov 2, 2009
    Messages:
    226
    Likes Received:
    5
    Sounds like fun. Specs and border cases should be clearly defined:

    Code:
    iff %value between 500 and 500 then ...
    If %value were to be 500, it should be true. Sure, it's obvious for integers... real numbers, not so much.

    Code:
    iff %value between 500 and 100 then ...
    ¿Throw an error, or silently invert the numbers?

    Code:
    iff %value between 'a' and 'z' then ...
    Easy enough for plain-old ASCII, but as soon as we consider code pages, etc., it can become rather complex. Should the output of the between operator depend on the active encoding?

    Code:
    iff %value between "Albert" and "James" then ...
    Acceptable?

    Code:
    iff %value between "Albert" and "james" then ...
    Note the lowercase 'j' - "Miguel" would be accepted.

    Code:
    iff %value between "Albert" and 42 then ...
    ERROR! Strong typing FTW :)

    What else?
     
  3. Frank

    Joined:
    Aug 2, 2011
    Messages:
    258
    Likes Received:
    4
    LoL :D
    Sure, it could be a kind of challenge, but it could also be a simplification in some cases.
     

Share This Page