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

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; }

compile-time gremlin/ql across pegged parse trees

2023-12-04 Thread Dmitry Ponyatov via Digitalmars-d-learn
Is anybody tried to implement some query-like adds for Dlang for making data selection from some data structures such as object graphs or trees (at least for pegged parsed data) ? I'm writing tiny tool for KiCAD (EDA CAD), and it would be great to have some tool to write easy-readable

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 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 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

anonymous structs within structs

2023-12-04 Thread DLearner via Digitalmars-d-learn
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 'Dummy' above) to the A struct held within the B struct.

Re: now I need -allinst when dmd compiles the unittest

2023-12-04 Thread Steven Schveighoffer via Digitalmars-d-learn
On Friday, 1 December 2023 at 22:00:52 UTC, kdevel wrote: If I not use -allinst the linker complains when using the current msgpack-d v1.0.5, e.g. [...]msgpack-d/src/msgpack/package.d:203: undefined reference to `pure nothrow @nogc @safe immutable(char)[]