jmarshal at mathworks.com
Wed Jun 13 14:55:27 CEST 2001
John Roth <johnroth at ameritech.net> wrote:
> So what you're saying is that if I have a function "Spam(eggs, ham) and a
> 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".
More information about the Python-list