On Thursday, 7 February 2013 at 19:49:27 UTC, Walter Bright wrote:
On 2/7/2013 6:15 AM, Zach the Mystic wrote:
Can you tell me if you consider my proposal with regard to making ref safe and complete simple and intuitive both for compiler and user, and if not, why? (I
don't have an opinion about '&' yet.)

http://forum.dlang.org/thread/[email protected]#post-bsgrtofehxfjmzkaedfr:40forum.dlang.org


I don't know if it's complete and safe. It's not something that can be determined with a quick read.

Okay. But at least that's a 'check' on simple and intuitive?

As far as why I think it's safe, my investigation led me to conclude that the key question was, how do I know whether to treat the return value of a ref function which accept a ref as local or global? I pass a value into a mysterious box, how do I know whether what comes out the other end is related to what I passed in, or something completely different? All the cases DIP25 takes care of are the ones which can be known just by the peculiarities of the call and signature, but many cases just leave you in the dark. The only way the compiler can know for sure without help from the function signature is by dipping into the function's code to take a look, which seems like too high a price to pay. About a month ago Jonathan M Davis brought this up and pointed out that the PIMPL idiom occasionally banishes altogether that opportunity for the compiler.

After a few tries, I realized that 'out' was actually still available to use for this purpose, which is either pure luck (possible) or a hidden byproduct of the fact that 1) it's a good keyword to begin with or 2) there's a secret truth to its interchangeability with 'ref' which applies to return values as well as to parameter tags.

Reply via email to