On Mon, May 26, 2008 at 6:14 AM, catrope@svn.wikimedia.org wrote:
Partial revert of r35058: when something looks stupid, that doesn't mean it is. This is done because the function in question expects a reference.
This is what comments are for, so people don't say "WTF is this doing" and try to change it without understanding. :) I added one in r35350.
On Mon, May 26, 2008 at 6:20 AM, MinuteElectron minuteelectron@googlemail.com wrote:
Can we not modify Article::generateReason() to not forced a reference, since, AFAIK, you no longer have to explicitly state that a parameter should be a reference.
That's only for objects and maybe arrays. Simple stuff like integers are still passed by value unless specified otherwise.
You have to wonder why PHP complains when given a constant for a pass-by-reference function, though. I guess they figure that explicit pass-by-reference usually means that some kind of return value is stored in the variable and they don't want people to mistakenly ignore it, but it still seems fairly pointless to force people to manually create a throwaway variable. Oh well. Could we give the variable a default value, maybe, or does that not work for references?
Simetrical wrote:
You have to wonder why PHP complains when given a constant for a pass-by-reference function, though. I guess they figure that explicit pass-by-reference usually means that some kind of return value is stored in the variable and they don't want people to mistakenly ignore it, but it still seems fairly pointless to force people to manually create a throwaway variable.
Perhaps they were motivated by some dim memory of the legendary old FORTRAN compilers, where (since everything was passed by reference) if you ran the program
program main x = f(5) j = 5 stop
real function f(i) i = 42 return
it would set j to 42. (The program would, in effect, modify itself, you see.)
Steve Summit wrote:
Perhaps they were motivated by some dim memory of the legendary old FORTRAN compilers, where (since everything was passed by reference) if you ran the program
program main x = f(5) j = 5 stop real function f(i) i = 42 return
it would set j to 42. (The program would, in effect, modify itself, you see.)
WTF? (sorry, i couldn't resist. Nice for obfuscated code, though.)
wikitech-l@lists.wikimedia.org