Monday, December 1, 2008

I just started using closure and can't stop thinking or talking about it!

One thing that I am not very happy about is the control abstraction.

A method that accepts an unrestricted closure as the last argument can be called using the control invocation syntax.

Why should we have this restriction that only the last argument can be called using the control invocation syntax?


It will be nice to have any number of arguments to be like that. Ex.



public static void DoInSequence( {==>void} first, {==>void} second) {
first.invoke();
second.invoke();
}



right now we can do ..



DoInSequence(
{ =>
System.out.println("3.First");
})
{
System.out.println("3.Second");
}



but not..



DoInSequence()
{
System.out.println("3.First");
}

{
System.out.println("3.Second");
}