[Issue 7364] Better Eponymous Template syntax

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Jul 7 02:47:14 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=7364


monarchdodra at gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |monarchdodra at gmail.com


--- Comment #8 from monarchdodra at gmail.com 2013-07-07 02:47:02 PDT ---
(In reply to comment #0)
> Current Eponymous Template syntax forces one to repeat a template name. It's
> bad because:
> * Templates often have long names like `FunctionTypeOf` (or longer) so it's
> just long to write `alias <...> FunctionTypeOf;`.
> * If one will make a misprint in retyping a long template name he will be
> punished.
> * If a template is renamed (can happened with private templates) or a part of
> template is moved to an internal template every using of a template name should
> be changed appropriately. If one will make a mistake in this renaming, see
> previous case.
> 
> If, e.g. Alias This syntax will be added (with no more than one `alias this`
> per template)

Just want to point out that technically, as long as you don't create any
conflicts (eg functions that overload), then you can have as many eponymous
entries as you wish.

template foo
{
    void foo(){}
    void foo(int i){}
}

> things will be significantly better because lots of Phobos (a
> real world library example) eponymous template aliases something. And now these
> templates look terrible. More than that, `this` is a keyword and will be
> highlighted in most editors unlike current syntax.
> 
> 
> Inspired by "Aliasing of template results" post in NG by Alex Rønne Petersen.

I have two problems with this.

1. The first is the the syntax `alias this` does not imply "shadowing" of the
rest of the members. EG:

template Foo
{
    alias this = long;
    alias T = short;
}
//Later:
Foo a;
Foo.T b; //Error: T not a property of long ? What???

In this case, I think `alias this` does a bad parallel with *what* alias this
actually does.

2. Ditto for functions:

template foo
{
    void this(){}
    void this(int i){}
}
//Template constructors?
//No! eponymous template!

Again, bad parralel between what "this" does in general case.

--------

So if I placed my vote on something, it would rather it be on the "template"
keyword, or anything else actually. I'm not sold on using "this".

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list