Related articles |
---|
What precedence for shift-left/shift-right operators? christl@bandos.fmi.uni-passau.de (Timon Christl) (2002-06-28) |
Re: What precedence for shift-left/shift-right operators? trt@cs.duke.edu (Thomas R. Truscott) (2002-07-02) |
Re: What precedence for shift-left/shift-right operators? christl@belinda.fmi.uni-passau.de (Timon Christl) (2002-07-04) |
From: | "Timon Christl" <christl@belinda.fmi.uni-passau.de> |
Newsgroups: | comp.compilers |
Date: | 4 Jul 2002 23:07:29 -0400 |
Organization: | Compilers Central |
References: | 02-06-079 02-07-015 |
Keywords: | parse, design |
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
operators).
--
Timon Christl <me@christltimon.de>
Return to the
comp.compilers page.
Search the
comp.compilers archives again.