Hi,
On 10.09.05, Simson Garfinkel wrote:
> >The reason for this being that we removed our own expressions
> >parser in favour of using the Python eval function. Commenting on
> >the graph style, I'll happily leave to André...
>
> You had an expression parser? Oh my. I always assumed you used eval().
Right: oh my goodness. I'm happy we finally could remove it, but let
me tell you the story from the beginning.
Before we started PyX I created a nonlinear fitting system used in a
commercial application. This thing was written in Delphi, a Pascal
dialect. I had to create an expression parser to do that, which turned
expressions in so called math trees (basically a tree where each knot
is a operator or function and the leaves are constants and variables).
And since it was funny to do, I also implemented a symbolic derivative
calculator base on those math trees. It turned out, that symbolic
derivatives are a great help for nonlinear curve fitting in terms of
speed, stability and precession.
When I started to work on PyX and its graph system, I ported the
expression parser. It was one of the first things I did in Python and
I was uncertain of Pythons eval (and compile and so on) to be a better
solution. At the same time it was quite easy to add special syntax
like the $notation for columns and the inplicit variable notation.
Think of the expression "y=sin(x)", where the system understood to
create a function y(x). It got into troubles for functions like "y=1",
which was an error for a long time. In 0.8 we introduced the explicit
notation "y(x)=1" with an deprication warning for the old implicit
notation ... and for 0.9 I now could remove the old math tree. (The
expression parser itself was removed earlier by Michael.) This also
allows us now to use different types in the expressions than we had
before. For bar graphs and split axes the tuples are now visible to
the end user. At the same time, the mathtree removal in the CVS was
smooth; all examples and test cases worked without a modification
(beside some changes in nested bar axes, which are a wanted feature).
However, there are some changes visible to the end user, since the
mathtree always worked on floats in favour of integers. As you well
know, integers are errorprone in divisions (new style division is a
great solution, but unfortunately it's not yet the default).
But one thing we missed in the discussion is, that the context feature
was available for years already. It has nothing to do with the removal
of our old expression handling.
André

by _ _ _ Dr. André Wobst
/ \ \ / ) wobsta@..., http://www.wobsta.de/
/ _ \ \/\/ / PyX  High quality PostScript and PDF figures
(_/ \_)_/\_/ with Python & TeX: visit http://pyx.sourceforge.net/
