New programming paradigm

Simen Kjærås simen.kjaras at gmail.com
Sun Jun 3 16:36:52 UTC 2018


On Sunday, 3 June 2018 at 14:57:37 UTC, DigitalDesigns wrote:
> On Sunday, 3 June 2018 at 09:52:01 UTC, Malte wrote:
>> You might want to have a look at 
>> https://wiki.dlang.org/Dynamic_typing
>> This sounds very similar to what you are doing. I never really 
>> looked into it, because I prefer to know which type is used 
>> and give me errors if I try to do stupid things, but I think 
>> it's a cool idea.
>
> No, this is not what I'm talking about, although maybe it could 
> be related in some way.

Actually, it sort of is. Your mapEnum is essentially the same as 
std.variant.visit (https://dlang.org/phobos/std_variant#.visit), 
and std.variant.Algebraic is the type that encapsulates both the 
runtime tag and the void[] containing the data of unknown type.

Now, there may be many important differences - Algebraic 
encapsulates the data and tag, which may or may not be what you 
want, visit only takes one algebraic argument, mapEnum may be 
faster, more or less generic, etc. The idea of converting a 
run-time value to a compile-time value is the same, though.

--
   Simen


More information about the Digitalmars-d-learn mailing list