DIP74 updated with new protocol for function calls

Zach the Mystic via Digitalmars-d digitalmars-d at puremagic.com
Sun Mar 1 08:08:15 PST 2015

On Sunday, 1 March 2015 at 08:57:17 UTC, Matthias Bentrup wrote:
> Note that you can get the same issue without duplicate 
> parameters, if you pass an alias to a global variable.
> static A a;
> void fun(A x) {
>   a = null; // Releases x
>   x.func();
> }
> void main() {
>   a = new A();
>   fun(a);
> }

Well don't do that... :-)

Looks like a fly in the ointment. The most straightforward 
solution is to always add the opAdd/Release cycle when passing 
globals to impures. That's probably good enough. You probably 
don't pass a global to an impure very often anyway.

More information about the Digitalmars-d mailing list