slang-users mailing list

[2006 Date Index] [2006 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

[slang-users] comparison operator grammar change


Hi,

For slang-2.1, I am thinking about making a change to the part of the
grammar that deals with the four comparison operators <, <=, >, >=.
In particular, I would like for boolean expressions such as

    a < b <= c

to mean

    ((a < b) and (b <= c)).
    
Similarly, 

    a < b <= c < d

would mean

    (a < b) and (b <= c) and (c < d).
    
This change would not only add clarity to code, but would also result in
some performance gain.  For example, compare

   if ((r0 <= hypot(x,y)) and (hypot(x,y) < r1))
     do_something ();

to

   if (r0 <= hypot(x,y) < r1)
     do_something ();

Unfortunately, such a change would break backward-compatibility.
Currently, a<b<=c is a valid expression and is equivalent to (a<b)<=c.
My feeling is that usage of such constructs is extremely rare in
existing slang code, whereas I imagine that with the proposed
semantics, these syntactic forms would become quite common.

Any thoughts on this matter? 
Thanks,
--John

PS. I will be releasing 2.0.7 soon and after that I intend to start on
the 2.1 series.

_______________________________________________
To unsubscribe, visit http://jedsoft.org/slang/mailinglists.html


[2006 date index] [2006 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]