alias syntax
Zarathustra
adam.chrapkowski at gmail.com
Wed Aug 5 02:13:07 PDT 2009
Ellery Newcomer Wrote:
> > You mean how the compiler rejects "alias const int x;" but not "alias
> > static int x;"? That is strange..
>
> I want to know why
>
> alias static int x;
>
> is allowed in the first place
d.grammar accepts: alias const int a; but compiler no (it is ok).
d.grammar accepts: alias static int a; and compiler too
It is compiler fault or compiler just ignore this cases which seem haven't sense.
It is a grammar rule, in D there is much unnecessary (senseless ) notations.
For example:
void main(){
alias static int a; // compiler will ignore alias
final static int b; // compiler will ignore final
alias final int b; // compiler will ignore alias and final
}
----------------------------------------------------------
class A{
final int a; // final field doesn't have a sense
scope int a; // A is still not-scope class
}
----------------------------------------------------------
module A;
private class AA{
}
module B;
import A;
void main(){
AA aa = new AA; // class AA is not private
}
----------------------------------------------------------
As to your question:
class K{
alias static int B;
B b; // b is non-static
}
----------------------------------------------------------
More information about the Digitalmars-d-learn
mailing list