@trusted attribute should be replaced with @trusted blocks

ag0aep6g anonymous at example.com
Wed Jan 15 18:58:40 UTC 2020


On 15.01.20 19:38, Johannes Pfau wrote:
> Am Wed, 15 Jan 2020 19:06:11 +0100 schrieb ag0aep6g:
[...]
> I think it shouldn't be much of a problem, as there is a very nice
> transition path:
> 
> * Add @system block support
> * Add -transition=systemBlocks which enforces @system blocks in trusted
> functions
> * Users gradually add @system blocks to their trusted functions, until
> everything compiles with -transition=systemBlocks. If you did not add all
> blocks yet, your code will still compile fine without -
> transisition=systemBlocks
> * -transition=systemBlocks becomes default

If that's deemed acceptable, I'm on board. But the alternative requires 
zero work from users (if we just keep @trusted functions around as 
legacy cruft).

>> But as Steven says, it can be done when we use @trusted blocks instead
>> of @system blocks and @safe instead of @trusted on the function. I.e.:
[...]
> I don't really like this. It makes @trusted functions completely useless
> legacy cruft. And there's no longer any way to annotate a function as
> 'this is 100% safe code', so then you'll have to check every safe
> function as thoroughly as trusted functions.

You already have to check for @trusted nested functions if you want to 
make sure an @safe function is really 100% safe. And those already 
routinely leak their unsafety into the surrounding @safe function. I 
don't see what would change in that regard.


More information about the Digitalmars-d mailing list