Attribute transference from callbacks?

Richard (Rikki) Andrew Cattermole richard at cattermole.co.nz
Sun Dec 15 07:04:54 UTC 2024


On 15/12/2024 7:47 PM, Zach Tollen wrote:
> In order to get it working, you have to make sure that the throw can't 
> escape:
> 
> |void j(void delegate() @noimply(throw) sink) { // passes, statically 
> checks that the call to sink() takes place in a context that can't throw 
> try { sink(); } catch(Exception) {} } void k() nothrow { // passes(!) 
> because the parameter in j() has been statically confirmed to not 
> propagate the throw j(() { throw new Exception(""); } ); } |
> 
> I believe this system has all the benefits of the other suggestions, but 
> with almost no syntactic noise.

``nothrow`` is a very bad example to give here.

In fact, it needs an entirely separate mechanism from the others.

It isn't boolean, and has codegen changes associated with it.

Also in your example, the delegate could be marked as throwing and it 
would work today.

``nothrow`` is already scope aware.



More information about the Digitalmars-d mailing list