Function type -postfix

Stefan Schulz schulz at the-loom.de
Mon Feb 8 23:29:49 PST 2010


And I still wonder, why not using a clear, lambda-resembling syntax with 
mandatory brackets instead of a leading #. It would clearly separate 
nested function types and not require extra parens for throws 
declaration. Having optional parens that are mandatory in some cases 
does not sound convincing to me, despite that postfix syntax "reads the 
wrong direction" for the common Java developer's eye.

Examples within for comparison.

On 09.02.2010 02:14, Rémi Forax wrote:
> int->int

#int(int)   // draft
[int(int)]  // brackets

> int,int->int

#int(int,int)
[int(int,int)]

> I think this syntax will not generate conflicts despite the fact
> that ',' can be used in expressions if int->int.class and
> implementing a function type are not allowed.

#int(int).class // not sure
[int(int)].class

> Here parenthesis are mandatory, the rule is if you want to have
> a function type in a function type, parens are required:
> int, (int->int)->int

#int(int, #int(int))
[int(int, [int(int)])]

> this means that int ->  int ->  int is illegal and
> should be written:
> int ->  (int ->  int) or (int ->  int) ->  int

##int(int)(int) or #int(#int(int))
[[int(int)](int)] or [int([int(int)])]

> (int->int)[]

#int(int)[]
[int(int)][]

> int,int throws Exception->int

#int(int,int) (throws Exception)
[int(int,int) throws Exception]

> int, (int ->  int) throws Exception->int

#int(int, #int(int) (throws Exception))
[int(int, [int(int) throws Exception])]

> int, (int throws Exception ->  int) ->  int

#int(int, #int(int) (throws Exception))
[int(int, [int(int) throws Exception])]

"brackets" add one character per function type compared to "draft" but 
parenthesises a type, not only introduces one.

I only can think of one place of "visual" conflict, where an array is 
defined giving its size by a method:

Object[size(param)]

But maybe I overlooked something.

Stefan



More information about the lambda-dev mailing list