DIP69 - Implement scope for escape proof references
Dicebot via Digitalmars-d
digitalmars-d at puremagic.com
Mon Dec 8 09:39:40 PST 2014
On Monday, 8 December 2014 at 16:57:44 UTC, Marc Schütz wrote:
>> Two issues immediately pop up:
>>
>> 1) scope is not transitive thus it doesn't work at all - you
>> still can store slice of `scope string` as only actual
>> ptr+length struct is protected.
>>
>> 2) even if it worked, existing definition of scope return
>> value makes it impossible to use in typical idiomatic
>> pipeline: `file.byLine.algo1.algo2`. Either algoX is defined
>> to take `scope ref` and thus can't return it or it is defined
>> to take `ref` and can't take another `scope ref` as an
>> argument.
>
> That's why I asked the question in
> http://forum.dlang.org/post/xdjsmwocbtxovjnathek@forum.dlang.org
> . It seems Walter wants to allow passing `scope ref` to `ref`,
> but then automatically treat a normal `ref` of the second
> function as if it were `scope ref`. But I can't quite see
> through it :-(
Yes I have seen that thread and have no idea what Walter has
meant either. His answer only makes sense if return value scope
is supposed to be inferred from body - what when bodies are
guaranteed to be there everything can be inferred anyway.
More information about the Digitalmars-d
mailing list