digitalmars.D - opDispatch forwarding and ifti
- John Colvin (38/38) Feb 27 2017 Has anyone ever found a way to actually implement forwarding
- Stefan Koch (5/9) Feb 27 2017 What is your actual usecase ?
- John Colvin (9/19) Feb 27 2017 I'm trying to make std.typecons.Proxy support more things
- Stefan Koch (8/29) Feb 27 2017 op-dispatch is a runtime feature.
- Adam D. Ruppe (3/6) Feb 27 2017 Completely false. It runs opDispatch!("the_string") which is
- Stefan Koch (2/8) Feb 27 2017 Oh damn. Just lost my Street Cred :)
- Timon Gehr (15/20) Feb 27 2017 One reason why your test case doesn't work is probably this compiler bug...
Has anyone ever found a way to actually implement forwarding properly with opDispatch, such that it works for both general templates and also functions called using ifti (implicit function template instantiation)? I've spent a day on it trying to improve std.typecons.Proxy to support this and it seems impossible. The problem is to support this: template X() { alias X = int; } struct S0 { template A(T ...) { alias A = X; } template foo(T ...) { void foo(K)(K t) {} } } struct S1 { private S0 _s0; import std.typecons : Proxy; mixin Proxy!_s0; } unittest { S1 s1; alias B0 = s1._s0.A!(); static assert(is(B0!() == int)); s1._s0.foo(3); alias B1 = s1.A!(); static assert(is(B1!() == int)); s1.foo(3); }
Feb 27 2017
On Monday, 27 February 2017 at 12:14:10 UTC, John Colvin wrote:Has anyone ever found a way to actually implement forwarding properly with opDispatch, such that it works for both general templates and also functions called using ifti (implicit function template instantiation)?What is your actual usecase ? You are aware that your trying to mix an runtime and a compile-time feature, yes ? If it can be done then you will have to use CTFE and aliasSeqOf.
Feb 27 2017
On Monday, 27 February 2017 at 12:22:02 UTC, Stefan Koch wrote:On Monday, 27 February 2017 at 12:14:10 UTC, John Colvin wrote:I'm trying to make std.typecons.Proxy support more things correctly (e.g. template members, members that are aliases of types). I thought that was clear from the rest of my post.Has anyone ever found a way to actually implement forwarding properly with opDispatch, such that it works for both general templates and also functions called using ifti (implicit function template instantiation)?What is your actual usecase ?You are aware that your trying to mix an runtime and a compile-time feature, yes ?Not quite sure what you mean there. What is a runtime feature here?If it can be done then you will have to use CTFE and aliasSeqOf.The problem isn't with generating code (unless there's some very involved exhaustive solution I haven't thought of). How would you imagine I would use CTFE or aliasSeqOf to help here?
Feb 27 2017
On Monday, 27 February 2017 at 13:17:21 UTC, John Colvin wrote:On Monday, 27 February 2017 at 12:22:02 UTC, Stefan Koch wrote:op-dispatch is a runtime feature. It takes a string which is avilable at compile-time and passes it as a runtime parameter. This runtime parameter can be used at ctfe if opDispatch is called at ctfe. Then aliasSeqOf transforms it into a string-literal which can be used by templates.On Monday, 27 February 2017 at 12:14:10 UTC, John Colvin wrote:I'm trying to make std.typecons.Proxy support more things correctly (e.g. template members, members that are aliases of types). I thought that was clear from the rest of my post.Has anyone ever found a way to actually implement forwarding properly with opDispatch, such that it works for both general templates and also functions called using ifti (implicit function template instantiation)?What is your actual usecase ?You are aware that your trying to mix an runtime and a compile-time feature, yes ?Not quite sure what you mean there. What is a runtime feature here?If it can be done then you will have to use CTFE and aliasSeqOf.The problem isn't with generating code (unless there's some very involved exhaustive solution I haven't thought of). How would you imagine I would use CTFE or aliasSeqOf to help here?
Feb 27 2017
On Monday, 27 February 2017 at 14:27:21 UTC, Stefan Koch wrote:op-dispatch is a runtime feature. It takes a string which is avilable at compile-time and passes it as a runtime parameter.Completely false. It runs opDispatch!("the_string") which is totally compile time.
Feb 27 2017
On Monday, 27 February 2017 at 14:34:05 UTC, Adam D. Ruppe wrote:On Monday, 27 February 2017 at 14:27:21 UTC, Stefan Koch wrote:Oh damn. Just lost my Street Cred :)op-dispatch is a runtime feature. It takes a string which is avilable at compile-time and passes it as a runtime parameter.Completely false. It runs opDispatch!("the_string") which is totally compile time.
Feb 27 2017
On 27.02.2017 13:14, John Colvin wrote:Has anyone ever found a way to actually implement forwarding properly with opDispatch, such that it works for both general templates and also functions called using ifti (implicit function template instantiation)? I've spent a day on it trying to improve std.typecons.Proxy to support this and it seems impossible.One reason why your test case doesn't work is probably this compiler bug: struct S1{ template opDispatch(string op){ template opDispatch(T...){ static int x; } } } unittest{ S1 s1,s2; alias B1 = s1.A!().x; // error s1.A!().x=2; // ok } opDispatch seems to not be resolved when aliasing a symbol.
Feb 27 2017