Why is it that so many programming languages make it possible for a function to modify an object passed to it as a parameter, without having some sort of syntax to make that clear to the caller. Eg consider:
SomeObject A(15), B
B = DoSomething(A)
print(A + " " + B + "\n)
Reading that code you would expect the output to be something like "15 75", ie A is what you constructed it to. However most languages make it possible for DoSomething to change the value of A. In C++ you can tell if its possible or not by looking at the declaration of DoSomething, eg by looking is the parameter is defined as a non const reference. However in many languages, such as Python there is really no way to tell without reading through the code for the function to make sure it never changes A.
Ive been bitten by this on a few occasions, especially when trying to work with someone else's code which uses this behaviour and usually results in going through the entire piece of code line by line to try and find what's changing the parameter...
Why is it that languages don't generally require some explicit syntax by the calling to say "yes this object can be modified", eg say "B = DoSomething(inout A)"?
Is there any codeing standards that help to prevent problems occurring, apart from the "never modify a parameter passed into the function"?