On Wed, Nov 13, 2013 at 10:22 PM, אלעזר firstname.lastname@example.org wrote:
2013/11/13 anatoly techtonik email@example.com:
So, what's wrong with supporting both:
print (1,2) (1, 2)
print (1,2) 1 2
That's horrible. Ok, I agree - this is the reason why it might be impossible to make both statement and a function. But between two ambiguities I chose that the function syntax takes precedence, because "print xxx" is a limited helper for fast-typing, with well-known limitations. More arguments - I doubt people often print tuples without formatting, and even if they do this, it is the code that they usually read immediately and can spot the mistake, so it doesn't hurt. It is not beautiful to have such ambiguity, and may not be recommended, and still "print xxx" is a nice feature to have.
What is your suggestion? Repeat Ruby's failure to make function call whitespace-insensitive?
I don't know Ruby. Where I can read more about this Ruby's fail?
print(1,2) 1 2 print (1,2) (1,2)
They should both map to print as expression, meaning print as a function, i.e. to the first one.
Besides, how do you want code like this one to behave?
print = log print xxx
"print xxx" translates to simplified print() call on the language level.
import builtins builtins.print = log print xxx
The same. When you get AST, it is already print call, or the statement can be translated to expression just after AST is received.