An idea to improve eponymous templates

Denis Shelomovskij verylonglogin.reg at gmail.com
Wed Apr 11 22:24:17 PDT 2012


12.04.2012 6:21, Reid Levenick написал:
> Firstly, I had no idea where suggestions should go, and I saw a few
> others here and thus here I am.
>
> I was writing some code that depended heavily on my own eponymous
> templates, and decided to change the names of some of them to make them
> more self-documenting. However, after changing the name, I encountered a
> long stream of unintelligible errors (to me, I haven't been using D for
> a long time) about template instances.
>
> So, my idea is that the 'this' keyword could be used in templates as a
> shortcut for eponymous templates, allowing code like this
>
> template anEponymousTemplate( size_t whatever ) {
> enum this = whatever * 2;
> }
> template anotherOne( T ) {
> static if( is( T == class ) ) {
> alias long this;
> } else {
> alias int this;
> }
> }
>
> Which would reduce cruft and make it easier to read some templates, as
> well as reducing maintenance.

This idea already has it's own issue:
http://d.puremagic.com/issues/show_bug.cgi?id=7364

born from:
http://www.digitalmars.com/d/archives/digitalmars/D/Aliasing_of_template_results_155859.html

-- 
Денис В. Шеломовский
Denis V. Shelomovskij


More information about the Digitalmars-d mailing list