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: John W. Eaton
Subject: Re: Realtime cost of call by value
Date: Fri, 31 Oct 2003 14:10:21 -0600

On 31-Oct-2003, address@hidden <address@hidden> wrote:

| In Scheme, lists & vectors are passed as references to those data
| structures. "set!" mutates the current environment's binding of
| identifiers to values. "vector-set!" mutates the pointers of the
| elements of the given vector ( Scheme's array data type). Since it
| doesn't operate on identifiers, there's no oddity.

But it is a bit odd, because some operations change the value of the
passed variable in the scope of the caller and some do not.  This may
seem perfectly natural to you if you write Scheme all day long, but it
would confuse the heck out of most of the Octave/Matlab users I know.
They would forget and do something like

  function foo (x)
    ...
    x(i,j) = 42;
    ...
  endfunction

and then be really confused after doing

  a = ...;
  foo (a);

because now the value of a has suddenly changed after calling foo.

I'm not saying that it is not useful, just that this kind of behavior
is not consistent with the way that Octave/Matlab is defined.

| It is very clear where this would be useful in Octave: in how arrays,
| cell arrays, and the soon-to-be-deprecated list types are handled in
| function calls.

Sure, there's no question that it could be useful.  It would also be
confusing, and disastrously inconsistent with the way that Matlab
works.

jwe



-------------------------------------------------------------
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]