Trying to use Mir ion, its a perfect example of the failure of D's attribute system
Ruby The Roobster
rubytheroobster at yandex.com
Fri Jan 20 13:33:31 UTC 2023
On Friday, 20 January 2023 at 13:08:46 UTC, Quirin Schroll wrote:
> On Friday, 20 January 2023 at 05:48:26 UTC, Steven
> ... [snip]
>
> If D added 1 fixed-name attribute variable per attribute (cf.
> `inout`), they could be spelled `@safety`, `purity`, `@gcness`,
> and `throwiness`.
>
> ```d
> void callInSequence(
> void delegate() @safety purity @gcness throwiness[] dgs
> ) @safety purity @gcness throwiness
> {
> foreach (dg; dgs) dg();
> }
> ```
> When called, the argument is a slice of delegates that are
> `@safe` or `@system` – `@safety` is replaced by that; that are
> `pure` or not – purity is replaced by that; that are `@nogc` or
> not – `@gcness` is replaced by that; that may throw or not –
> `throwiness` by `throw` or `nothrow`.
>
> [snip]
I second this, or a less verbose version of this. One who wishes
to vary all of the attributes shouldn't have to explicitly write
```@safety @gcness purity throwiness``` every time they want to
vary all of the attributes. Perhaps adding a keyword such as
```attrib``` to vary all attributes not specifically set is the
best course of action. Then we can write:
```d
void callInSequence(void delegate() attrib @safe dgs[])
{
foreach(dg; dgs)
dg();
}
```
This will require that all delegates be @safe, but there are no
other restrictions on their attributes.
More information about the Digitalmars-d
mailing list