help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Call by Reference


From: CdeMills
Subject: Re: Call by Reference
Date: Fri, 22 Oct 2010 09:44:08 -0700 (PDT)


Erik Stensmo wrote:
> 
> Hi,
> 
> I found some pages stating that Octave does not support call by reference.
> As I understood it, if you modify a function argument (such as an element
> in
> a matrix passed as an argument), Octave will copy the argument (and hence
> make a call by value). How are you supposed to write well structured code
> without a performance hit? Include files? I think Octave should support
> call
> by reference.
> 

That's annoying from a performances point of view, true. OTOH, let us
suppose you're debugging some function. You enter the body, perform a few
operations, then stop at a breakpoint. There, you decide the code is bogus,
and you hit Control-C. With the actual implementation, you're back at the
top level. All of your variables are still at the state they were BEFORE
calling the function. So you may modify its code, and repeat the call. 

If you did work by with references AND the original variable was modified,
then using Control-C will bring back you at the main level, but your
variable is modified. Broken. Lost. Whatever. You have to regenerate it in
order to retest the function.

As Octave is a scripting language, and because during the setup phase it is
very convenient to have a function interrupted while keeping the top-levels
variables, I prefer not to have call by reference. 

Regards

Pascal
-- 
View this message in context: 
http://octave.1599824.n4.nabble.com/Call-by-Reference-tp3007071p3007521.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]