Re: anonymous structs within structs

2023-12-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, December 4, 2023 11:26:07 AM MST DLearner via Digitalmars-d-learn wrote: > Suppose we need a construct like: > ``` > void main() { > > struct A { >int I1; >int I2; >char X; > } > > struct B { >A Dummy; >int Var1; >int Var2; >

Re: anonymous structs within structs

2023-12-05 Thread DLearner via Digitalmars-d-learn
On Tuesday, 5 December 2023 at 00:31:35 UTC, H. S. Teoh wrote: On Mon, Dec 04, 2023 at 11:46:45PM +, DLearner via Digitalmars-d-learn wrote: [...] Basically, B corresponds to the whole record (and only a whole record can be read). But the task only requires Var1 and Var2, the last two

Re: anonymous structs within structs

2023-12-04 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Dec 04, 2023 at 11:46:45PM +, DLearner via Digitalmars-d-learn wrote: [...] > Basically, B corresponds to the whole record (and only a whole record > can be read). > But the task only requires Var1 and Var2, the last two fields on the record. > By putting all the irrelevant fields

Re: anonymous structs within structs

2023-12-04 Thread DLearner via Digitalmars-d-learn
On Monday, 4 December 2023 at 23:16:27 UTC, thinkunix wrote: DLearner via Digitalmars-d-learn wrote: On Monday, 4 December 2023 at 21:55:29 UTC, Mike Shah wrote: [...] Is something like this what you had in mind? ``` void main() {    import std.stdio;    mixin template A() {   int I1;  

Re: anonymous structs within structs

2023-12-04 Thread thinkunix via Digitalmars-d-learn
DLearner via Digitalmars-d-learn wrote: On Monday, 4 December 2023 at 21:55:29 UTC, Mike Shah wrote: [...] Is something like this what you had in mind? ``` void main() {    import std.stdio;    mixin template A() {   int I1;   int I2;   char X;    }    struct B {   mixin A;

Re: anonymous structs within structs

2023-12-04 Thread DLearner via Digitalmars-d-learn
On Monday, 4 December 2023 at 21:55:29 UTC, Mike Shah wrote: [...] Is something like this what you had in mind? ``` void main() { import std.stdio; mixin template A() { int I1; int I2; char X; } struct B { mixin A; int Var1; int Var2; }

Re: anonymous structs within structs

2023-12-04 Thread Mike Shah via Digitalmars-d-learn
On Monday, 4 December 2023 at 18:26:07 UTC, DLearner wrote: Suppose we need a construct like: ``` void main() { struct A { int I1; int I2; char X; } struct B { A Dummy; int Var1; int Var2; } } ``` But do not want to give an explicit name (like