Re: [DOS] Can we emulate "pass by reference" in Eu?
- Posted by Alex Caracatsanis <CaracatsanisA at ramsayhealth.com.au> Oct 19, 2004
- 496 views
Alex Caracatsanis wrote: > > Dear List > > For my general knowledge, rather than with a specific program in mind, I'd > like to > ask how to pass a non-global variable (two scenario's: an atom; a sequence) as > an argument > to: > 1 a procedure that changes the variable (eg increments it) > 2 a function that changes the variable (eg increments it) but returns some > other, different, > variable > > A "minimal" example to achieve the above, would be enough. > > Thank you > > Alex Caracatsanis > Maybe I should add: what I'm thinking about is something like this...
procedure incrementProcedure( object obj ) -- code that will increment the actual parameter (num), -- not a copy of it, such that num is now 11 or {11, 21} end procedure function incrementFunction( object obj ) object retVar -- code that will increment the actual parameter (num), -- not a copy of it, such that num is now 12 or {12, 22} -- code to do other things as well return retVar end function procedure main() atom num num = 10 sequence seq seq = {10, 20} object retVal incrementProcedure( num ) ? num -- now num = 11 retVal = incrementFunction( num ) ? num -- now num = 12 -- retVal is anything; not interested in it for now incrementProcedure( seq ) ? seq -- now seq = {11, 21} retVal = incrementFunction( seq ) ? seq -- now seq = {12, 22} -- retVal is anything; not interested in it for now end procedure main()
Hope that's clear. Thanks Alex Caracatsanis