[Issue 11946] "need 'this' to access member" when passing field to template parameter

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Mar 3 08:08:44 PST 2014


https://d.puremagic.com/issues/show_bug.cgi?id=11946



--- Comment #31 from Dicebot <public at dicebot.lv> 2014-03-03 08:08:42 PST ---
(In reply to comment #30)
> The irony is that as much as I dislike this approach, it does allow doing more
> things with template alias parameters, and I've started to rely on it in my own
> code. I even took it a step further in

It does not really matter. What is the point of adding more features is they
break basic guarantees? It does not fit nicely with idea that templates are not
affected by instantiation scope and forces you to pollute your code with loads
of boilerplate just to be sure.

I am effectively forced to go though my code upon next release and replace all

void foo(alias X)(...) {}

with

template foo(alias X)
{
    static void foo(...) {]
}

_everywhere_. How I am even supposed to not hate it?

> The idea is to introduce "static alias" template parameters, which make it
> explicit if the alias parameter needs to transmit the symbol's context to the
> template (and thus nest the template within that context), or not. I think it
> is a sensible approach in lieu of automagically determining if that context is
> needed by the template (which Kenji claims is "mostly impossible").

It should be other way around, "dynamic alias" for those who do want a context
pointer. "Don't pay for what you don't use" and principle of least surprise.

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


More information about the Digitalmars-d-bugs mailing list