Python grammar..
David LeBlanc
whisper at oz.nospamnet
Tue Jun 12 12:56:20 EDT 2001
More information about the Python-list mailing list
Tue Jun 12 12:56:20 EDT 2001
- Previous message (by thread): Python grammar..
- Next message (by thread): Python grammar..
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
In article <9g3ee3$dcq$1 at news.mathworks.com>, jmarshal at mathworks.com says... > John <john.thai at dspfactory.com> wrote: > > Hi, > > > I previously asked whether Python accepts function arguments without the > > opening/closing brackets and commas, like so: foo(x,y) would become foo x > > y. The answer to this was no. So, I am wondering if it would be easy to > > modify the source and rebuild the interpretor to accept this format? I > > tried modifying the Grammar file but that didn't seem to work... > > This introduces an ambiguity: how do you parse "f(1,2)"? Is it the > function f called with 2 arguments or is it f called with one > argument--the tuple (1,2)? I don't think there's any way to > disambiguate using parens. > > This issue doesn't come up in SML (the only other language I know that > uses concatenation for function application) because all functions in > SML take exactly one argument. > Smalltalk is paren free for function calls: |mystring len dict croak| #arg declarations such as they are - no typing. mystring := String new. mystring add: "this is a string". len := mstring length. len := (mystring add: "this is a string") length. dict := Dictionary new. dict at: "frog" put: "ribbet". croak := dict at: "frog". One thing to note is that keyward arguments that expect a value use : (required syntax) to denote that they do have an argument. Also, as you can see, parens can be used to control order of evaluation and the above paren'd expression results in the string to which the length method message is sent. Parens are actually required to enforce the commonly expected order of evaluation - * does not have precedence of evaluation over (for instance) -. Smalltalk uses strict left to right evluation unless parens are used. deprecating parens as argument grouping operators is one thing i'd love to see happen in Python! And postfix (only!) ++ and -- and .... and .... aond of course implied self! Regards, Dave LeBlanc
- Previous message (by thread): Python grammar..
- Next message (by thread): Python grammar..
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list