Alternate implementations of an abstract functor

a variation of an earlier topic

i have two functors G(T, x) and H(T, y, z) that ultimately want to return a type F(T) that implements some method foo()… the suggestion here is that “extra” arguments to G and H will somehow shape the struct returned by each – ultimately implementing get in a different manner…

the client, however, deals with the type F(T) only – confident that it has a foo() method… this is not unlike dealing with abstract data objects, which could be instantiated via different implementations…

i’m not sure how to even approach this… do G and H themselves expose some sort of MakeF method that returns F(T)??? since the client deals with F(T) only, will the compiler complain when type names don’t match???

is there a “functor factory pattern” lurking here :wink:

just a small thought maybe ancillary to your grand plans, but zig’s build system has something sort of like that with regards to dependence of steps: in this case, Step is a bit like your F(T), and Step.Compile and its friends are like G and so on. these have an Step as a field and I am almost sure Steps rely on @fieldParentPtr and function pointers to call into the parent type to perform what they need to qua Step