Would like to see ref and out required for function calls

Jonathan M Davis jmdavisProg at gmx.com
Sat Sep 8 10:30:36 PDT 2012


On Saturday, September 08, 2012 17:05:25 Nick Treleaven wrote:
> As an option it would serve no practical purpose other than documentation.

It's worse than that. It's not even documentation that you can trust. If it 
were optional, and ref were used in a function call, then you know that the 
argument is being passed by ref (since presumably, you'll get a compilation 
error if it's not), but if there is no ref, it tells you _nothing_. It could 
be ref, but it might not be. And if you used ref at the call site frequently, 
then the lack of ref would end up giving the false impression that the 
argument wasn't being passed by ref in the case where the ref was forgotten.

There's some argument for requiring it (though at this point in its 
development, I think that it's too late to make it required even if it were 
determined that that were desirable), but making it optional is _definitely_ a 
bad idea IMHO.

- Jonathan M Davis


More information about the Digitalmars-d mailing list