On Monday, 8 December 2014 at 21:12:47 UTC, Walter Bright wrote:
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'.
That seems to contradict your other statement:
A 'scope ref' parameter may not be returned as a 'ref' or a 'scope ref'.
Please check `foo()` once more - it needs to accept scope (ref) to be able to accept ByLine.front as an argument. And it also needs to pass it down the call chain - but returning `input` by reference is illegal according to abovementioned rule.
