3 ms·
To me it would make sense that this be implemented as a normal interface at least initially, it would reuse all the existing bits of the language as is. Note th
by masklinn 3y ago
To me it would make sense that this be implemented as a normal interface at least initially, it would reuse all the existing bits of the language as is. Note that whether an interface boxes depends on escaping.
I don't see how unboxing would have to be "arbitrarily initialized as an A or a B" either. Even with a novel bespoke implementation you still need a discriminant between the two nested. You could keep a nil default by reserving the zero discriminant for that purpose.
- foldr 3y agoI agree with your first paragraph. I think it would be weird if an unboxed union of A and B was initialized to a value that wasn't the default value of either A or B, although I take your point that it's a technically possible implementation.
- masklinn 3y ago> I don't quite understand the second one (is 'boxing' supposed to be 'unboxing'?) Yep, fixed, sorry about that. > I think it would be weird if an unboxed union of A and B was initialized to a value that wasn't the default value of either A or B On the one hand yes, on the other hand it would be consistent with the langage semantics (the default value of an interface type is a nil), and I don’t think defaulting to the default value of an arbitrary variant is better. Although I can see the similarity with iota / newtype constants, the first item being the default, and similarly people could set the first type as relevantly named (possibly unexported) empty struct if they want / need the signal.