octave-maintainers
[Top][All Lists]
Advanced

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

Ambiguous documentation for "clear -all"


From: Rik
Subject: Ambiguous documentation for "clear -all"
Date: Sat, 17 Apr 2010 17:47:41 -0700

4/17/10

According to 'help clear', the option -all should clear local and global
symbols.

---------------------------------------------------------------------
The following options are available in both long and short form
    `-all, -a'
          Clears all local and global user-defined variables and all
          functions from the symbol table.
---------------------------------------------------------------------

However, Octave does not seem to actually remove the global variables, but
only remove them from view.  The following code shows this:

local_test_var = 1;
global global_test_var = 2;
whos
clear -all
whos
global global_test_var
global_test_var

My question is whether we need to clarify the documentation to reflect what
Octave actually does, or whether we should update Octave to do what the
documentation says it does?  It would also be useful if someone could run
the above code on Matlab ("clear -all" will need to be changed to "clear
all" for Matlab).

The documentation for Matlab's clear function is here:
http://www.mathworks.com/access/helpdesk/help/techdoc/ref/clear.html.  The
difference between "clear var" and "clear global var" is well explained.

---------------------------------------------------------------------
If name is global, clear removes it from the current workspace, but it
remains accessible to any functions declaring it global.
---------------------------------------------------------------------

So it appears, that 'clear -all' is roughly equivalent to 'clear *',
whereas I would have thought that 'clear -all' was equivalent to 'clear'
which does remove both local and global variables.  Again, maybe someone
can run the code above in Matlab and report what their parser thinks is
correct.

--Rik



reply via email to

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