ref parameters: there is no escape

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sun Aug 14 09:56:00 PDT 2011


On 8/14/11 11:50 AM, Jacob Carlborg wrote:
> On 2011-08-14 18:45, Andrei Alexandrescu wrote:
>> On 8/14/11 10:33 AM, Jakob Ovrum wrote:
>>> 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.
>>
>> Exactly. Using scope has been part of the discussion, and our agreement
>> was that it would be a lot of burden to require manual scope annotations
>> for non-escaping parameters.
>>
>> Andrei
>
> Can we do the opposite, somehow indicating that the parameters might
> escape?

We talked about this, too. I even aired ~scope. Such a change would be 
doable but is liable to break a lot of code.

Andrei


More information about the Digitalmars-d mailing list