Would like to see ref and out required for function calls
Jonathan M Davis
jmdavisProg at gmx.com
Thu Sep 13 08:17:48 PDT 2012
On Thursday, September 13, 2012 12:34:34 Andrei Alexandrescu wrote:
> I don't think there would be problems with allowing ref/out optionally
> at the call site. The thing is, however, that in this matter reasonable
> people may disagree.
I really think that optionally allowing ref and out at the call site is more
damaging than beneficial. _Requiring_ it could be beneficial, since then you
know that the arguments are being taken by ref, but if it's optional, it gives
you a false sense of security and can be misleading. Presumabyl, any time that
ref or out is used at a call site, presumably the compiler would check that it
really was passed by ref our out, which would be of some benefit, but it would
mean _nothing_ if ref or out wasn't used, since it could be an argument being
passed by ref but which wasn't marked or an argument which wasn't passed by
ref at all. So, if you have code where ref and out is used at the call site
semi-religiously, then it'll become very easy to falsely think that the lack
of them means that ref or out _isn't_ being used when it really is, misleading
people about what the code is doing.
So, if it wasn't going to break so much code, I'd see some argument for
changing things so that ref and out were required at the call site, but I
think that _allowing_ them but not requiring them would actually be
detrimental.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list