ref parameters: there is no escape

Jakob Ovrum jakobovrum+ng at gmail.com
Sun Aug 14 08:33:48 PDT 2011


On 2011/08/15 0:28, dsimcha wrote:
> I think this is an absolutely terrible idea, unless it has an "I know
> what I'm doing, let me cast away the safety" loophole. Consider the case
> of designing a D wrapper for C functionality.
>
> // C, we know it doesn't escape its parameters but the compiler doesn't.
> void cFun(int* a, int* b);

What if it was allowed if the parameters were explicitly marked scope?

void cFun(scope int* a, scope int* b);

I can imagine it being a proper inconvenience most of the time though, 
with many libraries not escaping a lot at all, you'd have to mark pretty 
much everything scope manually.


More information about the Digitalmars-d mailing list