Discussion: Introducing new operators for matrix computation

hzhu at localhost.localdomain.bbs hzhu at localhost.localdomain.bbs
Sat Jul 15 02:00:02 EDT 2000


On Fri, 14 Jul 2000 23:00:14 -0500, Paul Prescod <paul at prescod.net> wrote:

>> The problem is that Python provides no way for an add-on module to
>> define new operators.
>
>But that's not really an accident. There are languages that allow you to
>define new operators. REBOL is the most flexible example. Python
>emphasizes syntactic *simplicity*.

Well, I think there are two levels of syntactic simplicity:

1. Different structures: like the difference among identifiers, various
   literals (number, list, dict, string), indentation delimited blocks,
   function arguments.

2. Allowed members within a structure: like which function names are legal,
   which operators are binary, which functions can be overloaded.

To keep the first kind of simplicity we need to restrict number of things
allowed. But to keep simplicity of the second kind we need to remove
arbitrary restrictions.

For example, I had included a file aux.py in the MatPy package which caused
a great deal of headache for Windows users.  It turned out that Windows do
not allow file name to be aux because it's a device name.  This kind of
unreadonable restrictions represent complexity, not simplicity.

Python already provides both function names and binary operators, so the
first level issue is not there.  However, while it gives almost unlimited
supply of function names that can be overridden, there is only a handful of
binary operators which have deep rooted meanings and not enough for
overloading. This limit is largely arbitrary, and is therefore complexity.

>> Unfortunately, the current lack of appropriate notation makes these
>> problems very difficult to code clearly.
>
>Every domain of computing would be enhanced with special notation. Text
>processing, XML, COM, databases, Web programming etc.

Haven't we already talked this through?  Text processing already got its
special syntax, even of the first level, which is quoted string.  Within a
quoted string you could put in any text sequence.  In this specific domain
it happens that only very limited number of binary operators are required,
and they are duly provided, like string + string, string % string, or string
* number.  All the other things you mentioned could be built on top of this.
This domain is not even as mature as matrix computation - in many earlier
languages it was though that special syntax is needed for printing, formats
and regular expressions, which turned out to be just ordinary string
operations and functions, as python shows.

On the other hand, for proper matrix operation, there is not much need for
any additional first level structure, but there does exist a great need for
a larger supply of binary operators.  What we are saying is that extending
the number of operators overridable by applications represents a much
smaller risk of incompatability than giving everyone a complete parser.
With the given operators, all the fields like scientific computation,
graphics, statistical analysis and artificial intelligence could also be
built on top of this.

Before you dismiss numerical computation as just another domain, why not try
a few packages and get a feeling of how large the domain is?


Huaiyu



More information about the Python-list mailing list