Function types syntax

Vladimir Kirichenko vladimir.kirichenko at gmail.com
Wed Jan 27 21:20:14 PST 2010


Neal Gafter wrote:

> Finally, if we take a page from the Groovy playbook, a lambda would be written
> 
>   {String s -> 1.2}
> 
> I think the most natural corresponding notation for a function type would be
> 
>   {String -> float throws IOException}
> 
> I know the latter work out syntactically without ambiguity, because
> that's been implemented in BGGA (but with a fat arrow instead of a
> thin arrow).  I don't know how they'd interact with collection
> literals.

As for me it's the best syntax among proposed within last time.
Especially looking at something like this:

#(String)->int (throws IOException, InterruptedException) stringLength;

stringLength = #(String s) int (throws IOException,
InterruptedException) length: {
  if (s == null) break length = -1;
  length = s.length();
  };

understanding that this is lambda, or looking at propositions of
suffixes, prefixes, hyerogliphs, etc.

This is an example syntax of list comprehension I've made for test using
BGGA:

for (int i : $$({int x => x * 2}, range(10), {int x => x < 5}))
System.out.println(i);


-- 
Best Regards,
Vladimir Kirichenko


More information about the lambda-dev mailing list