alias and typedef declarations

Ary Manzana ary at esperanto.org.ar
Sun Dec 17 13:25:54 PST 2006


I'm almost finishing the AST nodes "à la JDT" for the Descent plugin, 
and I run into the following:

A typical alias declaration is:

# alias int Foo;

But this is also allowed:

# alias const x = 1;

Now, the AST nodes must record enough information to fully reflect what 
is written in the source code. Currently in DMD the last sentence is 
turned into a VarDeclaration that saves the storage class (const), the 
variable name (x) and the initializer (1, which is mandatory for this 
class of declarations). So the "alias" keyword is lost, and if you 
modify the AST and rewrite, it will definitely be lost.

So it seems the "alias" keyword isn't changing anything, so rewriting it 
as "const x = 1;" it's the same. Should I care about keeping the "alias" 
keyword or not? It's pretty much easier for me not to keep it.

Any suggestion?

(the same happens if "typedef" is used instead of "alias")

BTW, while building the AST I found out that any declaration can be 
preceded with modifiers. Sometimes it's pretty funny but luckily makes 
no harm, so I'm not complaining for this anymore. For example:

# abstract static if (true) { }
 > Will it evaluate? It's abstract :-P

# final static assert("D rules");
 > Now that's a final assert!

# override debug = 1;
 > If I defined it previously, now I can make it clear that I'm 
overriding it

Etc.

Thanks,
Ary


More information about the Digitalmars-d-learn mailing list