Simplification of @trusted

RazvanN razvan.nitu1305 at gmail.com
Wed Jun 16 16:22:24 UTC 2021


On Wednesday, 16 June 2021 at 16:17:28 UTC, GrimMaple wrote:
> On Wednesday, 16 June 2021 at 15:58:23 UTC, RazvanN wrote:
>> On Wednesday, 16 June 2021 at 14:57:19 UTC, GrimMaple wrote:

> With my approach, you can still cover as many code @safe as you 
> want without lying to the end user about the function safety. 
> IMHO, if you perform @trusted operations in a @safe function, 
> the function cannot be called @safe .

But this is not true. As Paul Backus pointed out, you can still 
have
a @safe function that calls trusted functions. Your argument seems
to imply that @safe should never interact with @trusted code, 
which
to be honest will make it unusable.

>>> Overall, if something like this is implemented, it should 
>>> support all safety levels for blocks, including @safe and 
>>> @system, for consistency purposes

>
> The point is enabling @safe checks on parts of @system/@trusted 
> code, that otherwise would require weird solutions. Or, if you 
> prefer, to be consistent over the lang. I think it is more 
> predictable to the user, that if you can mark a block @trusted, 
> it can be marked @safe or @system as well

I understand, but my point is that if you have a @system function 
it is kind
of useless to have @safe portions of it, you still cannot call it 
from @safe code.
It makes much more sense to have a @safe function with small 
trusted blocks.


More information about the Digitalmars-d mailing list