digitalmars.D.learn - std.traits and std.string incompatible ?
- Wilfried Kirschenmann (12/12) Mar 08 2011 Hi,
- =?UTF-8?B?QWxpIMOHZWhyZWxp?= (8/20) Mar 08 2011 isNumeric is a template. You are supposed to give it a type:
- Nick Sabalausky (18/43) Mar 08 2011 No, there's an isNumeric in *both* std.traits and std.string. The one in...
- Jonathan M Davis (11/66) Mar 08 2011 ng
- Jonathan M Davis (3/65) Mar 08 2011 Reported: http://d.puremagic.com/issues/show_bug.cgi?id=3D5721
Hi, When running the following file: import std.string, std.traits; void main(string[] args){ bool test = isNumeric(args[0]); } I get the error : dmd2/linux/bin/../../src/phobos/std/traits.d(2576): Error: template std.traits.isNumeric(T) is not a function template Is this a bug or is there something deprecated ? Wilfried
Mar 08 2011
On 03/08/2011 08:24 AM, Wilfried Kirschenmann wrote:Hi, When running the following file: import std.string, std.traits; void main(string[] args){ bool test = isNumeric(args[0]); } I get the error : dmd2/linux/bin/../../src/phobos/std/traits.d(2576): Error: template std.traits.isNumeric(T) is not a function template Is this a bug or is there something deprecated ? WilfriedisNumeric is a template. You are supposed to give it a type: if (isNumeric!SomeType) or at compile time: static if (isNumeric!SomeType) It doesn't work with string values. Although unnecessary, you could do this: bool test = isNumeric!(typeof(args[0])); Ali
Mar 08 2011
"Ali Çehreli" <acehreli yahoo.com> wrote in message news:il5pge$nrr$1 digitalmars.com...On 03/08/2011 08:24 AM, Wilfried Kirschenmann wrote:No, there's an isNumeric in *both* std.traits and std.string. The one in std.traits is a template that takes a type. But the one in std.string is a function that takes a string and checks if the value of the string is numeric. I'm on the latest D2 (2.052) and I just tried the example and got the same result. But if I *only* import std.string then it works. So it sounds like a bug: I forget the exact details of the rules involving overloading across modules, but one of two things should happen with the original example: A. It should know that you meant std.string.isNumeric because of how you're calling it. or: B. It should complain that there's an ambiguity between std.string.isNumeric and std.traits.isNumeric and require you to disambiguate with either "std.traits." or "std.string." I'm not sure which of those it's supposed to do, but it's clearly not doing either, so I'd file it as a bug: http://d.puremagic.com/issues/Hi, When running the following file: import std.string, std.traits; void main(string[] args){ bool test = isNumeric(args[0]); } I get the error : dmd2/linux/bin/../../src/phobos/std/traits.d(2576): Error: template std.traits.isNumeric(T) is not a function template Is this a bug or is there something deprecated ? WilfriedisNumeric is a template. You are supposed to give it a type: if (isNumeric!SomeType) or at compile time: static if (isNumeric!SomeType) It doesn't work with string values. Although unnecessary, you could do this: bool test = isNumeric!(typeof(args[0]));
Mar 08 2011
On Tuesday, March 08, 2011 13:24:44 Nick Sabalausky wrote:"Ali =C7ehreli" <acehreli yahoo.com> wrote in message news:il5pge$nrr$1 digitalmars.com... =20reOn 03/08/2011 08:24 AM, Wilfried Kirschenmann wrote:=20 No, there's an isNumeric in *both* std.traits and std.string. The one in std.traits is a template that takes a type. But the one in std.string is a function that takes a string and checks if the value of the string is numeric. =20 I'm on the latest D2 (2.052) and I just tried the example and got the same result. But if I *only* import std.string then it works. So it sounds like a bug: I forget the exact details of the rules involving overloading across modules, but one of two things should happen with the original example: =20 A. It should know that you meant std.string.isNumeric because of how you'=Hi, =20 When running the following file: =20 import std.string, std.traits; void main(string[] args){ bool test =3D isNumeric(args[0]); } =20 I get the error : dmd2/linux/bin/../../src/phobos/std/traits.d(2576): Error: template std.traits.isNumeric(T) is not a function template =20 Is this a bug or is there something deprecated ? =20 Wilfried=20 isNumeric is a template. You are supposed to give it a type: if (isNumeric!SomeType) =20 or at compile time: static if (isNumeric!SomeType) =20 It doesn't work with string values. Although unnecessary, you could do =20 this: bool test =3D isNumeric!(typeof(args[0]));calling it. =20 or: =20 B. It should complain that there's an ambiguity between std.string.isNumeric and std.traits.isNumeric and require you to disambiguate with either "std.traits." or "std.string." =20 I'm not sure which of those it's supposed to do, but it's clearly not doi=ngeither, so I'd file it as a bug: http://d.puremagic.com/issues/isNumeric in std.string is a function. In std.traits, it's an eponymous=20 template. The eponymous template should require the !. There's no function = to=20 feed the argument to. There shouldn't be any ambiguity of any kind. Overloa= d set=20 rules and whatnot should have nothing to do with this. This is definitely a= bug. =2D Jonathan M Davis
Mar 08 2011
On Tuesday, March 08, 2011 16:11:09 Jonathan M Davis wrote:On Tuesday, March 08, 2011 13:24:44 Nick Sabalausky wrote:Reported: http://d.puremagic.com/issues/show_bug.cgi?id=3D5721 =2D Jonathan M Davis"Ali =C7ehreli" <acehreli yahoo.com> wrote in message news:il5pge$nrr$1 digitalmars.com... =20=20 isNumeric in std.string is a function. In std.traits, it's an eponymous template. The eponymous template should require the !. There's no function to feed the argument to. There shouldn't be any ambiguity of any kind. Overload set rules and whatnot should have nothing to do with this. This is definitely a bug.On 03/08/2011 08:24 AM, Wilfried Kirschenmann wrote:=20 No, there's an isNumeric in *both* std.traits and std.string. The one in std.traits is a template that takes a type. But the one in std.string is a function that takes a string and checks if the value of the string is numeric. =20 I'm on the latest D2 (2.052) and I just tried the example and got the same result. But if I *only* import std.string then it works. So it sounds like a bug: I forget the exact details of the rules involving overloading across modules, but one of two things should happen with the original example: =20 A. It should know that you meant std.string.isNumeric because of how you're calling it. =20 or: =20 B. It should complain that there's an ambiguity between std.string.isNumeric and std.traits.isNumeric and require you to disambiguate with either "std.traits." or "std.string." =20 I'm not sure which of those it's supposed to do, but it's clearly not doing either, so I'd file it as a bug: http://d.puremagic.com/issues/Hi, =20 When running the following file: =20 import std.string, std.traits; void main(string[] args){ bool test =3D isNumeric(args[0]); } =20 I get the error : dmd2/linux/bin/../../src/phobos/std/traits.d(2576): Error: template std.traits.isNumeric(T) is not a function template =20 Is this a bug or is there something deprecated ? =20 Wilfried=20 isNumeric is a template. You are supposed to give it a type: if (isNumeric!SomeType) =20 or at compile time: static if (isNumeric!SomeType) =20 It doesn't work with string values. Although unnecessary, you could do =20 this: bool test =3D isNumeric!(typeof(args[0]));
Mar 08 2011