digitalmars.D.learn - Generate unique members with recursive mixins or another solution?
- ilariel (39/39) Sep 08 2016 Is it possible to generate unique fields and members with
- =?UTF-8?Q?Ali_=c3=87ehreli?= (4/6) Sep 08 2016 I don't fully understand the question but my answer is yes, D can do
Is it possible to generate unique fields and members with recursive template mixins? Each mixin has their own scope even if outer scope shadows their scope. So could it be possible to generate template methods that can access members in their own scopes? Assuming the members are dispatches to unique aliases of static functions, methods accessing fields of unique types of both structs and classes. Basically my use case would be something of the nature of the following (ofc I haven't gotten this working so it is mix of pseudo code and some bits of real D): alias Data = AliasSeq!(POD1,POD2,POD3/*etc*/); //List of processed data types alias Callables = AliasSeq!(AliasSeq!(function,another),someClass,SomeStruct); //processors Processor!(Data,Callables) dataProcessor; dataProcessor.simulate!float(1.5f); class SomeClass(Callables) { recursive mixin? } Processor(alias Data, alias Callables) { SomeClass!Callables processors; void simulate(parameterType...)(parameterType param) { foreach(callable; Callables) { static if(/* if right parameters */) { //Generate calls to each applicable processor processors!callable(param); } } } } If this is completely impossible with recursive mixin templates, is there another feasible solution for my use case beyond manual writing?
Sep 08 2016
On 09/08/2016 02:55 AM, ilariel wrote:Is it possible to generate unique fields and members with recursive template mixins?I don't fully understand the question but my answer is yes, D can do this as well. :p Ali
Sep 08 2016