On 08/14/2015 01:40 PM, Andrei Alexandrescu wrote:
On 8/12/15 5:43 AM, Sönke Ludwig wrote:
Anyway, I've just started to work on a generic variant of an enum based
algebraic type that exploits as much static type information as
possible. If that works out (compiler bugs?), it would be a great thing
to have in Phobos, so maybe it's worth to delay the JSON module for that
if necessary.


First proof of concept:
https://gist.github.com/s-ludwig/7a8a60150f510239f071#file-taggedalgebraic-d-L148



It probably still has issues with const/immutable and ref in some
places, but the basics seem to work as expected.

struct TaggedAlgebraic(U) if (is(U == union)) { ... }

Interesting. I think it would be best to rename it to TaggedUnion
(instantly recognizable; also TaggedAlgebraic is an oxymoron

No, it isn't. I believe the word you might want is "pleonasm". :o)

as there's no untagged algebraic type).

The tag is an implementation detail. Algebraic types are actually more naturally expressed as polymorphic higher-order functions.

Reply via email to