digitalmars.D - Is this a bug?
- Li Jie (35/35) Apr 10 2006 Code:
- Li Jie (2/11) Apr 11 2006 Modify "test1!(str[0])" to "test1!((str[0]))" can solve the problem.
- David L. Davis (54/68) Apr 11 2006 Li Jie, I don't think it's a bug. Below is some code I pull together tha...
- Li Jie (118/122) Apr 11 2006 Thanks David.
- David L. Davis (141/160) Apr 14 2006 Li Jie, I'm still not sure I see the problem...but it looks like your co...
- Li Jie (4/6) Apr 14 2006 Yes, it works find. But it must call like this:
- Thomas Kuehne (13/27) Apr 14 2006 -----BEGIN PGP SIGNED MESSAGE-----
- Walter Bright (3/25) Apr 15 2006 This is a known issue - a template argument that looks like a type is
Code: template test(char[] str) { const char test = test1!(str[0]); // #LINE 87 } template test1(char c) { const char test1 = c; } void main() { writefln(test!("a")); // #LINE 105 } Compile error(dmd 0.150 and dmd 0.153): testcom.d(87): str is used as a type testcom.d(87): template instance test1!(void[0]) does not match any template declaration testcom.d(87): cannot implicitly convert expression (test1!(void[0])) of type void to char testcom.d(105): template instance testcom.test!("a") error instantiating This is no error: template test(char[] str) { const char test = test1!(str); // #LINE 87 } template test1(char[] c) { const char test1 = c[0]; } void main() { writefln(test!("a")); // #LINE 105 } Thanks, - Li Jie
Apr 10 2006
In article <e1fa64$17nq$1 digitaldaemon.com>, Li Jie says...Code: template test(char[] str) { const char test = test1!(str[0]); // #LINE 87 } template test1(char c) { const char test1 = c; }Modify "test1!(str[0])" to "test1!((str[0]))" can solve the problem.
Apr 11 2006
In article <e1hm4c$l39$1 digitaldaemon.com>, Li Jie says...In article <e1fa64$17nq$1 digitaldaemon.com>, Li Jie says...Li Jie, I don't think it's a bug. Below is some code I pull together that I the code, they're only there for holding the formating). But I could be wrong...it has happen before. ;) Output: ---------- C:\dmd>dmd temptest1.d C:\dmd\bin\..\..\dm\bin\link.exe temptest1,,,user32+kernel32/noi; C:\dmd>temptest1 const char[] s = "ABC" Called testT(T="ABC" : char[]).value alias Test(in char[]) Called testT(T='A' : char).value alias Test(in char) Test(s[0])='A', Test(s)="ABC" C:\dmd> David L. ------------------------------------------------------------------- "Dare to reach for the Stars...Dare to Dream, Build, and Achieve!" ------------------------------------------------------------------- MKoD: http://spottedtiger.tripod.com/D_Language/D_Main_XP.htmlCode: template test(char[] str) { const char test = test1!(str[0]); // #LINE 87 } template test1(char c) { const char test1 = c; }Modify "test1!(str[0])" to "test1!((str[0]))" can solve the problem.
Apr 11 2006
In article <e1hqph$q8g$1 digitaldaemon.com>, David L. Davis says...Li Jie, I don't think it's a bug. Below is some code I pull together that I the code, they're only there for holding the formating). But I could be wrong...it has happen before. ;)Thanks David. Your code is function call, my code is value-parameter template. I want to write a "__uuidof" template, like VC++. A simple implemention is: 0x00, 0x00, 0x00, 0x46]}; It's too long. I think the D-template can calculate it from a string, at compile-time. I write some code: IIDFromStr!("00000000-0000-0000-C000-000000000046"); and {0x00000000, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; I like the first.
Apr 11 2006
In article <e1hvg6$vqj$1 digitaldaemon.com>, Li Jie says...In article <e1hqph$q8g$1 digitaldaemon.com>, David L. Davis says...Li Jie, I'm still not sure I see the problem...but it looks like your code should compile and work fine in D. (I made a few changes, but nothing major) Output: C:\dmd>dmd uui.d ole32.lib uuid.lib C:\dmd\bin\..\..\dm\bin\link.exe uui,,,ole32.lib+uuid.lib+user32+kernel32/noi; C:\dmd>uui {00000000, 0000, 0000, [192,0,0,0,0,0,0,70]} toString(iu)={00000000-0000-0000-C000-000000000046} IIDFromStr!("00000000-0000-0000-C000-000000000046")="{00000000-0000-0000-C000-000000000046}" C:\dmd> David L. ------------------------------------------------------------------- "Dare to reach for the Stars...Dare to Dream, Build, and Achieve!" ------------------------------------------------------------------- MKoD: http://spottedtiger.tripod.com/D_Language/D_Main_XP.htmlLi Jie, I don't think it's a bug. Below is some code I pull together that I the code, they're only there for holding the formating). But I could be wrong...it has happen before. ;)Thanks David. Your code is function call, my code is value-parameter template. I want to write a "__uuidof" template, like VC++. A simple implemention is: 0x00, 0x00, 0x00, 0x46]}; It's too long. IIDFromStr!("00000000-0000-0000-C000-000000000046"); and {0x00000000, 0x0000, 0x0000, [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]}; I like the first.
Apr 14 2006
In article <e1ooai$2tp4$1 digitaldaemon.com>, David L. Davis says...Li Jie, I'm still not sure I see the problem...but it looks like your code should compile and work fine in D. (I made a few changes, but nothing major)Yes, it works find. But it must call like this:
Apr 14 2006
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Li Jie schrieb am 2006-04-12:In article <e1fa64$17nq$1 digitaldaemon.com>, Li Jie says...Added to DStress as http://dstress.kuehne.cn/compile/t/template_35_A.d http://dstress.kuehne.cn/compile/t/template_35_B.d http://dstress.kuehne.cn/compile/t/template_35_C.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFEP4Ro3w+/yD4P9tIRAsciAJ92mhtJjmFeDZ+1QhdPuG7w8za1rACfU6Z1 HaBN+ofDk3QWW73XnFruEyY= =8E8Q -----END PGP SIGNATURE-----Code: template test(char[] str) { const char test = test1!(str[0]); // #LINE 87 } template test1(char c) { const char test1 = c; }Modify "test1!(str[0])" to "test1!((str[0]))" can solve the problem.
Apr 14 2006
Thomas Kuehne wrote:-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Li Jie schrieb am 2006-04-12:This is a known issue - a template argument that looks like a type is treated as a type.In article <e1fa64$17nq$1 digitaldaemon.com>, Li Jie says...Added to DStress as http://dstress.kuehne.cn/compile/t/template_35_A.d http://dstress.kuehne.cn/compile/t/template_35_B.d http://dstress.kuehne.cn/compile/t/template_35_C.dCode: template test(char[] str) { const char test = test1!(str[0]); // #LINE 87 } template test1(char c) { const char test1 = c; }Modify "test1!(str[0])" to "test1!((str[0]))" can solve the problem.
Apr 15 2006