Forums

a < b < c

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

a < b < c

Postby Charles » Sat Jun 06, 2009 10:56 pm

I think it might be time to implement Python's convenient grammar for checking numeric ranges. I find myself writing this too many times:
x >= 0 and x <= 1

# which could just be:
0 <= x <= 1

# so the general form is:
<expr-a> <comparison> <expr-b> <comparsion> <expr-c>

Sound good?
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: a < b < c

Postby natter » Sun Jun 07, 2009 4:12 am

this looks very cryptic and breaks a bit with cobras readability imo


but i would also like to see a general feature to shorten up lines with repeating elements:

a not inherits b and a not inherits c and a not inherits d
a > 0 and a < 7 and a != 3
natter
 
Posts: 20

Re: a < b < c

Postby todd.a » Mon Jun 15, 2009 12:56 pm

I actually think it is more readable because by having
0 <= x <= 1

you can easily see that x is bounded by 0 and 1
todd.a
Site Admin
 
Posts: 81
Location: Chicago, IL

Re: a < b < c

Postby Charles » Tue Jun 16, 2009 2:12 am

I added a ticket for this.
ticket:161
Charles
 
Posts: 2515
Location: Los Angeles, CA


Return to Discussion

Who is online

Users browsing this forum: No registered users and 3 guests