Operators for matrix: current choices (Was Matlab vs Python ...)

Michael Hudson mwh21 at cam.ac.uk
Wed Jul 19 18:54:52 EDT 2000


dipping in and out of this thread...

Paul Prescod <paul at prescod.net> writes:

> Parsers just do not work that way. Most parsers cannot be extended at
> runtime. The language is defined at compile time by the grammar. The
> only way to do it without rewriting Python's parser from scratch would
> be to pre-declare every possible operator anyone might ever want in the
> grammar.

What Haskell does is to declare that any sequence of characters from
the set [!+-*/$=%] (I think) to be an operator, much the same way as
any sequance of characters from [a-zA-Z_0-9] (ish) is a token in
Python today.

Still don't think runtime syntax extension is a good idea, but
unfortunately we can't claim that it's impossible.

Cheers,
M.
(who's just given half a second's thought to how much effort it would
be to get Python's current lexer/parser to work in the above model and
now has to sleep it off)

-- 
  I have gathered a posie of other men's flowers, and nothing but the
  thread that binds them is my own.                       -- Montaigne



More information about the Python-list mailing list