Dynamic templated virtuals - I still often want them
Alexandru Ermicioi
alexandru.ermicioi at gmail.com
Wed Jul 29 13:04:51 UTC 2020
On Wednesday, 29 July 2020 at 12:17:55 UTC, Steven Schveighoffer
wrote:
> On 7/29/20 4:01 AM, Alexandru Ermicioi wrote:>> On Tuesday, 28
> July 2020 at 21:09:51 UTC, Steven Schveighoffer This statement
> suggests you are not understanding the proposal. Arafel is
> right -- it's not a template function to be instantiated on
> calling, but a concrete function in the vtable instantiated on
> declaration.
Alright, I did read again original post, and indeed it is about
(this T) case only, which may work. I was referring to broader
case of templates in general, which would have issues I
mentioned. Still, for these virtual (this T) methods, it's best
to have a different/modified syntax to existing x(this T)(),
since they mean two different things.
And this feature can be implemented also in following fashion
right now:
---
class Base {
protected string doImpl(this T)() {
return T.stringof;
}
public abstract do();
}
class Derived {
public do() {
this.doImpl();
}
}
---
imho, this feature can be lowered to code in example above,
instead of generating new body for each derived class.
Best regards,
Alexandru.
More information about the Digitalmars-d
mailing list