Joint types inconsistency: Suggesting we use & instead of | for exceptions.

Stefan Schulz schulz at the-loom.de
Tue Feb 2 07:10:46 PST 2010


Am 02.02.2010 15:45, schrieb Reinier Zwitserloot:
> Well, without parens it would indeed be ambiguous, but as far as I can tell
> in the proposal, they are mandatory. Interesting dilemma - making parens
> mandatory is somewhat odd as they certainly aren't in method declarations
> and it makes the closure syntax rather paren heavy, but on the other hand
> without parens you're forced to use | or&  instead of the commas that throws
> clauses on method declarations use.

That's why I suggested thinking about a different syntax for function 
types. Another reason is the difficulty with higher-order functions, 
which might result in a hard to spot cascade of # and parens.

To repeat my (naive) suggestion, using brackets to identify a function type:

    FunctionType:
      '[' ResultType '(' TypeList_opt ')' Throws_opt ']'

e.g.:

    [[int(int,int)]() throws NoSuchOperation] operations = ...;

Hence, the part inside the brackets looks like a method signature but is 
in a closed format. As brackets are in use already and planned for 
collection literals, they might need context-sensitive parsing by a 
compiler.

Stefan


More information about the lambda-dev mailing list