Thoughts about private aliases now working

Robert Clipsham robert at
Wed Feb 1 15:14:44 PST 2012

Hi all,

I had to skip dmd 2.057 due to various bugs, so in the hopes that I'll 
be able to use my codebase with 2.058 I'm testing it early. Due to some 
fixes with private imports, some code I was previously using no longer 
works. It looks a little like this:

private alias string[string] SS;
mixin template Func()
     SS someFunc(SS s)
         return s;

import a;
mixin Func;

Now that private aliases work, this errors as expected (SS shouldn't be 
visible in b.d). What this does mean however is that I have to do one of:

  * Type out the type in full in Func (I'm not actually using 
string[string] in my code, it's a rather longer named type)
  * Make the alias public so it's available to all modules that import Func.

As it's an implementation detail, I'd rather not have it appear in user 
code, which rules out the latter, and typing out the full type makes a 
simple declaration use up several lines (or one obscenely long line!)

Are there any other options I'm missing? Is there some way to make the 
alias visible within the mixin but not elsewhere?



More information about the Digitalmars-d mailing list