help-octave
[Top][All Lists]
Advanced

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

Re: Call by Reference


From: Judd Storrs
Subject: Re: Call by Reference
Date: Fri, 22 Oct 2010 14:09:15 -0400

There is a trick from IDL that I think could help a lot of cases where
one wants pass-by-reference. It is called a function called
temporary(). Conceptually, what temporary() does in IDL is it deletes
the variable portion of its argument and returns the value the
variable had as if it was the result of an intermediate calculation
(IDL treats intermediate values differently than variables--I think
octave does, too but I'm not 100% certain about that). temporary() is
very useful in IDL because IDL understands that intermediates can be
modified in place so by declaring a variable to be temporary() the
memory copy can be avoided when the variable is modified inside the
function. [aside: IDL is sometimes pass-by-value and sometimes
pass-by-reference depending things that are not worth getting into
unless IDL is actually inflicted upon you]

>From what I understand, conceptually something similar should be
possible in octave. I work on large matrices doing image processing
type stuff and a long time ago I tried to implement this as an .oct
that modifies the reference counter of the octave_value if I remember
correctly. It seemed to work sometimes but there ended up being some
strange problems and I got stuck somewhere.

http://www-old.cae.wisc.edu/pipermail/octave-maintainers/2008-April/007096.html


--judd


reply via email to

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