Syntax changes
    Zdenek Tronicek 
    tronicek at fel.cvut.cz
       
    Mon Jul 21 08:44:23 PDT 2008
    
    
  
Hi,
my opinion is probably biased because I got used to the current  
syntax. But if I consider all the alternatives, the Groovy syntax  
seems the best for me:
{ int, int -> int } p = { int x, int y -> x + y };
As for the argument that the return type used to be written before the  
parameter types, I must admit that the syntax is unusual in this  
sense. But how the syntax would have looked like if we used the  
"function" syntax? For example:
int (int, int) p = int (int x, int y) { x + y };
Although this is still acceptable, once there is one or more  
exceptions thrown, it is not easy to read:
void (long) throws InterruptedException wait =
   void (long millis) throws InterruptedException { Thread.sleep(millis); }
And a really mess will be when a closure returns or accepts another  
closure. In addition, closures are different to methods and this  
justifies a different syntax.
As for the curly braces, I like them more than parenthesis because  
closure is a block of code.
Z.
-- 
Zdenek Tronicek
Department of Computer Science and Engineering
Prague                   tel: +420 2 2435 7410
http://cs.felk.cvut.cz/~tronicek
    
    
More information about the closures-dev
mailing list