reuse 'do' keyword instead of hash sign (#)

Marcin Wiśnicki mwisnicki at gmail.com
Sun Aug 22 16:17:26 PDT 2010


Would it be possible to change the clumsy '#' operator to 'do' keyword ?
I.e.:

  do()(5)
  do(){return 5;}
  do(int x, int y) { if (x>y) return x; else return y; }
  button.onClick(do(Event e) { println("button clicked"); });

I find it more readable, OTOH using special characters feels a bit
like perl (noisy), especially when combining multiple lambdas.
It event makes sense if you parse it as english.

Don't know what to do with anonymous function type but it could remain as '#'.

Pros:
 - more readable
 - makes sense
 - like '#' needs only 1-lookahead to disambiguate from do-while '(' vs '{' [1]
 - did I mention it's more readable ?

Cons:
 - none (that I could think of)

[1] Automatic Resource Management from Coins wanted to use 'do' but I
see they have switched to 'try' so no problem there.

PS. Please CC me since I'm not subscribed, thanks.


More information about the lambda-dev mailing list