Syntax...

Jakob Praher jp at hapra.at
Sat Nov 21 05:21:41 PST 2009


Hi all,

why do we need something like #, ^ for defining the function type at all?

IMHO in Java the identifier space has no function type already, since 
this is a novelity, compared with C/C++ block/lambda concepts build on 
top of existing function pointers. This implies the opportunity to 
introduce a clean function/lambda type identifier, which would also 
leverage a common representation.

I would not introduce new operators like => or # if it is not absolutely 
necessary. Java style would be to use something more readable IMHO.
Introducing closures with new would have the charme of beeing similar to 
anonymous inner class instantiation.

e.g.

File f = new File(".");
File[] textfiles = f.listFiles( new FileFilter() {
public boolean accept(File pathname) {
    return pathname.endswith(".txt");
});

which would be translated to:

File f = new FIle(".");
File[] textfiles = f.listFiles( new (File pathname) { 
pathname.endswith("txt") } );

"new" is surely debatable and one could think about omitting it.... Then 
one could also think about more scala like:

f.listFiles (File pathanme) {
       return pathname.endswith("txt") ;
}

If the only argument to a method is a closure, one could leave out the 
parenthesis and it looks much more readable IMHO.
Surely this would be a bigger burdon to the compiler, but even with the 
parenthesis around it would be readable, no?

f.listFiles( (File pathanme) {
       return pathname.endswith("txt") ;
});

Just my 2 cents.
-- Jakob

tronicek at fit.cvut.cz schrieb:
> Hi,
>
> I do not have any strong argument neither for # nor for ^ but I,
> personally, prefer # (for both, function types and lambdas). Why?
> ^ is an operator and thus # seems to be more readable.
> In C, the situation is different: # is a preprocessor thing and so ^ is
> probably better there.
>
> Zdenek
>   



More information about the closures-dev mailing list