|Parsing/evaluating shortcutting operators firstname.lastname@example.org (Jeremy J Starcher) (2009-01-13)|
|Re: Parsing/evaluating shortcutting operators email@example.com (Bartc) (2009-01-15)|
|Re: Parsing/evaluating shortcutting operators firstname.lastname@example.org (Jeremy J Starcher) (2009-01-17)|
|Date:||Thu, 15 Jan 2009 18:05:08 GMT|
|Posted-Date:||16 Jan 2009 07:01:12 EST|
"Jeremy J Starcher" <email@example.com> wrote in message
> I am unsure how to proceed in setting up shortcutting operators
> however. For example, this code:
> declare boolean b
> b = (1 == 2) || (3 == 4)
> Which results in the expression
> 1 2 == 3 4 == || b =
You've made me feel inadequate, because my compiler only uses shortcut
evaluation when there are jumps involved (eg. inside an If conditional, but
not in an ordinary expression).
But I found that my (a|b|c) construct (equivalent to C's a?b:c) generates
code like an If statement.
So I can fix this 'problem' by turning 'a and b' into (a and b|1|0), and 'a
or b' into (a or b|1|0), either manually or letting the compile do it as you
seem to be attempting to.
It's possible that you can try something similar, if you also have an
equivalent a?b:c operator that already has short-circuit evaluation.
Return to the
Search the comp.compilers archives again.