Is std.variant useful for types only known at run time?

2021-09-08 Thread Chris Piker via Digitalmars-d-learn
Hi D I'm working on data streaming reading module where the encoding of each input array isn't known until runtime. For example date-time column values may be encoded as: * An ISO-8601 UTC time string (aka char[]) * A ASCII floating point value with an indicated unit size and epoch (a

Re: Is std.variant useful for types only known at run time?

2021-09-08 Thread jfondren via Digitalmars-d-learn
On Wednesday, 8 September 2021 at 07:10:21 UTC, Chris Piker wrote: Hi D I'm working on data streaming reading module where the encoding of each input array isn't known until runtime. For example date-time column values may be encoded as: * An ISO-8601 UTC time string (aka char[]) * A

Re: Is std.variant useful for types only known at run time?

2021-09-08 Thread Chris Piker via Digitalmars-d-learn
On Wednesday, 8 September 2021 at 08:39:53 UTC, jfondren wrote: so I'd look at a std.sumtype of them first: Wow, this forum is like a CS department with infinite office hours! Interesting. I presume that the big win for using std.sumtype over a class set is value semantics instead of refer

Re: Can we rely on LDC respecting "align" (for avx) ??

2021-09-08 Thread Johan via Digitalmars-d-learn
On Wednesday, 8 September 2021 at 04:32:50 UTC, james.p.leblanc wrote: 1) Can we truly rely on LDC's alignment for AVX ? Yes. If you find wrong alignment, it's a bug. -Johan

Re: Is std.variant useful for types only known at run time?

2021-09-08 Thread jfondren via Digitalmars-d-learn
On Wednesday, 8 September 2021 at 09:55:20 UTC, Chris Piker wrote: Interesting. I presume that the big win for using std.sumtype over a class set is value semantics instead of reference semantics? There's a lot to say about the precise differences. One practical difference that I alluded to

Re: Is std.variant useful for types only known at run time?

2021-09-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/8/21 5:55 AM, Chris Piker wrote: On Wednesday, 8 September 2021 at 08:39:53 UTC, jfondren wrote: so I'd look at a std.sumtype of them first: Wow, this forum is like a CS department with infinite office hours! Interesting.  I presume that the big win for using std.sumtype over a class se

Re: Curious effect with traits, meta, and a foreach loop ... mystifies me.

2021-09-08 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 7 September 2021 at 17:47:15 UTC, james.p.leblanc wrote: What I mean by "dig out" the needed "x" is: if I could alias/enum/ or someother trick be then able just to use that "x" as a simple static array. You might be able to just cast the struct to a static array of the same size

Re: Curious effect with traits, meta, and a foreach loop ... mystifies me.

2021-09-08 Thread Bastiaan Veelo via Digitalmars-d-learn
On Tuesday, 7 September 2021 at 17:24:34 UTC, james.p.leblanc wrote: ```d /*…*/ // this is fine (notice that 'val' is never used foreach( i, val ; u.tupleof ){ ptr = u.tupleof[i].x.ptr; writeln("ptr: ", ptr); } // this fails with: "Error: variable 'i' cannot be read at

Re: DMD32 D Compiler v2.097.2-dirty ?

2021-09-08 Thread Bastiaan Veelo via Digitalmars-d-learn
On Monday, 6 September 2021 at 15:37:31 UTC, Paul wrote: I like to write CLEAN code:) Why does my DMD installation say v2.097.2-dirty? https://forum.dlang.org/post/qqxmnoshytmzflviw...@forum.dlang.org I suppose it is due to how the scripts work that produce the compiler release. I guess

Re: Curious effect with traits, meta, and a foreach loop ... mystifies me.

2021-09-08 Thread Tejas via Digitalmars-d-learn
On Tuesday, 7 September 2021 at 17:47:15 UTC, james.p.leblanc wrote: On Tuesday, 7 September 2021 at 17:33:31 UTC, Adam D Ruppe wrote: On Tuesday, 7 September 2021 at 17:24:34 UTC, james.p.leblanc wrote: If you want to do a runtime lookup, you need to separate the two pieces. This pattern wor

Re: Curious effect with traits, meta, and a foreach loop ... mystifies me.

2021-09-08 Thread Tejas via Digitalmars-d-learn
On Thursday, 9 September 2021 at 05:32:29 UTC, Tejas wrote: On Tuesday, 7 September 2021 at 17:47:15 UTC, james.p.leblanc wrote: [...] from what I understand you want to change the aligned data that you're referring to at runtime. ```d void main() { import std.experimental.allocator.mall