On Thu, 12 Apr 2012 14:04:44 -0400, Timon Gehr <[email protected]> wrote:
The general idea is useful, but there are issues.
'this' is the wrong keyword for the job. A class or struct instance is
very different from a template instance and the proposed usage would
clash with existing and useful ones. (assuming that it would work for
symbol lookups in addition to declarations)
'template' or maybe 'scope' would be superior choices.
I think static is underused keyword, maybe it should have a dual meaning
here.
In all seriousness, I'm not sure template is right either. Scope sounds
like a very bad choice to me.
Are there any eponymous examples where the name of the template is the
first token? If so that would clash with declaring a new template.
I would find this weird:
template X(T)
{
alias T template;
template t {
...
}
}
It looks like you are using template as an alias to T, but the second
'template' inside is using it for creating a new template.
Also, consider this:
template X(T)
{
class template {
static typeof(this) create() { return new typeof(this);}
}
}
I don't think you could realistically use any keyword instead of
typeof(this), I really think the best solution is what we have, or use a
new keyword.
Another option is to do something like:
@eponymous template X(T) // changed from Y(T)
{
class Y { } // oops forgot to change this to X!
}
Error: template X did not declare eponymous symbol
At least changes would be loud errors.
-Steve