Prefix and postfix operators

Andrew J Bromage ajb@spamcop.net
Thu, 28 Aug 2003 17:24:49 +1000


G'day all.

On Thu, Aug 28, 2003 at 11:05:52AM +0200, Ketil Z. Malde wrote:

> We already have prefix operators, don't we?  I.e., regular functions
> are prefix?

Not really.  This:

	- sqrt x

Doesn't mean the same thing as this:

	negate sqrt x

I think the difficulty is that it's very hard to convert a general
operator grammar into a context-free grammar, particularly if you
can set precedences and associativities at run-time.  See, for example:

	http://citeseer.nj.nec.com/aasa91precedences.html

Effectively you end up writing a whole other parser just to handle
operators.

Cheers,
Andrew Bromage