EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

2002  2003  2004  <20052006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 2002  2003  2004  <20052006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: data access structures, strings
From: Kay-Uwe Kasemir <[email protected]>
To: [email protected]
Date: Thu, 29 Sep 2005 10:54:27 -0400

On Sep 28, 2005, at 11:03 , Jeff Hill wrote:
1) reflexive =>  x==x is always true
2) symetric  => if x==y then y==x
3) transitive => if x==y and y==z then x==z


I agree that this is the correct definition of equivalence.

It's somewhat slower to guarantee this, but perhaps necessary.

It may be that a fast, but incorrect == operator may not be very useful.

Marty's right on the mathematical side.
On the practical side, when I write
    catA.equals(catB),
then I'm fairly certain that property catalog catA is compared to catB
by invoking catA's equal() method.

With operators I never know.
I can define a propertyCatalog/Container PC for doubles,
with a constructor that takes double,
a cast operator to double,
and now I can write
    catA == 3.14,
but don't know if the catA gets automatically cast to double
and compared as a number, or if the compiler generates a
temporary DoubleContainer instance from 3.14 and invokes its
comparison routine.
g++ 3.3 actually gives an error message:
error: ambiguous overload for `PC& == double' operator
error: candidates are: operator==(double, double) <built-in>
error:                 bool PC::operator==(const PC&)

In this case, I understand the message because I just created the mess
on purpose. But I had cases where I created those operators
for 'convenience', and a month later I worked on the code, got
a similar error message, and was very surprised what the compiler had
done to me to 'help' and now got confused.
Of course this probably only happens to me, because everybody else
understands C++ much better and should by all means use the operators,
but maybe we can still keep the methods in the API in case I have to use it.

Thanks,
-Kay


Replies:
RE: data access structures, strings Jeff Hill
References:
RE: data access structures, strings Jeff Hill

Navigate by Date:
Prev: RE: EPICS Meeting agenda Jeff Hill
Next: Re: strings Kay-Uwe Kasemir
Index: 2002  2003  2004  <20052006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: RE: data access structures, strings Jeff Hill
Next: RE: data access structures, strings Jeff Hill
Index: 2002  2003  2004  <20052006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 02 Feb 2012 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·