That's only for a particular case, and looks kinda ugly or confusing as it seems to suggest it's obtaining a key from the result of function application. I don't think it fits correctly.
I do propose the following:
Get rid of statements (make them all expressions with the same syntax, returning the function or class or the last evaluated value)
In order to support the former, recognize INDENT and DEDENT tokens within parens
Make function name in def optional (it's useful to define it for backtraces); it ought to work similar to Javascript's function
Make parens in def optional (they're syntactically useless)
New lambda syntax:
x = def x: x + 1
example(x, def y, z: #INDENT after this line for i in y, z: ... return whatever #DEDENT after this line )
example2(x, (def y, z: y + z), def k: ... , more, arguments)
Python already allows ; as a statement separator, it is conceivable that indentation could be nested in expressions. Eg:
map(
mylist,
lambda x:( # note lambda appearing at start of a line, to set block indentation
if x > 2: return 2
else: return x))
To keep backwards compatible, lambda expressions always return their last expression, and statement-lambdas must enclose the lambda body in parenthesis (to avoid tuple expression ambiguity, among others).
3
u/A_for_Anonymous Jul 13 '11
That's only for a particular case, and looks kinda ugly or confusing as it seems to suggest it's obtaining a key from the result of function application. I don't think it fits correctly.
I do propose the following:
Get rid of statements (make them all expressions with the same syntax, returning the function or class or the last evaluated value)
In order to support the former, recognize INDENT and DEDENT tokens within parens
Make function name in def optional (it's useful to define it for backtraces); it ought to work similar to Javascript's function
Make parens in def optional (they're syntactically useless)
New lambda syntax:
x = def x: x + 1
example(x, def y, z: #INDENT after this line for i in y, z: ... return whatever #DEDENT after this line )
example2(x, (def y, z: y + z), def k: ... , more, arguments)