D3 sumtype api

Paul Backus snarwin at gmail.com
Fri Feb 28 01:25:29 UTC 2025


On Friday, 28 February 2025 at 01:18:15 UTC, monkyyy wrote:
> On Friday, 28 February 2025 at 01:06:01 UTC, Paul Backus wrote:
>> On Friday, 28 February 2025 at 00:46:13 UTC, monkyyy wrote:
>>> If I read that right you were doing it get!int but now its 
>>> breaking;
>>
>> You read wrong.
>
> https://github.com/dlang/phobos/pull/10650/commits/fe64ac592b03037b99e5ea201c0170af2281ea4b#
>
> you had `ref get(size_t tid)()` and now its `ref 
> getByIndex(size_t tid)()`

Sure. That was an internal, `private` function, so changing its 
name didn't break anything. In fact, the whole reason I made it 
`private` was so that I could change it in the future if I wanted 
to.

> If naively some future d3 user had your modified sumtype and 
> called my match, it would break(in an additional way);

If your `match` is using `SumType`'s `private` interface, and it 
breaks, that's your fault. Use the `public` interface if you 
don't want breakage. `SumType` has an extensive unit test suite 
to prevent regressions in its `public` interface.


More information about the dip.ideas mailing list