On 08/02/2013 11:20 PM, SteveGuo wrote:

I think it could get pretty confusing. I.e.:

module foo;

struct a { }
struct b { }

----
module bar;

import foo;

auto Add(a, b) { } // [1]

----
[1] Here the unsuspecting programmer thinks he's writing a template
function, not knowing that one module he's importing actually
specifies 'a' and 'b' as types, which makes his Add a regular function
taking unnamed variables of types 'a' and 'b'.

We know that normal function parameter declaration is the form of
"PARAMTYPE param"
but in this declaration "auto Add(a, b) { }" the parameter do not have
PARAMTYPE, compiler can detect this issue, so, the compiler knows a or b
is not a type, it treats them as template

Note that currently this is parsed as having _only_ PARAMTYPE.

Reply via email to