Python grammar..

Remco Gerlich scarblac at pino.selwerd.nl
Thu Jun 14 03:00:09 EDT 2001


Joshua Marshall <jmarshal at mathworks.com> wrote in comp.lang.python:
> John Roth <johnroth at ameritech.net> wrote:
> 
> > So what you're saying is that if I have a function "Spam(eggs, ham) and a
> > function
> > scramble(<number of eggs>, size = small), then I'd have to write
> > Spam(scramble(eggs), ham) as
> > Spam scramble eggs ham.
> 
> > How do I tell that "ham" is an operand of Spam, and not the second operand
> > of scramble? The
> > only way this could possibly work is if the parser could tell, at compile
> > time, exactly how many
> > operands each function had. There are languages where this is possible, but
> > Python isn't one of them.
> 
> Choose a parsing rule and use parens to group things differently.
> Python (and many other languages) already need parens to do this for
> binary operators ("1-2-3" parses as "(1-2)-3").
> 
> So you'd probably have to write "Spam(scramble(eggs), ham)" as
> "Spam (scramble eggs) ham".

Why wouldn't that parse as (Spam (scramble eggs)) (ham) ?

If you're going to make the parentheses mandatory everywhere you've just
taken a step back to Lisp...

-- 
Remco Gerlich



More information about the Python-list mailing list