Trying to use Mir ion, its a perfect example of the failure of D's attribute system
H. S. Teoh
hsteoh at qfbox.info
Fri Jan 20 04:28:01 UTC 2023
On Thu, Jan 19, 2023 at 07:41:02PM -0800, Walter Bright via Digitalmars-d wrote:
> On 1/19/2023 7:19 PM, H. S. Teoh wrote:
> > This is a flaw in the language: there is no way to express that
> > `process`'s attributes inherit from the passed-in delegate. This
> > has been a pain point for years.
>
> void process()(void delegate() userData) {}
Code:
````
void process()(void delegate() cb) { cb(); }
void gcFunc() {
int[] a;
process({ a = new int[10]; });
}
void nogcFunc(void delegate() @nogc cb) @nogc {
process(cb);
}
````
Compiler output:
````
/tmp/test.d(9): Error: `@nogc` function `test.nogcFunc` cannot call non- at nogc function `test.process!().process`
````
Nope, doesn't work.
T
--
Obviously, some things aren't very obvious.
More information about the Digitalmars-d
mailing list