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.
Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
August 27, 2021 A way to mixin during runtime? | ||||
---|---|---|---|---|
| ||||
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. |
August 27, 2021 Re: A way to mixin during runtime? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kirill | 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. remember D is a statically compiled language, you may need a scripting language embedded in your D app to achieve this. thx. |
August 27, 2021 Re: A way to mixin during runtime? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kirill | 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 |
August 27, 2021 Re: A way to mixin during runtime? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mathias LANG | 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 Each csv file will be different. For example:
I'd like to extract the data types automatically. For instance, if using tuples:
instead I'd like to have:
|
August 27, 2021 Re: A way to mixin during runtime? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kirill | On Friday, 27 August 2021 at 10:34:27 UTC, Kirill wrote: >Each csv file will be different. For example:
I'd like to extract the data types automatically. For instance, if using tuples:
instead I'd like to have:
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 |
August 27, 2021 Re: A way to mixin during runtime? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kirill | On 8/27/21 6:34 AM, Kirill wrote: >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 Each csv file will be different. For example:
I'd like to extract the data types automatically. For instance, if using tuples:
instead I'd like to have:
So you can't build "new types" at runtime that are usable after your code is compiled. But there are options:
Without the CSV telling you types, it's hard to make something "easy". I have written code that extracts from JSON data and database data serializable struct types, and builds a D file, but it's never clean-cut, and sometimes you have to hand-edit that stuff. This is about as "easy" as it gets, just have the computer do most of the heavy lifting, and then massage it into something usable. -Steve |
August 29, 2021 Re: A way to mixin during runtime? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kirill | 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. mixin at runtime not possible. But you can impement this! Steps:
Packages bindbc-, derelict- uses dynamic loading. You can use both as examples. |