-preview=safer for D

Richard (Rikki) Andrew Cattermole richard at cattermole.co.nz
Fri Jan 3 15:43:01 UTC 2025


On 03/01/2025 11:19 PM, Andrej Mitrovic wrote:
> On Saturday, 14 December 2024 at 08:46:35 UTC, Walter Bright wrote:
>> Now that this has been merged into master, what are your reactions?
> 
> I posted this same question in the announcement thread, but I'm curious 
> how we're going to make this work with dependencies.
> 
> I can't enable `-preview=safer` only on my own code. It applies 
> transitively to everything that's being imported.
> 
> It would be useful to be able to limit this flag to specific packages. 
> So that I can enable it for only the code I'm in control over. But that 
> could complicate the compiler, I understand.
> 
> Right now this feature is pretty much dead in the water for me if I 
> can't compile my own code with the feature on because some dependency is 
> not `-preview=safer` compatible.

This is solvable using a prefix switch. Of course build managers will 
need to support this style of dflags.

Both editions and external import switch require the refactoring work to 
make this work, and both I intend to do this month.

https://github.com/dlang/dmd/pull/20623

However, given that this isn't meant to remain a switch, I am 
unconvinced that it requires this treatment. Perhaps it warrants 
discussion though.



More information about the Digitalmars-d mailing list