Alias Declarations
A symbol can be declared as an alias of
another symbol. For example: import string;
alias string.strlen mylen;
...
int len = mylen("hello"); // actually calls string.strlen()
The following alias declarations are valid: template Foo2(T) { alias T t; }
instance Foo2(int) t1; // a TemplateAliasDeclaration
alias instance Foo2(int).t t2;
alias t1.t t3;
alias t2 t4;
alias instance Foo2(int) t5;
t1.t v1; // v1 is type int
t2 v2; // v2 is type int
t3 v3; // v3 is type int
t4 v4; // v4 is type int
t5.t v5; // v5 is type int
Aliased symbols are useful as a shorthand for a long qualified symbol
name, or as a way to redirect references from one symbol to another: version (Win32)
{
alias win32.foo myfoo;
}
version (linux)
{
alias linux.bar myfoo;
}
Note: Type aliases can sometimes look indistinguishable from alias
declarations: alias foo.bar abc; // is it a type or a symbol?
The distinction is made in the semantic analysis pass.
Copyright (c) 1999-2002 by Digital Mars, All Rights
Reserved