Phobos 3 Discussion Notes - 02-01-2024
Paul Backus
snarwin at gmail.com
Mon Feb 5 16:46:20 UTC 2024
On Monday, 5 February 2024 at 16:36:02 UTC, monkyyy wrote:
> On Monday, 5 February 2024 at 15:40:11 UTC, Paul Backus wrote:
>>> I think our goal is to make `-betterC` obsolete. As in: if
>>> you don't use the feature, you don't pay for it, and it's
>>> implicit.
>>
>> Even in the 100% pay-as-you-go world, I think we'll still want
>> Phobos APIs to avoid depending on (and paying for) more
>> druntime features than they really need to.
>
> This feels delusional to me; like I don't know how the formal
> style with its contracts and extra asserts and 5 layered
> datetime will ever avoid rogue imports that aren't part of a
> blessed compile environment.
The way you avoid this stuff is by testing. Run your unit tests
with `-betterC` and any accidental druntime dependencies you add
will be revealed to you very quickly.
The current version of Phobos was written before BetterC existed
and is kind of lazy about testing in general, so it doesn't do
this, but I'm hoping that will change with Phobos V3.
I've tried to set an example with `std.sumtype`. Unlike every
other module in Phobos, its unit tests are enabled in BetterC by
default, and those that depend on druntime have to make this
explicit by using a `version` condition.
More information about the Digitalmars-d
mailing list