[slang-users] comparison operator grammar change

John E. Davis davis at space.mit.edu
Mon Oct 16 02:36:21 EDT 2006


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.




More information about the slang-users-l mailing list