Adding new math operators

Huaiyu Zhu hzhu at users.sourceforge.net
Fri Aug 4 19:51:06 EDT 2000


On Fri, 04 Aug 2000 05:56:31 GMT, Jeff Petkau <jpet at eskimo.com> wrote:
>...
>> Examples:
>>      b = a.I ~- a.I ~* u ~/ (c.I ~+ v~/a~*u) ~* v ~/ a
>>      z = sin(x~**2 ~+ y~**2)
>
>Gah. As much as I wish for more operators sometimes, I
>think this would have the Perl folks laughing at us for
>programming in line noise. And given how much discussion
>and thought went into this proposal, I'm not sure it's possible
>to do any better as long as you're restricted to ASCII.

A little clarification: these two examples only arise when you are using a
class that is of the opposite flavor (element vs object).  If the standard
op is of the desired flavor, all the ~ go away, and you get

    b = a.I - a.I * u / (c.I + v/a*u) * v / a
    z = sin(x**2 + y**2)

The alternative op only occur in mixed situations. Whether this is line
noise or not, it's so much better than

b = sub(inv(a),div(mul(div(mul(inv(a),u),add(inv(c),mul(div(v,a),u))),v),a))

(Could anybody verify whether this is correct?)

As for Perl, I wouldn't even dream of doing numerical computation there.
Certainly I wouldn't substitute two lines of line noise with 60 lines of
line noise, let alone running in slow motion.  Perl only functions as glue
language, you still need real applications to do the real thing (except text
related tasks).

>And now for something completely different:
>
>What if there were no new operators, no new syntax, but
>instead a new module that used excessive cleverness to
>translate Python expressions into MathML, which was
>then displayed in emacs/Idle/PythonWin as Real Math?

Though I love to use markup languages for typesetting, I wouldn't use them
for programming.  You are looking at the source code most of the time
instead of whatever transformed results.  Only WYSIWYG works for programs.

Yes, I agree the root of the problem is that ascii is too antiquated.  But
given the available resources, I'd claim that the proposal in the PEP is the
least of all evils.

then-you'd-expect-me-to-say-that-ly yr's

Huaiyu




More information about the Python-list mailing list