DIP69 - Implement scope for escape proof references

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Mon Dec 8 13:12:01 PST 2014


On 12/8/2014 12:54 PM, Dicebot wrote:
> struct ByLine
> {
>      scope string front();
>      // ...
> }
>
> auto byLine(File file)
> {
>      return ByLine(file);
> }
>
> scope /* ref */ string foo(scope /* ref */ string input)
> {
>      return input[1..$];
> }
>
> void main()
> {
>      auto r = file.byLine.map!foo;
>      string s = r.front; // this should not compile
>      string s = r.front.dup; // this should compile
>
>      // how foo signature should look like for this to work?
> }

front() should return a 'scope ref string'.



More information about the Digitalmars-d mailing list