News for hackers. Stuff that matters.
Re:Should function arguments be reassignable or mutable? by adrianmonk on Tuesday January 02, 2018 @02:20AM (#16050425)
You can't generalize across all languages that modifying an argument modifies something visible outside the function. It is true in languages that have pass by reference (C++ with &, Pascal, others) and it isn't true in languages which have pass by value (C, Java).

And yes, passing a reference or pointer by value enables you to have effects that are visible outside the function, but if you copied the reference or pointer value to a local variable, you still could have effects visible outside the function, so that isn't a question of how arguments should be treated; it's a general question of how functions should behave.

There are no comments on this comment yet.