Re: opDispatch doesn't play nice with inheritance

2018-11-18 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, November 17, 2018 11:09:51 PM MST Carl Sturtivant via Digitalmars-d-learn wrote: > On Thursday, 15 November 2018 at 19:01:45 UTC, Ali Çehreli wrote: > > On 11/15/2018 09:14 AM, Carl Sturtivant wrote: > > > opDispatch is special in that it allows for functions to be > > > > added to a

Re: opDispatch doesn't play nice with inheritance

2018-11-17 Thread Carl Sturtivant via Digitalmars-d-learn
On Thursday, 15 November 2018 at 19:01:45 UTC, Ali Çehreli wrote: On 11/15/2018 09:14 AM, Carl Sturtivant wrote: > opDispatch is special in that it allows for functions to be added to a > class or struct when undefined overtly but used elsewhere but it seems > those functions sadly are final. >

Re: opDispatch doesn't play nice with inheritance

2018-11-15 Thread Ali Çehreli via Digitalmars-d-learn
On 11/15/2018 09:14 AM, Carl Sturtivant wrote: > opDispatch is special in that it allows for functions to be added to a > class or struct when undefined overtly but used elsewhere but it seems > those functions sadly are final. > > Can anything useful be done to remedy the situation? For the com

Re: opDispatch doesn't play nice with inheritance

2018-11-15 Thread Carl Sturtivant via Digitalmars-d-learn
On Thursday, 15 November 2018 at 18:04:42 UTC, Adam D. Ruppe wrote: Right, all templates are final, including opDispatch. What I've done in the past is to forward them to a virtual function with runtime arguments instead of compile time arguments. Kinda like: void opDispatch(string name)()

Re: opDispatch doesn't play nice with inheritance

2018-11-15 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 15 November 2018 at 17:14:21 UTC, Carl Sturtivant wrote: opDispatch is special in that it allows for functions to be added to a class or struct when undefined overtly but used elsewhere but it seems those functions sadly are final. Right, all templates are final, including opDispa

opDispatch doesn't play nice with inheritance

2018-11-15 Thread Carl Sturtivant via Digitalmars-d-learn
//Consider this: import std.stdio; void main() { X obj = new Y; writeln( obj._f() ); } class Proxy { X x; this(X x) { this.x = x; } string _f() { return "Proxy._f called"; } } class X { auto opDispatch(string f, Args...)(Args args) { Proxy p = new Proxy(this);