www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - module private symbols collide?

reply Buchan <kbuchan xtra.co.nz> writes:
Output is:
D:\dmd\bin\..\src\phobos\std\stream.d(2132): function isdigit conflicts  
with ctype.isdigit at D:\dmd\bin\..\src\phobos\std\ctype.d(14)
D:\Coding\magiccards\main.d: module main stream.isdigit is private

in stream.d:
private bit isdigit(char c) {...}

in ctype.d:
int isdigit(dchar c)  {...}

why are these colliding? if I import both, should I not be able to use  
isdigit from ctype without specifing the full path?

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
Oct 15 2004
next sibling parent reply Regan Heath <regan netwin.co.nz> writes:
On Sat, 16 Oct 2004 04:06:54 +1300, Buchan <kbuchan xtra.co.nz> wrote:
 Output is:
 D:\dmd\bin\..\src\phobos\std\stream.d(2132): function isdigit conflicts  
 with ctype.isdigit at D:\dmd\bin\..\src\phobos\std\ctype.d(14)
 D:\Coding\magiccards\main.d: module main stream.isdigit is private

 in stream.d:
 private bit isdigit(char c) {...}

 in ctype.d:
 int isdigit(dchar c)  {...}

 why are these colliding? if I import both, should I not be able to use  
 isdigit from ctype without specifing the full path?
The solution is to use: alias std.ctype.isdigit isdigit; or to use the full path i.e. if (std.ctype.isdigit(5)) {} to tell the compiler which 'isdigit' you mean. The problem. as I understand it, is that the compiler cannot choose between the 'std.ctype' or 'std.stream' isdigit method, because it might guess wrong. You have to explicitly tell it which one you mean. Regan -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Oct 17 2004
parent reply Buchan <kbuchan xtra.co.nz> writes:
On Mon, 18 Oct 2004 10:21:29 +1300, Regan Heath <regan netwin.co.nz> wrote:

 On Sat, 16 Oct 2004 04:06:54 +1300, Buchan <kbuchan xtra.co.nz> wrote:
 Output is:
 D:\dmd\bin\..\src\phobos\std\stream.d(2132): function isdigit  
 conflicts  with ctype.isdigit at  
 D:\dmd\bin\..\src\phobos\std\ctype.d(14)
 D:\Coding\magiccards\main.d: module main stream.isdigit is private

 in stream.d:
 private bit isdigit(char c) {...}

 in ctype.d:
 int isdigit(dchar c)  {...}

 why are these colliding? if I import both, should I not be able to use   
 isdigit from ctype without specifing the full path?
The solution is to use: alias std.ctype.isdigit isdigit; or to use the full path i.e. if (std.ctype.isdigit(5)) {} to tell the compiler which 'isdigit' you mean. The problem. as I understand it, is that the compiler cannot choose between the 'std.ctype' or 'std.stream' isdigit method, because it might guess wrong. You have to explicitly tell it which one you mean. Regan
Yeah, if they are both public. The compiler SHOULD be smart enough to not try to call a private function, or am I missing something? -- Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
Oct 17 2004
parent Regan Heath <regan netwin.co.nz> writes:
On Mon, 18 Oct 2004 18:41:59 +1300, Buchan <kbuchan xtra.co.nz> wrote:
 On Mon, 18 Oct 2004 10:21:29 +1300, Regan Heath <regan netwin.co.nz> 
 wrote:

 On Sat, 16 Oct 2004 04:06:54 +1300, Buchan <kbuchan xtra.co.nz> wrote:
 Output is:
 D:\dmd\bin\..\src\phobos\std\stream.d(2132): function isdigit  
 conflicts  with ctype.isdigit at  
 D:\dmd\bin\..\src\phobos\std\ctype.d(14)
 D:\Coding\magiccards\main.d: module main stream.isdigit is private

 in stream.d:
 private bit isdigit(char c) {...}

 in ctype.d:
 int isdigit(dchar c)  {...}

 why are these colliding? if I import both, should I not be able to 
 use   isdigit from ctype without specifing the full path?
The solution is to use: alias std.ctype.isdigit isdigit; or to use the full path i.e. if (std.ctype.isdigit(5)) {} to tell the compiler which 'isdigit' you mean. The problem. as I understand it, is that the compiler cannot choose between the 'std.ctype' or 'std.stream' isdigit method, because it might guess wrong. You have to explicitly tell it which one you mean. Regan
Yeah, if they are both public. The compiler SHOULD be smart enough to not try to call a private function, or am I missing something?
Good point. From my experiments it seems the import order also matters, if you import the private one first then you also get an error about the function being private. Here is a test case. --[inc.d]-- module inc; import prifn; import pubfn; void main() { fn('a'); } --[prifn.d]-- module prifn; private bit fn(char c) { return false; } --[pubfn.f]-- module pubfn; bit fn(char c) { return false; } The above gives the following errors: prifn.d(3): function fn conflicts with pubfn.fn at pubfn.d(3) inc.d: module inc prifn.fn is private changing the import order in inc.d gives only: pubfn.d(3): function fn conflicts with prifn.fn at prifn.d(3) In addition to the above bugs/problems the std library needs a tidy up. std.stream should be using std.ctypes functions isdigit etc and std.ctypes isdigit should return bool (AKA bit) and not int. Regan -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Oct 18 2004
prev sibling parent reply Sean Kelly <sean f4.ca> writes:
In article <opsfw2xskk44buww simon.mshome.net>, Buchan says...
Output is:
D:\dmd\bin\..\src\phobos\std\stream.d(2132): function isdigit conflicts  
with ctype.isdigit at D:\dmd\bin\..\src\phobos\std\ctype.d(14)
D:\Coding\magiccards\main.d: module main stream.isdigit is private

in stream.d:
private bit isdigit(char c) {...}

in ctype.d:
int isdigit(dchar c)  {...}

why are these colliding? if I import both, should I not be able to use  
isdigit from ctype without specifing the full path?
I bumped into this bug today when experimenting with restructuring Phobos. I sincerely hope this is fixed soon, as there's no easy workaround for it from the client side. Sean
Oct 20 2004
parent larrycowan <larrycowan_member pathlink.com> writes:
In article <cl66rd$3s5$1 digitaldaemon.com>, Sean Kelly says...
In article <opsfw2xskk44buww simon.mshome.net>, Buchan says...
Output is:
D:\dmd\bin\..\src\phobos\std\stream.d(2132): function isdigit conflicts  
with ctype.isdigit at D:\dmd\bin\..\src\phobos\std\ctype.d(14)
D:\Coding\magiccards\main.d: module main stream.isdigit is private

in stream.d:
private bit isdigit(char c) {...}

in ctype.d:
int isdigit(dchar c)  {...}

why are these colliding? if I import both, should I not be able to use  
isdigit from ctype without specifing the full path?
I bumped into this bug today when experimenting with restructuring Phobos. I sincerely hope this is fixed soon, as there's no easy workaround for it from the client side. Sean
Two things are involved here. The error shown is in streams which has a private definition and is pulling in the public one as a conflict. This needs to be dealt with. It could make the use of other peoples libraries and even the phobos ones problematic to say the least. The language needs a public reservation system for function names? Every reference in every library needs full specification to protect it from what it may be used with? If as is implied, a call to isdigit() in the main(), errors out with the same conflict, that is wrong - in main, the private one shouldn't even be seen, or "private" is useless when used in this way. Both problems may be correctable at once if, as is likely, the answer is that the private marking in streams is being somehow ignored or lost.
Oct 31 2004