octave-maintainers
[Top][All Lists]
Advanced

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

Re: clear all inside function


From: Jaroslav Hajek
Subject: Re: clear all inside function
Date: Wed, 10 Jun 2009 15:27:19 +0200

On Wed, Jun 10, 2009 at 3:17 PM, John W. Eaton<address@hidden> wrote:
> On 10-Jun-2009, Jaroslav Hajek wrote:
>
> | On Tue, Jun 9, 2009 at 5:12 PM, John W. Eaton<address@hidden> wrote:
> | > What is supposed to happen with "clear all" inside a function?
> | >
> | > Given the claim that the program posted here
> | >
> | >  https://www-old.cae.wisc.edu/pipermail/help-octave/2009-June/014713.html
> | >
> | > works in Matlab, it seems it should not be clearing functions.  I
> | > guess this works in 3.0.x, but with the current sources, and a .m file
> | > containing the following
> | >
> | >  function main ()
> | >    clear all
> | >    sub
> | >  end
> | >  function sub ()
> | >    'this is sub'
> | >  end
> | >
> | > I see
> | >
> | >  octave:2> main
> | >  error: `sub' undefined near line 3 column 3
> | >  error: called from:
> | >  error:   /scratch/jwe/build/octave/main.m at line 3, column 3
> | >
> | > jwe
> | >
> |
> | Matlab explicitly says that
> | "All functions and global variables are cleared in both the function
> | workspace and in your base workspace"
>
> If that's correct, then how does the above work in Matlab?  Can
> someone else verify that it does in fact work?
>

Maybe it is true, and Matlab simply can automatically find
subfunctions when in a parent function.
I do, however, consider this a totally useless feature. Why the hell
would anyone want to clear all functions within a function?


-- 
RNDr. Jaroslav Hajek
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz



reply via email to

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