aliasing expressions and identifiers

Nick Treleaven via Digitalmars-d digitalmars-d at puremagic.com
Mon May 30 07:23:19 PDT 2016


On Monday, 30 May 2016 at 14:18:38 UTC, Nick Treleaven wrote:
> On Monday, 30 May 2016 at 10:55:57 UTC, Marc Schütz wrote:
>>     auto tmp = stdin.byLine;
>>     auto lines = tmp.array;
>>
>> Here, `lines` contains references to the buffer owned by 
>> `tmp`, but doesn't escape (assuming `array` takes its argument 
>> by `scope` or however the final solution will look like).
>
> tmp and stdin.byLine are of type ByLine, whose front could be 
> scope/return to prevent escaping. Above array() does escape 
> ByLine.front so can't mark its argument with scope - the 
> compiler would error.

Sorry, I meant using array(scope R range) would not affect the 
compiler error when array attempts to escape range.front into its 
slice.



More information about the Digitalmars-d mailing list