Would like to see ref and out required for function calls

Sean Kelly sean at invisibleduck.org
Thu Sep 13 09:28:40 PDT 2012


On Sep 13, 2012, at 7:21 AM, Andrei Alexandrescu <SeeWebsiteForEmail at erdani.org> wrote:
> 
> One question Walter and I thought about a lot was whether we should disallow escaping addresses of ref parameters in general or only in @safe code. We decided to go for the latter in order to avoid breakage of existing code. Thoughts?

I love the idea.  However, this could complicate working with C APIs, particularly regarding structs which are often passed by reference as a matter of course.  For example:

struct some_c_struct {}

void fn(ref some_c_struct s) {
    some_c_func(&s);
}

I guess the only way to know if this will turn out to be a real issue is to give it a try though.


More information about the Digitalmars-d mailing list