Hi, On Fri, 19 Jan 2001, Richard B. Kreckel wrote:
Okay, installing all those supporting packages is a somewhat intrusive procedure. We had a close look at it, though. I have a couple of comments on the patches you applied to the GiNaC files. For those who haven't seen them yet, let me sum up: they consist of a bunch of `#ifdef __WITH_GUI__' delimited statements that turn the output function to something useful for TeXmacs. This works great. But, frankly, it is ugly.
Well, I agree that I will not win a beauty contest for programming style with these patches.
Our Todo-List <http://www.ginac.de/ToDo.html> says something about "systematic I/O-Philosophy". There might be people who wish to have their expressions directly print OpenMATH or MathML or MathML or Maple-Input or Mathematica-Input... You name it. What we *should* do instead of defining more and more .print_my_fancy_format(ostream & os) methods to the interfaces is this:
* define some printflags (maybe an enum) that tells how the output should look like,
* make ex::print(), basic::print()... aware of these flags and handle everything inside those print functions -- but without bloating them (by moving out code into static functions as far as reasonable).
* [optional] some of the already existent print methods may be eliminated now, if the flags can incorporate this distinction.
Let's go one step further towards "the best of all worlds"(tm). Ideally, in the end one would write code like this, using manipuators:
ex e = 3/2*pow(Pi,2); cout << e << endl; // prints 3/2*Pi^2; cout << ginsh << e << endl; // ...the same in this case... cout << tex << e << endl; // prints \frac{3}{2}\Pi^2 // 1 2 cout << pretty << e << endl; // prints --- Pi // ... imagine more... // 2
This can't be done so simply, since std::cout is an object of type ostream and it simply not clever enough to remember such states as tex, pretty and so on. It is only designed for hex, oct, boolalpha and a few others. However, it is straightforward to derive your own class from ostream that handles such flags and define a GiNaC::ostream cout; somewhere so one could choose it simply by saying using GiNaC::cout;. Chapter 21 in Bjarne Stroustrup's Book TC++PL3 (The C++ Programming Language, 3rd ed.) is a readable and rather realistic description of streams in C++ and gives enough insight to implement this.
Stefan, since you had a look at the output and understand it and since the output must be reorganized anyways and since I am rather busy on other frontiers and since I would love to have your routines in GiNaC (once they are reorganized), would you be willing to volunteer on this? And remember: good patches are very welcome!
I can have a look at it, but expect something more on a time scale of months than weeks. The reasons are that at the moment I'm not yet too familiar with the source code of GiNaC, and secondly, I would like to write some applications/extensions first. (You write good code only if a problem really bothers you !) Stefan