help-octave
[Top][All Lists]
Advanced

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

Re: Realtime cost of call by value


From: Glenn Golden
Subject: Re: Realtime cost of call by value
Date: Tue, 28 Oct 2003 15:20:02 -0700

(NOTE: This is an edited excerpt from an offline email exchange I had
with Tomer which was Cc-ed to John.  John asked me to keep the discussion
on the list rather than continuing with it offline. So here's the gist of
it, edited for brevity and clarity.   - Glenn)
-----

address@hidden writes:
> This means that if you merely follow that page's syntax, and declare a
> top-level variable using the 'global' "type", and declare that same
> variable with that same "type" in the functions that need to access
> it, then you've achieved the ability to reference the matrix without
> copying it to the "local scope" of the function.

I agree with the first part of your last phrase ("...you've achieved
the ability to reference the matrix..."), but I suspect that the second
part ("...without copying it...") may not true, although the behavior that
the user sees is exactly as if it were true.

What I believe the interpreter does when you access a global variable
from within an m-file function is to first perform a copy down of the
global's value to a temp variable in the interpreter, and then operate
on that temp.  When the function exits, if you've modified the temp
variable, then it copies the temp back up to the global. This is what
I've been doing in my feasibility DLD, using get_global_value() and
set_global_value().  I don't see any other way, but perhaps there is.
What about this link_to_global_variable() function, anyone know what
that's about?

Anyway, I sure hope I'm wrong on this. One of those cases where
it would really make my day to have someone tell me what a moron I
am and there really is a simple efficient way to accomplish this...
but I suspect it may have been done this way in order to maintain
consistentcy with the overall call-by-value semantics, in which case
the realtime costs are the same, and there's no clean way around it.


-Glenn



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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