digitalmars.D - Typeless function arguments
- Tomek =?UTF-8?B?U293acWEc2tp?= (5/5) Oct 16 2010 Funny thing:
- dsimcha (9/12) Oct 16 2010 IMHO yes, this is a bug. What you wrote is syntactic sugar for:
- Rainer Deyke (5/9) Oct 16 2010 I think 'void foo(t)' is syntactically correct. You can't know that 't'
Funny thing: void foo(T)(t); // typeless argument If you don't instantiate the template, it actually compiles. Bug? -- Tomek
Oct 16 2010
== Quote from Tomek SowiĆski (just ask.me)'s articleFunny 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.
Oct 16 2010
On 10/16/2010 19:26, dsimcha wrote: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.I think 'void foo(t)' is syntactically correct. You can't know that 't' isn't the name of a type without semantic analysis. -- Rainer Deyke - rainerd eldwood.com
Oct 16 2010