Hacker News new | ask | show | jobs
by ghj 2176 days ago
OMG there are multiline lambdas!!! https://coconut.readthedocs.io/en/master/DOCS.html#statement...

But trying it out, it doesn't even look like python anymore. Especially if you want to nest them a lot like in other callback heavy languages. It requires a lot of semicolons and parens to get past the parsing ambiguity problem: https://stackoverflow.com/questions/1233448/no-multiline-lam...

    # Incorrect, the lambda returns (y, [1,2,3]) here!
    map(def (x) ->
          y=x+1;
          return y
    , [1,2,3])
    
    # Right
    map((def (x) ->
          y=x+1;
          return y
    ), [1,2,3])
2 comments

A more Coconutty way to write this might be:

    [1, 2, 3] |> map$(def (x) -> y = x + 1; return y)
Which looks even less Pythonic.
Wow! That looks awful.