Function types syntax
Neal Gafter
neal at gafter.com
Wed Jan 27 19:00:10 PST 2010
This variation on John Rose's proposed syntax has no problematic
interaction with arrays:
#(String -> float throws IOException)
This could be paired with the existing lambda syntax, or use the
matching lambda syntax
#(String s)->1.2
or even drop the # and write a lambda this way
(String s)->1.2
One could also leave the result type first, and move the throws clause
into the parens of the function type
#float(String throws IOException)
I think any of these are more readable than the current function type syntax
#float(String)(throws IOException)
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.
Cheers,
Neal
More information about the lambda-dev
mailing list