On 22/01/2012 18:33, Andrej Mitrovic wrote:
A while ago there was a suggestion by Andrei to incorporate this sort of syntax:
template ElementType(T : T[])
{
alias ElementType = T;
}
struct Foo(T)
{
alias Type = T;
}
I think people agreed it was a nice syntax, but I don't know if anyone
tried to implement it.
I think this is not really relevant to the OP question about changing
eponymous template syntax though.
By coincidence, I implemented 'alias bar = foo;' syntax yesterday in my
local copy - see attached diff.
diff --git a/src/parse.c b/src/parse.c
index dd481df..0ca48e4 100644
--- a/src/parse.c
+++ b/src/parse.c
@@ -2726,6 +2726,35 @@ Dsymbols *Parser::parseDeclarations(StorageClass
storage_class, unsigned char *c
addComment(s, comment);
return a;
}
+ // alias this = identifier;
+ Token *tk = peek(&token);
+ if (token.value == TOKthis && tk->value == TOKassign &&
+ peek(tk)->value == TOKidentifier)
+ {
+ check(TOKthis);
+ check(TOKassign);
+ AliasThis *s = new AliasThis(this->loc, token.ident);
+ nextToken();
+ check(TOKsemicolon);
+ a = new Dsymbols();
+ a->push(s);
+ addComment(s, comment);
+ return a;
+ }
+ // alias identifier = expression;
+ if (token.value == TOKidentifier && tk->value == TOKassign)
+ {
+ Identifier *id = token.ident;
+ nextToken();
+ check(TOKassign);
+ t = parseType();
+ check(TOKsemicolon);
+ Declaration *v = new AliasDeclaration(loc, id, t);
+ a = new Dsymbols();
+ a->push(v);
+ addComment(v, comment);
+ return a;
+ }
break;
case TOKtypedef:
if (!global.params.useDeprecated)