bugGNU Octave - Bugs: bug #39790, "clear" also removes...

 
 

bug #39790: "clear" also removes variables from the global workspace

Submitted by:  Julien Bect <jbect>
Submitted on:  Thu 15 Aug 2013 10:14:32 AM UTC  
 
Category: InterpreterSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Matlab Compatibility
Status: Patch SubmittedAssigned to: None
Originator Name: Julien BectOpen/Closed: Open
Release: devOperating System: GNU/Linux

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

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.

Jordi GutiƩrrez Hermoso <jordigh>
Project Administrator
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 ?

Julien Bect <jbect>
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.

Michael Godfrey <godfrey>
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.)

Julien Bect <jbect>
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.

Michael Godfrey <godfrey>
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)

Julien Bect <jbect>
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?

Michael Godfrey <godfrey>
Mon 19 Aug 2013 06:53:26 AM UTC, comment #2:

Here is a patch that seems to do the job.

(file #28874)

Julien Bect <jbect>
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

Julien Bect <jbect>
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.

Julien Bect <jbect>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #28881:  jbPatch_clear_2.patch added by jbect (3kB - text/x-patch)
file #28874:  jbPatch_clear.patch added by jbect (1kB - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by godfrey (Posted a comment)
  • -unavailable- added by jordigh (Updated the item)
  • -unavailable- added by jbect (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 20 Aug 2013 08:18:49 AM UTCjbectAttached File-=>Added jbPatch_clear_2.patch, #28881
    Mon 19 Aug 2013 01:00:12 PM UTCjordighStatusNone=>Patch Submitted
    Mon 19 Aug 2013 06:53:26 AM UTCjbectAttached File-=>Added jbPatch_clear.patch, #28874

    Back to the top


    Powered by Savane 3.1-cleanup