bugGNU Octave - Bugs: bug #57604, Document how clear -v removes only...

 
 

bug #57604: Document how clear -v removes only local copy of global variable

Submitter:  Muhali <muhali>
Submitted:  Wed 15 Jan 2020 12:08:35 PM UTC
   
 
Category:  Documentation Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Documentation
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 6.0.90 Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 26 Jun 2020 09:01:34 PM UTC, comment #4: 

I re-wrote some of the chapter on global variables in the Octave manual, and added a specific Programming Note in the documentation for the clear() function which I think makes it clear what is happening.  See https://hg.savannah.gnu.org/hgweb/octave/rev/d747d57989e2

Marking as fixed and closing report.

Rik <rik5>
Group administrator
Thu 16 Jan 2020 03:30:28 PM UTC, comment #3: 

I don't think it is documented, but probably should be.  Let me hijack this bug report and change it to request that feature.

Rik <rik5>
Group administrator
Thu 16 Jan 2020 08:53:35 AM UTC, comment #2: 

I get the same behavior. And I didn't know about gvar surviving the clear command. Thanks for showing me! Is that (local instance of a global variable) documented somewhere?

The report can be closed.

Muhali <muhali>
Wed 15 Jan 2020 05:46:50 PM UTC, comment #1: 

Do you have a test case that demonstrates this?  I used a global variable to check and it works fine.


octave:1> global gvar;
octave:2> gvar = 1;
octave:3> lvar = 2;
octave:4> whos
Variables in the current scope:

   Attr Name        Size                     Bytes  Class
   ==== ====        ====                     =====  =====
        ans         1x20                        20  char
     g  gvar        1x1                          8  double
        lvar        1x1                          8  double

Total is 22 elements using 36 bytes

octave:5> clear -v
octave:6> whos
octave:7> global gvar
octave:8> whos
Variables in the current scope:

   Attr Name        Size                     Bytes  Class
   ==== ====        ====                     =====  =====
     g  gvar        1x1                          8  double

Total is 1 element using 8 bytes

octave:9> gvar
gvar =  1


The local variable which is an instance of the global variable is removed by the clear statement.  But the global variable is not cleared, and can be re-accessed by declaring a local instance again.  This is the same behavior I see in Matlab.


Rik <rik5>
Group administrator
Wed 15 Jan 2020 12:08:35 PM UTC, original submission:  

Instead of just clearing local variables, clear -v clears everything.

Muhali <muhali>

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by muhali (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 10 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-06-26 rik5 StatusConfirmed Fixed
        Open/ClosedOpen Closed
        Releasedev 6.0.90
    2020-01-16 rik5 CategoryInterpreter Documentation
        Item GroupMatlab Compatibility Documentation
        StatusWorks For Me Confirmed
        Release5.1.0 dev
        Summaryclear -v clears everything Document how clear -v removes only local copy of global variable
    2020-01-15 rik5 Item GroupNone Matlab Compatibility
        StatusNone Works For Me

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code