On Saturday, 15 December 2012 at 23:04:37 UTC, r_m_r wrote:
On 12/16/2012 04:00 AM, js.mdnq wrote:
Now, the next step is to be able to "insert" code into the
struct! ;)
how about this: http://dpaste.dzfl.pl/8161d00a
regards,
r_m_r
No, it's backwards! ;)
Or, sort of what one wants to do is:
template MasterStruct_A(alias f, string c = "")
{
enum F = f;
struct S
{
int X;
int Y;
this(int x, int y) { X = x; Y= y; }
mixin (c);
}
}
template UserStruct(alias f)
{
enum F = f;
struct S
{
int A;
int B;
}
}
and mixin the UserStruct.S with the MasterStruct_A
something like
mixin (genStruct!(MasterStruct_A, UserStruct, "s3");
which is equivalent of to the following
struct S
{
int X;
int Y;
this(int x, int y) { X = x; Y= y; }
int A;
int B;
}
S s3;
This, then basically adds the ability to do partial structs(or
classes) relatively easily(although not as easy if the compiler
did it automatically).