Confirm: D escapes auto ref similar to Go language

Ali Çehreli acehreli at yahoo.com
Sun Aug 24 17:30:33 UTC 2025


On 8/24/25 8:03 AM, Brother Bill wrote:
 > auto ref string parenthesized(string phrase) {
 >      string result = '(' ~ phrase ~ ')';
 >      writeln("&result: ", &result);
 >      return result;      // ← compilation ERROR
 > }

First, thank you for reading the book and raising so many issues. Very 
much appreciated!

In this case, you used the body of a 'ref' function but compiled it as 
'auto ref'. Please remove 'auto' above.

Ali



More information about the Digitalmars-d-learn mailing list