I was taught long ago that "call by value" meant simply that whatever the 
target routine did to a parameter was not reflected back to the caller's 
argument. There are multiple possible implementations. One is to make a copy 
and pass the argument by reference to the copy. Another is to pass the actual 
value (somewhere, somehow).

For what it's worth, the internal PL/X that much of z/OS is written in only 
supports call by value for the cases where the argument fits within the "width" 
of a parameter list entry (by convention, 4-bytes for an AMODE 31 call, 8-bytes 
for an AMODE 64 call). PL/X's "call by value" never copies (accompanied by 
passing the copy by reference). We have many places where our dynamic storage 
is strictly limited such that "copy" is often not a possibility. So what 
happens if you have something larger than fits but don't want it changed? Too 
bad.  Or make your own copy. The interface definition shared by the source and 
target identifies whether the parameter is to be treated as input-only or not. 
It is up to the compiler to help identify places where the target code writes 
into something that is input-only and passed by reference.

That does not make this implementation "good" or "bad". Probably it's "good" in 
some ways, "bad" in others. It is what it is.

An interesting facet of this comes when passing an ALET (so that your argument 
can be addressed by its address and its ALET). In effect, the ALET really has 
to be passed not by reference in any way because otherwise you would have no 
way of identifying how to access the ALET and would have to have some 
rule/restriction about where that could live (maybe you can live with such a 
restriction, perhaps that the ALET must be in the primary address space; maybe 
you can't). So you pass the ALET by placing it in a parameter list slot where 
it is accessible according to the rules of how to access the parameter list 
(generally R1 and, if in AR mode, AR1). In some cases you can consider the 
"ALET and address" as occupying two slots in the parameter list, but in others 
you might want to take advantage of passing "one ALET" with the "knowledge" 
(AKA restriction) that multiple parameters are in the space identified by that 
single ALET . In restrictive cases you can pass something byvalue in a register 
(but that does not scale well).

Peter Relson
z/OS Core Technology Design


----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to