|What precedence for shift-left/shift-right operators? email@example.com (Timon Christl) (2002-06-28)|
|Re: What precedence for shift-left/shift-right operators? firstname.lastname@example.org (Thomas R. Truscott) (2002-07-02)|
|Re: What precedence for shift-left/shift-right operators? email@example.com (Timon Christl) (2002-07-04)|
|From:||"Timon Christl" <firstname.lastname@example.org>|
|Date:||4 Jul 2002 23:07:29 -0400|
|Posted-Date:||04 Jul 2002 23:07:29 EDT|
On 2 Jul 2002 01:16:05 -0400, Thomas R. Truscott wrote
> However the language does it, programmers will occasionally do it wrong.
> The gcc compiler issues a helpful warning:
> suggest parentheses around + or - inside shift
> Another mistake I have seen is "if (x << y)" when the programmer
> meant "if (x < y)". (Vanilla gcc does not warn about that.)
> One can try to design the language to reduce mistakes.
> To avoid the 1+2<<3 problem, require parentheses when mixing operators.
This can lead to a *lot* a parentheses, which is not what I want. It's
only a toy language I'm developing, and I'm having other problems with
it at the moment (especially the interface to native code, which is
needed to implement the core classes of the runtime library).
> To avoid the if (x << y)" problem, require "boolean" values in the if.
Yes, I'm already doing this, the condition's type must be of class
Boolean (of which exactly two instances exist in my runtime: true and
false; one of these two are returned when evaluating the boolean
Timon Christl <email@example.com>
Return to the
Search the comp.compilers archives again.