On Wednesday, 20 November 2013 at 07:52:30 UTC, Kenji Hara wrote:
With the lambda `(const x){ ... } `, the lambda parameter name
`x` is
parsed as TypeIdentifier.
Then semantic analysis handle the `x` as a lambda parameter
name that
requires type inference.
Similarly, with `void foo(const x) {}`, `x` is parsed as
TypeIdentifier.
However, semantic analysis will handle it as a Type name of
unnamed
function parameter.
The difference is in semantic analysis phase, but not in parsing
phase. Therefore the current Parameter grammar is correct.
Thank you, that's very interesting.
Do you use the word "function template" as meaning
function/delegate/lambda
literal which requires parameter type inference?
Yes, my mistake. Named function templates are of course not
affected by this issue.
I was not sure that the fun!int is legitimate usage.
I also ask this question. I think it may prove useful, and code
in the wild might be relying on it.
Therefore, I didn't mention about the 'template lambda'
semantics in documentation.
Right.
My guess is that it will either take many years before this
implementation-specific behaviour causes a problem, or
alternatively, before it is finally decided that the behaviour
should be elevated to become part of the specification. Either
way, it's probably not worth spending time on this problem right
now.