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

 
 

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

Submitted by:  Muhali <muhali>
Submitted on:  Wed 15 Jan 2020 12:08:35 PM UTC  
 
Category:  Documentation Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Documentation
Status:  Confirmed Assigned to:  None
Originator Name:  Open/Closed:  Open
Release:  dev Operating System:  GNU/Linux

Add a New Comment (Rich Markup)
   

You are not logged in

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

 

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>
Project 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>
Project 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)
  •  

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

    Only project members can vote.

     

     

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    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.5