Missing namespace qualification in GiNaC 1.0.12

Christian Bauer cbauer at thep.physik.uni-mainz.de
Wed Oct 30 19:18:52 CET 2002


Hi!

On Wed, Oct 30, 2002 at 06:15:53PM +0100, Roberto Bagnara wrote:
> It seems the patch below was not included in 1.0.12.
>
>     #define is_ex_the_function(OBJ, FUNCNAME) \
> !       (GiNaC::is_exactly_a<GiNaC::function>(OBJ) && GiNaC::ex_to<GiNaC::function>(OBJ).get_serial() == function_index_##FUNCNAME)
>
>     #define is_ex_the_function(OBJ, FUNCNAME) \
> !       (GiNaC::is_exactly_a<GiNaC::function>(OBJ) && GiNaC::ex_to<GiNaC::function>(OBJ).get_serial() == GiNaC::function_index_##FUNCNAME)

The function_index_* are not necessarily in the GiNaC namespace (only for
functions defined by GiNaC itself), so this patch would break
is_ex_the_function() for user-defined functions. Forcing function_index_*
into the GiNaC namespace doesn't seem to be possible in C++. I can't think
of any solution that wouldn't break binary compatibility.

In GiNaC 1.1, the situation is slightly improved: the function_index_*
are replaced by *_SERIAL classes which at least allows you to prefix the
function name with a namespace qualifier when using is_ex_the_function().
The ideal solution would be to convert is_ex_the_function() into a proper
template function (a la is_a<>() etc.), but this would require having
classes with the same identifier as functions (e.g. "class sin" which in
some way holds the serial number, and "sin()" which constructs a function
object) which also doesn't appear to be possible (well, gcc 3.x didn't
accept it...).

If you have any clever solution for this, I'd be happy to hear it.

Bye,
Christian

-- 
  / Coding on PowerPC and proud of it
\/ http://www.uni-mainz.de/~bauec002/


More information about the GiNaC-list mailing list