DIP1028 - Rationale for accepting as is

Q. Schroll qs.il.paperinik at gmail.com
Thu May 28 01:09:54 UTC 2020


On Wednesday, 27 May 2020 at 13:42:08 UTC, Andrej Mitrovic wrote:
> There could be a simple solution to that:
>
> Ban `@trusted:` and `@trusted { }` which apply to multiple 
> symbols. Only allow `@trusted` to apply to a single symbol. For 
> example:

That came to my mind immediately. I'm not entirely sure about 
`@trusted { }`, because it might be handy at times (I don't use 
`@attribute { }` often). But `@trusted:` is such that it is 
almost guaranteed that sooner or later it's applied to something 
it wasn't intended to. I have no idea if that's the case with 
braces.
Since `@trusted` is intended to be special, I'd go the full route 
and ban it for any non-direct use. Mass-`@trusted` makes no sense 
logically: If the programmer is required to investigate a 
function to determine it's `@safe`-ty, the time required for the 
investigation clearly outweighs the time marking the function 
`@trusted` (if the investigation has that result, of course), 
even if the judgment is fast.

If people go through a whole lot of `extern(C)` declarations and 
marks them @trusted individually because neither `@trusted:` nor 
`@trusted { }` did the job, it may occur to them it's probably 
not the right thing.

I really hope this makes it through.


More information about the Digitalmars-d-announce mailing list