Tue 22 Nov 2016 09:26:45 PM UTC, comment #10:
This issue is still present in Octave 4.2.0.
The code example from comment #0 gives still the same results in Octave.
There is a patch submitted in comment #4 (that still lacks the possibility to clear global variables).
|
Thu 21 Aug 2014 12:59:10 PM UTC, comment #9:
This patch seems incomplete. It's not implementing the "clear GLOBAL x" syntax for also clearing global variables.
|
Wed 20 Aug 2014 06:33:50 PM UTC, comment #8:
A patch for this bug has been provided exactly one year ago :))
Anything wrong with my patch ?
|
Tue 20 Aug 2013 03:55:14 PM UTC, comment #7:
You are right. The documentation issues about -x
are another item.
Best to wait until your patch has been pushed and then
see what may need to be done about doc and tests.
Thanks for the opinion about the options and their
arguments counting as arguments to clear. This seems
reasonable. But, some thought should still be given
to this ansd other items like what combinations of
options are allowed. i.e. does:
clear -g -x foo
make sense, or is global assumed? If global is assumed
is there a way to use -x but only on non-global?
And, of course, needs Matlab checking...
All this is for the new bug report.
|
Tue 20 Aug 2013 02:24:31 PM UTC, comment #6:
I would say that this issue (doc not clear enough about `-x', no test for the behaviour of clear with `-x', etc.) deserves another bug report, with examples of situations where the documentation is not precise enough concerning `-x'.
THIS bug report is about the Matlab-incompatible behaviour of `clear' (when called with no input arguments). I believe that my patch fixes the problem, and that the documentation is now updated accordingly. Don't you agree ?
(To answer your question anyway: `clear -x foo' is the same as `clear ("-x", "foo")' and should therefore be considered, IMO, as a call with two arguments.)
|
Tue 20 Aug 2013 01:53:41 PM UTC, comment #5:
This does improved the documentation, but it does not
appear to clarify the behavior of:
clear -x foo
Specifically, is this treated as a use with one or
more arguments, or is -x foo treated as an option?
It might be useful to have one or more tests which
check for correct operation of -x.
Thanks.
|
Tue 20 Aug 2013 08:18:49 AM UTC, comment #4:
Here is a new version of my patch, with doc fixes as well.
@Michael: I believe it improves on the paragraph you quote, can you tell me if it sounds better ? If not, can you be more specific on what needs to be improved ?
(file #28881)
|
Tue 20 Aug 2013 12:48:56 AM UTC, comment #3:
It appears that the indended behavior is implemented.
But, the documentation does not seem to give a clear
explanation. The behavior of, fo example,
clear -x x2
is not clear. A user might think that x2 is an
argument, and then use the documentation section
that says:
=======================
If 'clear' is called without any arguments, all user-defined
variables (local and global) are cleared from the symbol table. If
'clear' is called with at least one argument, only the visible
names matching the arguments are cleared.
=======================
How is the negation of this explanation to be interpreted?
|
Mon 19 Aug 2013 06:53:26 AM UTC, comment #2:
Here is a patch that seems to do the job.
(file #28874)
|
Thu 15 Aug 2013 11:26:56 AM UTC, comment #1:
Related thread on maintainers list :
http://octave.1599824.n4.nabble.com/Compatibility-considerations-of-quot-clear-quot-td4656597.html
|
Thu 15 Aug 2013 10:14:32 AM UTC, original submission:
Calling "clear" from the prompt or from within a function currently removes all variables from both the current (base or local) workspace and the global workspace.
The following code demonstrates this:
For Matlab compatibility, "clear" should only remove variables from the current (base or local) workspace, but not from the global workspace.
|