invalid expression in content|unit|...()

Richard B. Kreckel kreckel at thep.physik.uni-mainz.de
Thu Nov 22 18:46:53 CET 2001


Hi Pearu,

On Thu, 22 Nov 2001, Pearu Peterson wrote:
> On Thu, 22 Nov 2001, Christian Bauer wrote:
> 
> > On Thu, Nov 22, 2001 at 03:21:30PM +0200, Pearu Peterson wrote:
> > >   content(a*c,a)        -> exception 'invalid expression in unit()' ?!
> <snip>
>  
> > Seeing that a constant is just a global symbol with a special evalf()
> > behavior, maybe these two classes should be integrated better...
> 
> Indeed, while wrapping GiNaC to Python, I also noticed that this is the
> only relevant difference. That is, in addition diff(<constant>) returns
> always 0.
> 
> I went ahead and derived constant from symbol. It was quite simple, I just
> had to remove some constant methods that were almost identical with the
> corresponding methods in symbol (there were some stylistic differences).
> Right now I am running checks, and if they pass, I will send patches if
> you are interested in. Currently it looks like with these changes
> GiNaC will be also backward compatible.

We had this layout already where constant was derived from symbol and we
changed it because it turned out to produce all kinds of weird problems.  
That seems to have been before 0.4.0, though, since I can't find it in the
archives right now.  Generally it is considered problematic to have a
concrete class for use by folks and derive another concrete class from it.
Scott Meyers discusses this in his books to some extend.

>From a design perspective, I would much rather have an intermediate class
derived from basic from wich both constant and numeric are derived.  This
class could then provide everything these two have in common.

Regards
    -richy.
-- 
Richard B. Kreckel
<Richard.Kreckel at Uni-Mainz.DE>
<http://wwwthep.physik.uni-mainz.de/~kreckel/>





More information about the GiNaC-devel mailing list