Lisp 都是 pass by reference,但是沒有 Pascal/Ada/C 的那种 out parameter。虽然現在都不鼓励用 out parameter 了。
Procedure WriteToB(Out B : Integer);
begin
B:=2;
end;
Call by value/call by reference/call by sharing/pass by reference 混在一起傻傻分不清。
The description “call by value where the value is a reference” is common (but should not be understood as being call by reference); another term is call by sharing. Thus the behaviour of call by value Java or Visual Basic and call by value C or Pascal are significantly different: in C or Pascal, calling a function with a large structure as an argument will cause the entire structure to be copied (except if it’s actually a reference to a structure), potentially causing serious performance degradation, and mutations to the structure are invisible to the caller. However, in Java or Visual Basic only the reference to the structure is copied, which is fast, and mutations to the structure are visible to the caller.