Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Declined new conditional expression "between"

Aug
258
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
 
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

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?
 
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?

LoL :D
Sure, it could be a kind of challenge, but it could also be a simplification in some cases.
 
Back
Top