A way to mixin during runtime?

Kirill kirill.saidov at mail.com
Fri Aug 27 10:34:27 UTC 2021


On Friday, 27 August 2021 at 09:51:46 UTC, Mathias LANG wrote:
> On Friday, 27 August 2021 at 06:52:10 UTC, Kirill wrote:
>> Is there a way to do mixin or similar during runtime?
>>
>> I'm trying to read a csv file and extract data types. Any 
>> ideas on how this should be approached in D are greatly 
>> appreciated.
>
> You cannot mixin at runtime. However, it is fairly easy to map 
> a finite and CT-know set of argument to runtime arguments via 
> `static foreach`.
> Could you give us example of the content of your CSV file and 
> what you are trying to do ?

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)[]
```


More information about the Digitalmars-d-learn mailing list