draft proposal for Sum Types for D
Steven Schveighoffer
schveiguy at gmail.com
Wed Nov 30 04:57:16 UTC 2022
On 11/29/22 3:04 PM, Walter Bright wrote:
> On 11/29/2022 9:14 AM, Steven Schveighoffer wrote:
>> In the DIP, it says that "Member functions of field declarations are
>> restricted the same way union member functions are." What does this
>> mean? I can't find any information on this in the spec.
>>
>> An example of what is not allowed would be helpful.
>>
> I thought it mentioned that copy constructors, postblits, and
> destructors are not allowed.
It mentions postblit and destructors *on the union itself* are not
allowed. It says nothing on field declarations.
These make sense given that a union itself cannot know what the actual
data stored its (unless you embed the type somehow in the data itself).
However, a sumtype would not have that problem.
Honestly, the trickiest parts of making a library sumtype *are* the
lifetime issues. I would hope the builtin thing would solve this for us.
-Steve
More information about the Digitalmars-d
mailing list