[Issue 2616] New: Undocumented behaviour: part-explicit, part-implicit instantiations of function templates are accepted
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Jan 25 14:10:37 PST 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2616
Summary: Undocumented behaviour: part-explicit, part-implicit
instantiations of function templates are accepted
Product: D
Version: 1.039
Platform: PC
URL: http://www.digitalmars.com/d/1.0/template.html
OS/Version: Windows
Status: NEW
Keywords: accepts-invalid, spec
Severity: normal
Priority: P2
Component: www.digitalmars.com
AssignedTo: bugzilla at digitalmars.com
ReportedBy: smjg at iname.com
OtherBugsDependingO 2599
nThis:
`Function templates can be explicitly instantiated with a
!(TemplateArgumentList):
writefln("The square of %s is %s", 3, Square!(int)(3));
or implicitly, where the TemplateArgumentList is deduced from the types of the
function arguments:
writefln("The square of %s is %s", 3, Square(3)); // T is deduced to be int`
It's just come to my attention that the compiler allows an in-between case that
isn't covered by the current documentation, either for D1 or for D2.
----------
import std.stdio;
void fun(T1, T2)(T2 x) {
pragma(msg, T1.stringof);
writefln(x);
}
void main() {
fun!(int)("hello!");
}
----------
C:\Users\Stewart\Documents\Programming\D\Tests>dmd template_partial.d
int
C:\Users\Stewart\Documents\Programming\D\Tests>template_partial
hello!
----------
What is T2? The template instantiation is explicit in form, but doesn't match
the parameter list with which the template is declared. Neither is T2 deduced
from the given template arguments. Neither is it IFTI as currently documented,
since a template parameter list has been given. Rather, the template
instantiation is of an undocumented mix of the two styles.
Issue 2599 comment 6 implies that this feature is intended, but you forgot to
document it.
--
More information about the Digitalmars-d-bugs
mailing list