Bug on octave 3.1.51+ with pkg install

John W. Eaton jwe at bevo.che.wisc.edu
Thu Aug 21 10:21:54 CDT 2008


On 21-Aug-2008, Jaroslav Hajek wrote:

| Could there just be parentage relations between scopes? That seems
| simpler. A subfunction (or anonymous function) would just set up a
| proper parent scope for its local scope. Name lookup, when
| unsuccessful in a given scope, would simply proceed recursively on
| parent scope, until there is no parent. There would be no need for
| inherit (), I think.
| Or is there a catch that I don't see?

I think the call to symbol_table::inherit is needed to provide values
for the otherwise unbound variables in the anonymous function scope,
and those values must come from the current scope at the time the
anonymous function handle is created.  For example, try this:

  x = 1;
  afh = @() x;
  afh ()
  x = 2;
  afh ()

Both calls to afh should print ans = 1 even though the value of x in
the parent scope has changed to 2 by the time of the second call.

jwe


More information about the Octave-maintainers mailing list