www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - template class name unconsistent behavior

reply "timotheecour" <thelastmammoth gmail.com> writes:
Is that a bug?

The code below returns:

"main.A!(double).A"

if we uncomment "auto c=make!A(1.0);", we get:

"main.a!(double).A"

----
module main;
import std.stdio;
class A(T){
	T x;
	this(T x){this.x=x;}
}
auto make(alias a,T...)(T args){
	return new a!T(args);
}
void main(){
	//auto c=make!A(1.0);
	auto b=new A!double(1.0);
	writeln(typeid(b));
}
----
Sep 16 2012
next sibling parent "timotheecour" <thelastmammoth gmail.com> writes:
If this behavior is not a bug, I wonder what's the rationale, but 
also, how can we have such a "make" function that doesn't mess up 
the template class name depending on the order of which is used 
first (the make!T variant or the new A!T) ?
Sep 16 2012
prev sibling next sibling parent =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 09/16/2012 05:08 PM, timotheecour wrote:
 Is that a bug?

 The code below returns:

 "main.A!(double).A"

 if we uncomment "auto c=make!A(1.0);", we get:

 "main.a!(double).A"

 ----
 module main;
 import std.stdio;
 class A(T){
 T x;
 this(T x){this.x=x;}
 }
 auto make(alias a,T...)(T args){
 return new a!T(args);
 }
 void main(){
 //auto c=make!A(1.0);
 auto b=new A!double(1.0);
 writeln(typeid(b));
 }
 ----

This bug must be related: http://d.puremagic.com/issues/show_bug.cgi?id=8579 Other bugs that are linked from that one mention an internal hash table. Apparently different objects resolve to the same key, and the value of the first key gets used from that hash table. I don't know whether Kenji Hara's fix for the bug above also fixed this issue. I say, open a bug anyway. Ali
Sep 16 2012
prev sibling parent "timotheecour" <thelastmammoth gmail.com> writes:
done: http://d.puremagic.com/issues/show_bug.cgi?id=8674
Sep 16 2012