Help improve program for parsing simple rules

Aaron Brady castironpi at gmail.com
Fri Apr 17 16:01:45 EDT 2009


On Apr 17, 2:01 pm, Paul McGuire <pt... at austin.rr.com> wrote:
> On Apr 17, 1:26 pm, Aaron Brady <castiro... at gmail.com> wrote:
>
> > Hi, not to offend; I don't know your background.  
>
> Courtesy on Usenet!!!  I'm going to go buy a lottery ticket!
>
> Not to worry, I'm a big boy.  People have even called my baby ugly,
> and I manage to keep my blood pressure under control.
>
>
>
> > One thing I like
> > about Python is it and the docs are careful about short-circuiting
> > conditions.  ISTR that C left some of those details up to the compiler
> > at one point.
>
> > >>> def f():
>
> > ...     print( 'in f' )
> > ...     return 10
> > ...>>> 0<f()<20
>
> > in f
> > True>>> 0<f() and f()<20
>
> > in f
> > in f
> > True
>
> > Therefore, if op{n} has side effects, 'op1 operator1 op2 AND op2
> > operator2 op3' is not equivalent to 'op1 optor1 op2 optor2 op3'.
>
> Interesting point, but I don't remember that "A < B < C" is valid C
> syntax, are you perhaps thinking of a different language?
>
> By luck, my implementation of EvalComparisonOp.eval does in fact
> capture the post-eval value of op2, so that if its evaluation caused
> any side effects, they would not be repeated.
>
> -- Paul

It was very hazy in my memory and is easily solved by a web search.
Perhaps I was thinking of the short-circuiting of 'and', and mixing it
up with the warning about parentheses in macros.

-Macros?  NO, Batman.
-I'm afraid so Robin.  Macros.



More information about the Python-list mailing list