one more reject (was Feature decision deadline on 7/14)
"Mark Hahn" <[email protected]>
| Newsgroups | gmane.comp.lang.prothon.user |
|---|---|
| Message-ID | <[email protected]> |
I have added the function-as-command feature to the tenative decision REJECT
list. We have been using it for the print function and I have proposed
using it for the yield function in the stackless proposal.
Here are the arguments pro and con:
1) It allows the familiar command appearance of keyword statements:
print a, b, c
yield result
2) It has syntax problems because the function name is not a keyword. These
fall into two categories.
2.a) One syntax problem happens with constants like tuple constansts
and list constants. One can argue that you wouldn't be printing a constant,
but you might want to yield a constant. You can always fix these problems
by surrounding them in parens to make it a function instead of a command.
print (1,2) # this is a function, not a tuple
print [1,2] # throws an exception, a function cannot be indexed
print ((1,2), [1,2]) # parens fix any problem
2.b) Another syntax problem happens when you want to print an
expression that happens to start with parens. The parens fool the function
into thinking it is the function format instead of a command. Luckily this
throws an exception for print but we aren't so lucky with yield or any other
function we might want to return a value from. We could say that you can
only use this feature with functions that return None.
print (1+2) * 3 # throws exception since print() returns None
The reason I am tenatively deciding for rejection is that it barely worked
for print and now it doesn't work at all for yield since yield returns a
value. So the trend is not good.
I will also remove mention of this feature from the stackless proposal asap.