I would like to have some comments from you about a proposal about constants: In order to forbid insane code like this one in GiNaC: EulerGamma = Pi; cout << EulerGamma << endl; // prints 3.14... all objects of class constant need to be declared const (which is the case for built-in constants). While the copy constructor for constants is sane (because when you declare constant EulerGamma(Pi); this is a new constant with local scope) the above case is not. One could override constant::operator= but there are other cases. E.g. I wanted to override constant::subs() to return *this but while this seemlingly worked for the checks it caused basic's virtual table to be overridden with garbage (and then executed, which caused a SEGV beeing raised) by the xloops check. I do not have any clue why this happens. Also, I had to change symbol::subs to be somewhat more flexible. The whole trouble is IMHO caused by the fact that symbol is currently partly caring for its derived class constant. Can't we just eliminate class constant and declare global symbols like Pi, EulerGamma and the like and assign them an evalf()-function similar to how expressions may be assigned to symbols? Then just declare those special symbols const and that's it? I haven't tried it, just wanted to hear your comments and sleep a night before doing something, maybe it's rubbish! Cheers -rbk. -- Richard Kreckel <Richard.Kreckel@Uni-Mainz.DE> <http://wwwthep.physik.uni-mainz.de/~kreckel/>
On Wed, 15 Sep 1999, I wrote:
I would like to have some comments from you about a proposal about [...]
Hell, I have forgotten to include the latest seminal results from our famous how-maple-does-one-non-commutative-object-under-addition-dept.:
exp(evalf(log(matrix(2,2,[[exp(1),0],[0,exp(1)]])))) - x; x - x -- Richard Kreckel <Richard.Kreckel@Uni-Mainz.DE> <http://wwwthep.physik.uni-mainz.de/~kreckel/>
On Wed, 15 Sep 1999, Richard B. Kreckel wrote:
Can't we just eliminate class constant and declare global symbols like Pi, EulerGamma and the like and assign them an evalf()-function similar to how expressions may be assigned to symbols?
Maybe they could be functions with zero arguments? Bye, Christian -- / Coding on PowerPC and proud of it \/ http://www.uni-mainz.de/~bauec002/
On Thu, 16 Sep 1999, Christian Bauer wrote:
class constant and declare global symbols like Pi, EulerGamma and the like
Maybe they could be functions with zero arguments?
Do you really want to write Pi()? I vote for an independent class constant directly derived from basic. -- Alexander Frink E-Mail: Alexander.Frink@Uni-Mainz.DE Institut fuer Physik Phone: +49-6131-393391 Johannes-Gutenberg-Universitaet D-55099 Mainz, Germany
On Thu, 16 Sep 1999, Alexander Frink wrote: [...]
Do you really want to write Pi()? I vote for an independent class constant directly derived from basic.
Seconded. Does this introduce a lot of changes in other modules where stuff is tested for is_ex_of_type(foo, symbol)? I don't exactly see tons of such stuff... -rbk. -- Richard Kreckel <Richard.Kreckel@Uni-Mainz.DE> <http://wwwthep.physik.uni-mainz.de/~kreckel/>
On Thu, 16 Sep 1999, Richard B. Kreckel wrote:
Does this introduce a lot of changes in other modules where stuff is tested for is_ex_of_type(foo, symbol)? I don't exactly see tons of such stuff...
in printcsrc.cpp, this should be replaced by is_ex_exactly_of_type(foo,symbol) || is_ex_exactly_of_type(foo,constant) in series.cpp, the is_ex_of_type(var_,symbol) should be is_ex_exactly_of_type(var_,symbol) (or do we want a power series expansion in Pi?) in symbol.cpp, the // ASSERT(is_ex_exactly_of_type(ls.op(i),symbol)); ASSERT(is_ex_of_type(ls.op(i),symbol)); was changed quickly to get rid of the subs bug for constants. -- Alexander Frink E-Mail: Alexander.Frink@Uni-Mainz.DE Institut fuer Physik Phone: +49-6131-393391 Johannes-Gutenberg-Universitaet D-55099 Mainz, Germany
On Thu, 16 Sep 1999, Alexander Frink wrote:
Do you really want to write Pi()?
#define Pi Pi() Bye, Christian -- / Coding on PowerPC and proud of it \/ http://www.uni-mainz.de/~bauec002/
On Fri, 17 Sep 1999, Christian Bauer wrote:
On Thu, 16 Sep 1999, Alexander Frink wrote:
Do you really want to write Pi()?
#define Pi Pi()
"Almost every macro demonstrates a flaw in the programming language, in the program, or in the programmer." Bjarne Stroustrup The C++ Programming Language, 3rd edition page 160 -- Richard Kreckel <Richard.Kreckel@Uni-Mainz.DE> <http://wwwthep.physik.uni-mainz.de/~kreckel/>
On Fri, 17 Sep 1999, Richard B. Kreckel wrote:
#define Pi Pi()
"Almost every macro demonstrates a flaw in the programming language, in the program, or in the programmer."
In case of doubt, it's always the former. BTW, why don't we use a Real Programming Language like Pascal that allows calling functions without arguments without parentheses? :^) Bye, Christian -- / Coding on PowerPC and proud of it \/ http://www.uni-mainz.de/~bauec002/
participants (3)
-
Alexander Frink
-
Christian Bauer
-
Richard B. Kreckel