Thread overview
std.traits and std.string incompatible ?
Mar 08, 2011
Ali Çehreli
Mar 08, 2011
Nick Sabalausky
Mar 09, 2011
Jonathan M Davis
Mar 09, 2011
Jonathan M Davis
March 08, 2011
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
March 08, 2011
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
March 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:
> > 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/



March 09, 2011
On Tuesday, March 08, 2011 13:24:44 Nick Sabalausky wrote:
> "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/

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.

- Jonathan M Davis
March 09, 2011
On Tuesday, March 08, 2011 16:11:09 Jonathan M Davis wrote:
> On Tuesday, March 08, 2011 13:24:44 Nick Sabalausky wrote:
> > "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/
> 
> 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=5721

- Jonathan M Davis