[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bug on octave 3.1.51+ with pkg install
From: |
Jaroslav Hajek |
Subject: |
Re: Bug on octave 3.1.51+ with pkg install |
Date: |
Thu, 21 Aug 2008 07:47:02 +0200 |
On Wed, Aug 20, 2008 at 9:59 PM, John W. Eaton <address@hidden> wrote:
> On 20-Aug-2008, John W. Eaton wrote:
>
> | On 18-Aug-2008, Jaroslav Hajek wrote:
> |
> | | Since there is no reason to wrap the subfunction
> | | is_architecture_dependent in an identity anonymous function, the
> | | attached workaround should make the problem vanish (and it is not a
> | | temporary solution).
> |
> | I applied the changeset.
> |
> | | Still, the underlying problem persists, as the subfunction seem to be
> | | unreachable in an anonymous function. Not always, though: it seems to
> | | work when pkg.m is copied into local directory. I'll try to submit a
> | | new bug report for this.
> |
> | Does anyone have a simpler test case that shows the problem? That
> | would help, but either way I'll try to look at this problem sometime
> | this week.
>
> I found a simpler case:
>
> function foo ()
> c = {-1, 0, 1};
> cellfun (@(x) sub2 (x), c)
> sub1 (c);
> endfunction
> function sub1 (c)
> cellfun (@(x) sub2 (x), c)
> endfunction
> function y = sub2 (x)
> y = x > 0;
> endfunction
>
> I think the attached patch should solve the problem.
>
> This code will probably have to change again in order to properly
> handle nested functions (not planned until after 3.2).
>
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?
> jwe
>
>
> # HG changeset patch
> # User John W. Eaton <address@hidden>
> # Date 1219262234 14400
> # Node ID 24701aa75ecbe5f64da30b756890888a858ef029
> # Parent faf0abc5fd515423c7b95083b03260bdfcc6f777
> scope fixes for anonymous and inline functions that appear inside subfunctions
>
> diff --git a/src/ov-fcn-inline.cc b/src/ov-fcn-inline.cc
> --- a/src/ov-fcn-inline.cc
> +++ b/src/ov-fcn-inline.cc
> @@ -91,7 +91,20 @@
> octave_user_function *uf = fcn.user_function_value ();
>
> if (uf)
> - uf->stash_parent_fcn_scope (octave_call_stack::current_scope ());
> + {
> + octave_function *curr_fcn = octave_call_stack::current ();
> +
> + if (curr_fcn)
> + {
> + symbol_table::scope_id parent_scope
> + = curr_fcn->parent_fcn_scope ();
> +
> + if (parent_scope < 0)
> + parent_scope = curr_fcn->scope ();
> +
> + uf->stash_parent_fcn_scope (parent_scope);
> + }
> + }
> }
> }
>
> diff --git a/src/pt-fcn-handle.cc b/src/pt-fcn-handle.cc
> --- a/src/pt-fcn-handle.cc
> +++ b/src/pt-fcn-handle.cc
> @@ -114,7 +114,13 @@
> if (curr_fcn)
> {
> uf->stash_parent_fcn_name (curr_fcn->name ());
> - uf->stash_parent_fcn_scope (curr_fcn->scope ());
> +
> + symbol_table::scope_id parent_scope = curr_fcn->parent_fcn_scope ();
> +
> + if (parent_scope < 0)
> + parent_scope = curr_fcn->scope ();
> +
> + uf->stash_parent_fcn_scope (parent_scope);
> }
>
> uf->mark_as_inline_function ();
>
>
--
RNDr. Jaroslav Hajek
computing expert
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz
- Re: Bug on octave 3.1.51+ with pkg install, Michael Goffioul, 2008/08/18
- Re: Bug on octave 3.1.51+ with pkg install, David Bateman, 2008/08/18
- Re: Bug on octave 3.1.51+ with pkg install, Jaroslav Hajek, 2008/08/18
- Re: Bug on octave 3.1.51+ with pkg install, David Bateman, 2008/08/18
- Re: Bug on octave 3.1.51+ with pkg install, John W. Eaton, 2008/08/20
- Re: Bug on octave 3.1.51+ with pkg install, John W. Eaton, 2008/08/20
- Re: Bug on octave 3.1.51+ with pkg install,
Jaroslav Hajek <=
- Re: Bug on octave 3.1.51+ with pkg install, John W. Eaton, 2008/08/21