static code generation

js.mdnq js_adddot+mdng at
Mon Dec 17 15:12:21 PST 2012

On Monday, 17 December 2012 at 22:24:58 UTC, r_m_r wrote:
> On 12/17/2012 04:33 AM, js.mdnq wrote:
>> Well, it a slightly another way and close. Let me see if I can 
>> come up
>> with something that expresses better what I'm after. It will 
>> be a week
>> or two though till I get around to it probably.
> OK. I'll just leave this here for future reference:
> regards,
> r_m_r

Cool. You have some useful stuff there. I'll have to go through 
it and see if it does what I want or could be used to do it. It 
looks like it does the combining so that is a definite plus. I 
think, though, one problem is, is you would want to wrap the user 
struct in a template because you might want to access the 
master's members from the user struct.

It looks like the approach 2 does what I'm looking for pretty 
nicely except that, If I'm not mistaken the user struct will 
error out when trying to access members from the master.


struct S_AB(AT, BT)
	AT A;
	BT B;

struct S_CD(CT, DT)
         void check() { writeln(A); } // error, No A
	CT C;
	DT D;

mixin ( gen!("S_ABCD", S_AB!(int, float), S_CD!(double, string)) 

I'm not actually sure about the best approach here. Using a 
template mixin will work but I like the look & feel of just using 
normal structs(as we don't have to access A in S_CD if we don't 
need too).

In any case, it seems your method does not work with methods? if 
I add the `check()` to your approach-2 it fails with several 
strange errors. Any ideas?

More information about the Digitalmars-d-learn mailing list