questions are in the below code.
Although I'm pretty sure of the answer, I still feel a little uncomfortable, because I feel that the format of the body of Module[] is a bit "dead", seems that the Return statement had to be put at last line.
Is the value of Module[] is always equal to the last line which is not followed by semicolon;?
Is there a concept of "Return value of a function" including Module[] in Mathematica? and whenever you use the function in any expression, the function is always equal to the return value of the function?
i don't know how to ask, seems no questions here but a little uncomfortable for me(i'm not sure whether you can get the points of my uncomfortablement). Is there existing some reference about this?
f[x_,y_,z_]:=Module[{a,b,c},a+b;b+c;...;x+y+z]
(* is equal to the following c-function? *)
Head[x+y+z] f(Head[x] x ,Head[y] y, Head[z] z)
{
Head[a] a; Head[b] b; Head[c] c;
a+b; b+c; ....;
return x+y+z;
}
(------------------------------------------)
f[x_,y_,z_]:=Module[{a,b,c},a+b;b+c;...;x+y+z;] (in my test return Null)
(* is equal to the following c-function? *)
void f(Head[x] x ,Head[y] y, Head[z] z)
{
Head[a] a; Head[b] b; Head[c] c;
a+b; b+c; ....;
return ;
}
RETURN(STATUS). so one knows what variable is being returned also. common exit code also include any common cleanup code by the function (such as closing files, printing messages ,etc). As far as looking all the places whereSTATUSis being assigned to, yes, this does not eliminate that. But this is something one has to do anyway. The common exist option only reduces one aspect of code understanding. Not everything. – Nasser Jan 15 '23 at 21:06