www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - making package privates visible with alias

reply Bill Baxter <dnewsgroup billbaxter.com> writes:
I'm using the helix.linalgebra library.
It uses constructs like:

private template Stuff(T) {
    int blarf(T) { ... }
}
alias .Stuff!(float).blarf blarf;
alias .Stuff!(double).blarf blarf;


I guess their code worked at one point in the history of D, but now (DMD 
0.172) attempts to use the 'blarf' functions result in the error
     "function linalgebra.blarf is not accessible from <mycode>."

Is there some other way to expose certain bits of private stuff?  Or is 
this just a bug that's supposed to work?

--bb
Oct 29 2006
parent Bill Baxter <dnewsgroup billbaxter.com> writes:
Some more info on this:

The same approach seems to be OK for the structs inside the template. 
Aliasing them outside in the public zone does make aliases that are 
public (or perhaps they aren't really being made private to begin with). 
  The alias just doesn't work for functions.

Also I found I could work around the problem for now by prefixing the 
functions inside the private template with 'public'.  So..

private template Stuff(T) {
    public int blarf(T var) // needs the public
    { ... }
    struct Dorf  // ok as default private
    {...}
}
alias .Stuff!(float).blarf blarff;
alias .Stuff!(float).Dorf Dorff;

--bb

Bill Baxter wrote:
 I'm using the helix.linalgebra library.
 It uses constructs like:
 
 private template Stuff(T) {
    int blarf(T) { ... }
 }
 alias .Stuff!(float).blarf blarf;
 alias .Stuff!(double).blarf blarf;
 
 
 I guess their code worked at one point in the history of D, but now (DMD 
 0.172) attempts to use the 'blarf' functions result in the error
     "function linalgebra.blarf is not accessible from <mycode>."
 
 Is there some other way to expose certain bits of private stuff?  Or is 
 this just a bug that's supposed to work?
 
 --bb
Oct 29 2006