Implicit instantiation of parameterless templates
Piotr Szturmaj
bncrbme at jadamspam.pl
Fri Oct 5 04:49:40 PDT 2012
Java and C# with their generics can do the following:
class List { }
class List<T> { }
List list = new List();
List<int> intList = new List<int>();
In D similar code can't work because we can't have both a type and a
template with the same name. So this code must be rewritten to:
class List(T = Variant) { }
List!() list = new List!();
List!int intList = new List!int;
When template name is used as a type and it can be instantiated with no
parameters it could be automatically rewritten to List!() by the
compiler. That code would then look like this:
List list = new List;
List!int intList = new List!int;
The question is... is it possible to change D's behaviour to avoid
awkward !() template parameters _without_ breaking backward compatibility?
More information about the Digitalmars-d
mailing list