EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  <20032004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  <20032004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: Long expressions using MAX and MIN in CALC fields
From: Noboru Yamamoto <[email protected]>
To: Tim Mooney <[email protected]>
Cc: Andrew Johnson <[email protected]>, "Redman, Russell O." <[email protected]>, "Tech-Talk (E-mail)" <[email protected]>
Date: Fri, 28 Feb 2003 08:59:17 +0900
Tim Mooney wrote:
Andrew, re...,


The GNU C++ compiler has a built-in extension for MIN and MAX that uses <?
and >? respectively as the binary operators.  Although I'd prefer that we
stick as close as possiblt to the standard C operators and function
syntax, if a variable-length MIN() and MAX() can't easily be developed
it's probably better to regard g++ as a sort of standard and re-use their
operators.


I think <? would be valuable even if min(a,b,c,d,...) existed, because in some
cases using the operator would yield a clearer expression. But I certainly
agree that sticking to standards is the way to go. Otherwise we might get more
functions like "loge" (should be "ln"), and operators like "#" (should be "!="
or "<>").
To this end, does anyone happen to know the precedence and associativity of these
operators? I.e.,
does a + b <? c mean (a + b) <? c or a + (b <? c)
does a <? b <? c mean (a <? b) <? c or a <? (b <? c)
does a * b <? c mean (a * b) <? c or a * (b <? c)
etc. I haven't been able to find this information online.



The token value for "<?" and ">?" is MAX_MIN. And parse.y for gcc defines precedence rules:

%nonassoc THROW
%right <code> ':'
%right <code> ASSIGN '='
%right <code> '?'
%left <code> OROR
%left <code> ANDAND
%left <code> '|'
%left <code> '^'
%left <code> '&'
%left <code> MIN_MAX
%left <code> EQCOMPARE
%left <code> ARITHCOMPARE '<' '>'
%left <code> LSHIFT RSHIFT
%left <code> '+' '-'
%left <code> '*' '/' '%'
%left <code> POINTSAT_STAR DOT_STAR
%right <code> UNARY PLUSPLUS MINUSMINUS '~'
%left HYPERUNARY
%left <ttype> LEFT_RIGHT
%left <code> POINTSAT '.' '(' '['


So I think, "<?" and "<?" are stronger than "&" but weaker than EQCOMPARE (==).


a + b <? c   mean  (a + b) <? c
a * b <? c   mean  (a * b) <? c

This definition also says "<?" and ">?" are left associative.
So,

a <? b <? c mean (a <? b) <? c

I think.

Noboru



References:
Long expressions using MAX and MIN in CALC fields Redman, Russell O.
Re: Long expressions using MAX and MIN in CALC fields Andrew Johnson
Re: Long expressions using MAX and MIN in CALC fields Tim Mooney

Navigate by Date:
Prev: Re: Long expressions using MAX and MIN in CALC fields Tim Mooney
Next: Re: Long expressions using MAX and MIN in CALC fields Andrew Johnson
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  <20032004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: Long expressions using MAX and MIN in CALC fields Tim Mooney
Next: Re: Long expressions using MAX and MIN in CALC fields Andrew Johnson
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  <20032004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 10 Aug 2010 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·