Typeless function arguments

dsimcha dsimcha at yahoo.com
Sat Oct 16 18:26:13 PDT 2010


== Quote from Tomek Sowiński (just at ask.me)'s article
> Funny thing:
> void foo(T)(t); // typeless argument
> If you don't instantiate the template, it actually compiles. Bug?

IMHO yes, this is a bug.  What you wrote is syntactic sugar for:

template foo(T) {
    void foo(t);
}

The rule with uninstantiated template bodies is that the code needs to be
syntactically correct, but not necessarily semantically correct (since the
semantics can only be fully analyzed on instantiation).  void foo(t) looks
syntactically incorrect.


More information about the Digitalmars-d mailing list