www.digitalmars.com         C & C++   DMDScript  

D - conflict between std.ctype.isdigit and std.stream.isdigit

reply Nicolas J. <Nicolas_member pathlink.com> writes:
Hello,

I am learning the D language, and so far, I must say I really like it.
I think it is very well designed and contrarily to some other comparable
languages it doesn't get in the way.

I am having a compilation problem though. In my main source, I wrote :

import std.stream;
import std.file;
import std.ctype;
import std.string;
import mintl.slist;

However, the compiler tells me :
..\src\phobos\std\stream.d(2912): function std.stream.isdigit conflicts with
std.ctype.isdigit at ...\src\phobos\std\ctype.d(32)

Is it a bug in the Phobos library, or did I forget something ?

A good problem report is a closed problem report.
Nov 11 2005
parent "Regan Heath" <regan netwin.co.nz> writes:
On Fri, 11 Nov 2005 13:00:40 +0000 (UTC), Nicolas J.  
<Nicolas_member pathlink.com> wrote:
 Hello,

 I am learning the D language, and so far, I must say I really like it.
 I think it is very well designed and contrarily to some other comparable
 languages it doesn't get in the way.

 I am having a compilation problem though. In my main source, I wrote :

 import std.stream;
 import std.file;
 import std.ctype;
 import std.string;
 import mintl.slist;

 However, the compiler tells me :
 ..\src\phobos\std\stream.d(2912): function std.stream.isdigit conflicts  
 with
 std.ctype.isdigit at ...\src\phobos\std\ctype.d(32)

 Is it a bug in the Phobos library, or did I forget something ?

 A good problem report is a closed problem report.

It's a little of both. It's a bug in that ideally std.stream should be using the std.ctype idigit function, this should be fixed but Walter is the only person who can do that. You've forgotten that D requires that you explicitly select the symbol you require in the instance of a collision, eg. import std.stdio; //for writef import std.stream; import std.ctype; alias std.ctype.isdigit isdigit; void main() { if (isdigit('9')) writef("is"); else writef("isnt"); } Without the 'alias' line the above causes: C:\Library\D\dmd\src\phobos\std\stream.d(2912): function std.stream.isdigit conflicts with std.ctype.isdigit at C:\Library\D\dmd\src\phobos\std\ctype.d(32) abug2.d: module abug2 std.stream.isdigit is private note the last part, this relates to a recent discussion of 'private' not hiding declarations. In that case it was classes, eg private class A {} In this case a function, std.stream contains: private bit isdigit(char c) .. despite being 'private' the symbol is still exported (if thats the right term) and still collides with the isdigit from std.ctype when really neither should occur, if it even needs to exist at all in std.stream. Regan
Nov 11 2005