escaping addresses of ref parameters - not

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon Feb 9 07:34:41 PST 2009


Daniel Keep wrote:
> I've used ref arguments in the past to wrap a C api that expects
> pointers.  I'm fine with this so long as there is a way to break out of
> it (in regular D, at least) that makes it abundantly clear you need to
> know what you're doing.
> 
> Something like:
> 
> void wrapSomeCApi(ref Foo arg)
> {
>     Foo* argptr = ref_unsafe_escape(arg);
>     some_c_api(argptr);
> }
> 
> Incidentally, I don't suppose we can get ref variables while Walter's at
> it? :P

The entire scheme relies on ref not being allowed outside function 
signatures. If ref vars were allowed, they could be escaped.

Andrei



More information about the Digitalmars-d mailing list