Templated struct doesn't need the parameterized type in return type definitions?

David Nadlinger see at klickverbot.at
Tue Mar 8 12:12:39 PST 2011


On 3/8/11 8:20 PM, spir wrote:
> […] Yet another
> syntactic special-case for special cases in the language. In this case,
> there are even 3 ways to write the same thing: […]

I don't quite get how you think this would be a syntactic special case. 
As Steve pointed out, »class Foo(T) {}« is merely syntax sugar for 
»template Foo(T) { class Foo{} }«, and because of this, it would rather 
be a special case *not* to allow referring to Foo using just that name. 
When considering this, don't forget that templates in D are little more 
than parametrized, named scopes.

I guess you could argue that »class Foo(T)« as a shorthand is an 
unnecessary special case, but I very much prefer the benefit in brevity 
here…

David


More information about the Digitalmars-d-learn mailing list