When developing @safe @nogc nothrow code, the mantra needs repeated on each module and each aggregate in the module. This is verbose and has little value for the reader, more noise in the code.
Currently adding module level attributes is not allowed:
---
@nogc module foo;
---
Error: @nogc attribute for module declaration is not supported
Would be nice to able to annotate whole modules (including aggregates inside the module) with a set of attributes - this will reduce the clutter and actually be useful as a documentation for readers.
Comment #1 by b2.temp — 2018-12-10T12:01:04Z
yes but no restrictions ?
@trusted module stuff;
<plenty of unsafe stuff here>
__EOF__
Comment #2 by radu.racariu — 2018-12-10T12:13:16Z
You can do this ATM with global declarations
---
@trusted:
---
or on aggregates
---
@trusted struct Foo
---
so there is no change on how you can shot yourself in the proverbial foot.
Comment #3 by radu.racariu — 2018-12-11T15:42:55Z
This https://atilanevesoncode.wordpress.com/2018/12/11/what-d-got-wrong/ points out the "attribute soup" issue, which could be ameliorated by this feature request. One can simply group similar concerning code with certain attributes in modules and thus greatly reduce the number of attribute declarations inside modules and module members.
Comment #4 by robert.schadek — 2024-12-13T19:01:35Z