[GiNaC-devel] Real and imaginary parts.

Richard B. Kreckel kreckel at ginac.de
Mon Apr 24 22:25:25 CEST 2006


Dear Chris,

Chris Dams wrote:

>
>No, actually, just because I was thinking "what could be a nice name for a
>function that takes the real/imaginary part of something". Do you think
>that it should be changed? I am not sure whether numeric::real() and 
>numeric::imag() would cause trouble in that case.
>  
>

Sure the return type would cause trouble. The return type can only 
change if it's a reference or pointer and if it changes covariantly 
across the class hierarchy. In the case at hand, it's a numeric object, 
however, not a refernece. Even changing covariantly would not be a good 
idea in GiNaC for the very same reason basic::eval() and so many others 
return an ex object.

No, the numeric::real() member function would have to be renamed to make 
place for a new signature ex numeric::real() (the free function 
real(const numeric&) could stay, in principle, I guess). This would 
break compatibility somewhat, however. Alternatively, ex::real() could 
dispatch to a differently named basic member function, like your 
real_part(). Not nice.

Don't misunderstand me. I'm not advocating it, merely pondering aloud...

Cheers
-richy.

-- 
Richard B. Kreckel
<http://www.ginac.de/~kreckel/>




More information about the GiNaC-devel mailing list