Hi! On Sun, 8 Apr 2001, Christian Bauer wrote:
On Sun, Apr 08, 2001 at 06:17:50PM +0200, Pearu Peterson wrote:
basic::precedence
Why do you need this?
basic::precedence (that is, basic::get_precedence() virtual) is needed for Python `str' representation. It is very close to ginsh output type but has the following differences: 1) a^b is a**b in Python, 2) [[ [[a]], [[b]] ]] is [ [a], [b] ] (matrix) 3) For GiNaC function objects I needed a special trick to support their creation and calling from Python. The trick includes a special class that contains information about Python functions and its instance is past to GiNaC function as an additional argument that the end-user should *not* see. 4) Some additional tricks were needed for constant objects in order to support Python callbacks for evaluation. Because of all this I separated the code generating Python `str' and `repr' representation from GiNaC and it is now (almost) independent of GiNaC.print functions.
Here's another idea for finding all properties of all objects of a GiNaC expression: if you archive the expression, all relevant information will be stored inside an archive object. Currently, it's all safely hidden inside, but I see no problem in making the data available for public read access. It should then be easy to, e.g., convert an archived expression to a Python initializer.
I guess (never tried), it means extra work/code. But not all properties are needed, just those that were used in *constructing* the object. In order words, just getter methods inline const * get_<what's-in-constructor-arguments>() const; In addtion, I found that color::representation_label is private. Could you make it at least protected or provide get_representation_label() function? Because it is explicitely used in construction of an color object and therefore is crucial to know for reproducibility in Python interface. The same holds for minkmetric::pos_sig tensepsilon::minkowski tensepsilon::pos_sig Thanks for your other hints as well, Pearu