www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - std.traits and std.string incompatible ?

reply Wilfried Kirschenmann <wilfried.kirschenmann gmail.com> writes:
Hi,

When running the following file:

#!../dmd2/linux/bin/rdmd -unittest
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
next sibling parent reply =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 03/08/2011 08:24 AM, Wilfried Kirschenmann wrote:
 Hi,

 When running the following file:

 #!../dmd2/linux/bin/rdmd -unittest
 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

isNumeric 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
parent "Nick Sabalausky" <a a.a> writes:
"Ali Çehreli" <acehreli yahoo.com> wrote in message 
news:il5pge$nrr$1 digitalmars.com...
 On 03/08/2011 08:24 AM, Wilfried Kirschenmann wrote:
 Hi,

 When running the following file:

 #!../dmd2/linux/bin/rdmd -unittest
 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

isNumeric 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]));

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/
Mar 08 2011
prev sibling next sibling parent Jonathan M Davis <jmdavisProg gmx.com> writes:
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...
=20
 On 03/08/2011 08:24 AM, Wilfried Kirschenmann wrote:
 Hi,
=20
 When running the following file:
=20
 #!../dmd2/linux/bin/rdmd -unittest
 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

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]));

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'=

 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=

 either, 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
prev sibling parent Jonathan M Davis <jmdavisProg gmx.com> writes:
On Tuesday, March 08, 2011 16:11:09 Jonathan M Davis wrote:
 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...
=20
 On 03/08/2011 08:24 AM, Wilfried Kirschenmann wrote:
 Hi,
=20
 When running the following file:
=20
 #!../dmd2/linux/bin/rdmd -unittest
 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

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]));

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/

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.

Reported: http://d.puremagic.com/issues/show_bug.cgi?id=3D5721 =2D Jonathan M Davis
Mar 08 2011