Questions about D

FireLancer Dragon_Fly1102 at Hotmail.com
Thu May 22 14:02:14 PDT 2008


Robert Fraser Wrote:

> FireLancer wrote:
> > Ive been learning c++ and was wondering if I should move over to D or not but theres a few details I'm not sure on and I couldn't find a good ansew on.
> > 
> > 1)Is there a way to "hide" things complelty when building a static libary. eg in c++ if I have:
> > 
> > //libary.h
> > double GetRandomNumber();
> > 
> > //libary.cpp
> > int DoSomething()
> > {
> >  //do something
> > }
> > double GetRandomNumber()
> > {
> >      return (double)rand() / RAND_MAX;
> > }
> > 
> > 
> > This is fine as the user doesn't know DoSomething() exists. But now if they create there own DoSomething() they get linker errors because it exists twice :(
> 
> Yes and no. In D, everything is qualified by its module name, and 
> there's a 1:1 module:file correspondence. So it's unlikely that two 
> modules would have the same fully-qualified name with the exact same symbol.
> 
> A bigger problem is that D doesn't have the concept of header files 
> (well, it does sort of with .di files, but they're rarely used in 
> open-source since they're generally not necessary if you have the source 
> file). The problem is that if you import one of them, all the symbols 
> (even those marked "private") will be imported.

So like in c++ I can't choose not to export something in a static lib and make it completly unavaible?



More information about the Digitalmars-d-learn mailing list