Comments inline (reply) below (without leading >; I don't seem to have that feature available).
________________________________ From: IBM Mainframe Discussion List <[email protected]> on behalf of Paul Gilmartin <[email protected]> Sent: Sunday, April 2, 2023 5:32 PM To: [email protected] <[email protected]> Subject: Re: ASM call by value On Sun, 2 Apr 2023 22:37:53 +0000, Frank Swarbrick wrote: >I'm just going to put this out there... Dingus has an online test C compiler, >which outputs the generated assembler. You can find it at >http://www.dignus.com/dcc/compileit.html. > Thanks. >I ran the following program through it. <snip!> > void fun1(tester *, int *); > void fun2(tester, int); > What do you see if you provide actual function bodies, not only prototypes/? (reply) Are you thinking the call sites will change at all, or do you just want to see how called functions handle the parameters? I can tell you for certain, even without doing it, that they (the called functions) are handled differently. They have to be, after all, based on the fact that the parameters are passed differently. ... >Something to note, and it's not supported by C as far as I am aware, is >neither of these are "pass by content". Pass by content is "pass address of a >copy of the field". So a copy is done, as with fun2, but the parameter list >pointed to by R1 is not the address of the copied fields but rather the >address of a parmeter list that contains the addresses of both copied fields. > Are the external semantics (not examining the generated assembly) of "pass by content" any different from "pass by value"? How? (reply) Call by content is enforced by the caller. Call by value is enforced by the callee. It would seem more efficient for the called function to perform the copy rather than the caller because the code to perform the copy would exist only once in the subroutine rather than at each point of call. (reply) well, as I said, the caller is the one who cares that the variable is not altered, and thus passes a copy. It could just as well be accomplished by copying the variable to a temp field and passing the temp field by reference. I mostly use it to pass a length "special register" value, CALL 'mysubr' USING BY REFERENCE my-string BY CONTENT LENGTH OF my-string. This can be "shortened: to CALL 'mysubr' USING my-string CONTENT LENGTH OF my-string. Because a COBOL special register itself is not updateable it cannot be passed by reference and must be passed by value. In general there isn't much need to pass an actual variable by content. -- gil ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [email protected] with the message: INFO IBM-MAIN ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [email protected] with the message: INFO IBM-MAIN
