[Issue 1661] Not possible to specialize on template with integer parameter
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Feb 29 12:07:46 PST 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1661
------- Comment #8 from onlystupidspamhere at yahoo.se 2008-02-29 14:07 -------
(In reply to comment #7)
> Am I right in thinking this is the actual syntax that should work?:
>
> struct test_specialize(T : Number!(N), int N)
> {
> void talk() { writefln("Ooh special - NUMBER N\n"); }
> }
> test_specialize!(Number!(5)) x;
I would expect it to be. But this issue isn't limited to int parameters. Other
primitive types don't work either. Also, more complex pattern matching fails:
struct a(S, T) {}
struct b(T : a!(N, a!(N, int)), N) {}
alias a!(float,int) A;
alias a!(float, A) B;
b!(B, float) x; // fails, and so does b!(B) x;
foo.d:5: template instance b!(a!(float,a!(float,int) ) ,float) does not match
any template declaration
foo.d:5: Error: b!(a!(float,a!(float,int) ) ,float) is used as a type
foo.d:5: variable foo.x voids have no value
This is a bit problematic for someone creating a new compiler for D since it's
not really clear how complex types the language should be able to match. The
specification only mentions (http://www.digitalmars.com/d/1.0/template.html)
that they should be types. But that's a bit confusing since Number!(N) isn't a
valid type. You can't e.g. alias it, there's no parametrized alias syntax:
alias IntNPair N = tuple!(int, N);
One could instantiate the code above with Number(float) or Number!(float), and
get tuple!(int, float).
--
More information about the Digitalmars-d-bugs
mailing list