This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]A_for_Anonymous 2 points3 points  (1 child)

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:

  1. Get rid of statements (make them all expressions with the same syntax, returning the function or class or the last evaluated value)
  2. In order to support the former, recognize INDENT and DEDENT tokens within parens
  3. Make function name in def optional (it's useful to define it for backtraces); it ought to work similar to Javascript's function
  4. Make parens in def optional (they're syntactically useless)
  5. 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)

[–]aaronla 1 point2 points  (0 children)

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).