No, that's wrong. Pass-by-value with references as values, is not the same as pass-by-reference.
Plenty of people make the mistake of equating the two. They can get away with the misconception as long as they don't encounter a language like C# that features both reference types and optional pass-by-reference.
> According the SO definition, C is always pass by value
That's correct. C is always pass-by-value. You can get a similar effect to pass-by-reference, by passing a pointer.
> It pretty much applies to any language: ultimately you're passing a value from the caller to the callee.
That's incorrect. If the language has pass-by-reference semantics, then it does not copy the value, it passes the callee a reference to the variable. It's not true of pass-by-name, either, but don't know much about that strategy.
A good article on this topic is the documentation on C#'s ref keyword, which enables pass-by-reference. The article does a good job explaining the related concepts. [0]
The acid test for whether pass-by-reference is happening, rather than pass-by-value, is whether the asserts can fail in code along the lines of this Java code:
int myInt = 42;
doStuff(myInt);
assert(42 == myInt); // Ok
String myString = null;
doMoreStuff(myString);
assert(null == myString); // Ok
In Java, the asserts will never fail. The two methods called do not have access to either the myInt local or the myString local, they only have access to copies of the values held in the two locals. This is the reason Java would permit us to use the final modifier when declaring the two locals, without needing to know anything about either of the called methods.On the other hand, C# permits pass-by-reference. Here we'll suppose that both doStuff and doMoreStuff declared their parameters using the ref keyword:
int myInt = 42;
doStuff(ref myInt); // If callee uses 'ref' keyword, caller must use it too
assert(42 == myInt); // May fail
string myString = null;
doMoreStuff(ref myString);
assert(null == myString); // May fail
In this case, either assert may fail, depending on the behaviour of doStuff and doMoreStuff. The callees are given references to our locals, and so they may mutate our locals (as well as reading their values of course).Related to this, this is illegal in C#:
doStuff(ref 42); // Compile error. 42 is not a variable!
[0] https://docs.microsoft.com/en-us/dotnet/csharp/language-refe...