Kevin,
What are you trying to do with these techniques? They are not exactly 
equivalent.

The pass-by-reference technique is generally used to avoid the use of 
indirection and to
make the code cleaner and more efficient. It cannot be used where the target 
array is a
global.

The indirection technique applies equally well to global arrays as to local 
arrays and can
therefore hide the fact that scratch arrays might be global. This can be useful 
on MUMPS
implementations with limited memory space available for local variables.

Kevin wrote:
>I have found that there are two ways that parameters can be passed by 
>reference:
>
>MyFunct1(VarName)
>     ;"Input: VarName, the NAME OF the variable to alter
>     set @VarName@(1)="Hello"
>     quit
>
>MyFunct2(VarArray)
>     ;"Input: VarArray -- PASS BY REFERENCE, the array to alter.
>     set VarArray(2)="There"
>     quit
>
>And These can be called as follows:
>
>Main
>   new Array
>
>  do MyFunct1($name(Array))
>  do MyFunct2(.Array)
>  zwr Array(*)
>  quit
>
>This should output this:
>Array(1)="Hello"
>Array(2)="There"
>
>
>But I have just encountered an issue when I try to mix these two.  For
>example, The following wouldn't work, I believe
>
>
>MyFunct1(VarName)
>     set @VarName@(1)="Hello"
>    do MyFunct2([EMAIL PROTECTED])  <------------- This wouldn't work
>     quit
>
>MyFunct2(VarArray)
>     set VarArray(2)="There"
>     quit
>
>
>Main
>  new Array
>  do MyFunct1($name(Array))
>  zwr Array(*)
>  quit
>
>
>So I have written some functions using both calling methods, and I
>have just now had reason to call one from another.
>I know that I could create a new array, merge it, pass that array,
>then when the function returns merge it back.  But, is there a way to
>do this directly--i.e. achieve my erroneous line listed above, perhaps
>with different syntax?

---------------------------------------
Jim Self
Systems Architect, Lead Developer
VMTH Computer Services, UC Davis
(http://www.vmth.ucdavis.edu/us/jaself)


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Hardhats-members mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/hardhats-members

Reply via email to