A way to mixin during runtime?

jfondren julian.fondren at gmail.com
Fri Aug 27 11:22:41 UTC 2021


On Friday, 27 August 2021 at 10:34:27 UTC, Kirill wrote:
> Each csv file will be different.
>
> For example:
> ```
> name;surname;age;grade
> Alex;Wong;18;87
> John;Doe;19;65
> Alice;Doe;18;73
> etc...
> ```
>
> I'd like to extract the data types automatically. For instance, 
> if using tuples:
> ```
> Tuple!(string, string, int, int) ...
> ```
> instead I'd like to have:
> ```
> auto mytuple = read_csv(path); // returns Tuple!(string, 
> string, int, int)[]
> ```

mytuple needs to have a type that's known at compile-time, so 
this isn't possible. In the types are only dynamically known, 
then you have to deal in dynamic types. One way could be to have 
a read_csv that returns an array of 
https://dlang.org/phobos/std_variant.html


More information about the Digitalmars-d-learn mailing list