September 22, 2005 Char[] suffix 'c' operates differently than cast(char[]) | ||||
---|---|---|---|---|
| ||||
// charsuffix.d // WinXP SP2 / dmd v0.132 private import std.stdio; void test(in char[] s) { writefln("bool test(in char[] s)"); } void test(...) { writefln("bool test(...)"); } int main() { test("string"); // Calls void test(in char[] s) test(128U); // Calls void test(...) test(cast(char[])"string"); // Calls void test(in char[] s) /* * charsuffix.d(29): function charsuffix.test called with argument types: * (char[6]) * matches both: * charsuffix.test(char[]) * and: * charsuffix.test(...) */ //test("string"c); return 0; } It appears that a casted string literal is handed differently then a string literal using the new string suffixes, shouldn't these work exact same way? David L. ------------------------------------------------------------------- "Dare to reach for the Stars...Dare to Dream, Build, and Achieve!" ------------------------------------------------------------------- MKoD: http://spottedtiger.tripod.com/D_Language/D_Main_XP.html |
September 25, 2005 Re: Char[] suffix 'c' operates differently than cast(char[]) | ||||
---|---|---|---|---|
| ||||
Posted in reply to David L. Davis Attachments: | David L. Davis schrieb: > // charsuffix.d > // WinXP SP2 / dmd v0.132 > private import std.stdio; > > void test(in char[] s) > { > writefln("bool test(in char[] s)"); > } > > void test(...) > { > writefln("bool test(...)"); > } > > int main() > { > test("string"); // Calls void test(in char[] s) > test(128U); // Calls void test(...) > test(cast(char[])"string"); // Calls void test(in char[] s) > > /* > * charsuffix.d(29): function charsuffix.test called with argument types: > * (char[6]) > * matches both: > * charsuffix.test(char[]) > * and: > * charsuffix.test(...) > */ > //test("string"c); > return 0; > } > > It appears that a casted string literal is handed differently then a string literal using the new string suffixes, shouldn't these work exact same way? > > David L. Added to DStress as http://dstress.kuehne.cn/run/v/variadic_argument_07_A.d http://dstress.kuehne.cn/run/v/variadic_argument_07_B.d http://dstress.kuehne.cn/run/v/variadic_argument_07_C.d http://dstress.kuehne.cn/run/v/variadic_argument_07_D.d Thomas |
Copyright © 1999-2021 by the D Language Foundation