bugGNU Octave - Bugs: bug #40452, explicit clear will not clear...

 
 

bug #40452: explicit clear will not clear function entered on the command line

Submitter:  None
Submitted:  Sat 02 Nov 2013 12:41:06 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Adrian Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 3.6.2
Operating System:  * GNU/Linux Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sun 03 Nov 2013 11:27:42 PM UTC, comment #4: 

Thanks for checking. I filed another bug report on the "type" command (bug #40462).

cheers, Adrian

Anonymous
Sun 03 Nov 2013 01:11:40 PM UTC, comment #3: 

Hmmm, the syntax complaint on

function foo "nop"; endfunction


doesn't show up now.... well that's better still.

As to your other request:

GNU Octave, version 3.7.7+
:
:
>> function [retval] = foo (); retval = 1; end
>> type foo
error: type: 'foo' undefined
>>


(on Windows & Linux) so yes that is still the behavior.

Philip Nienhuis <philipnienhuis>
Group Member
Sat 02 Nov 2013 11:29:44 PM UTC, comment #2: 

Thanks Philip Nienhuis, for taking the time to look into this.

As regards your first question, have I tried "clear -f": yes, see command #6 in my OP; no effect either.

Wrt your side remark, I have no idea why 'function foo "nop"; endfunction' causes syntax complaints for you: I can define and execute this foo on 3.6.2 and 3.6.4 without complaints. But of course the precise content of foo is not important here, your suggestion produces the same result.

I upgraded to the newest version packaged for Debian, 3.6.4 (testing and unstable), and I can confirm the bug like you did on that version on Windows. Unfortunately even Debian-experimental does not have a newer version, so I'll wait until 3.77 has led to a new stable release and is packaged. Glad to hear the bug has been squashed already and can be closed.

Could you just check if 3.7.7 has also corrected the following bug, which seems also somehow related to symbol look-up:


>> function [retval] = foo (); retval = 1; end
>> type foo
error: type: 'foo' undefined


If 3.7.7 does not show the function definition as it should, I might open a second bug-report.

Thanks again! Octave has become a really valuable piece of software for me.

Adrian

Anonymous
Sat 02 Nov 2013 01:44:11 PM UTC, comment #1: 

Have you tried "clear -f"?

BTW your example:
function foo "nop"; endfunction
gets me syntax complaints.

Anyway I think you'd better upgrade - 3.6.2 is quite old.

I can confirm this behavior in 3.6.4 (on Windows). However, in the development version (3.7.7+) I see (on Linux and Windows):

>> function [retval] = foo (); retval = 1; end
>> exist foo
ans =  103
>> clear foo
>> exist foo
ans = 0
>> foo
error: 'foo' undefined near line 1 column 1
>>


so this bug has been fixed.

Philip Nienhuis <philipnienhuis>
Group Member
Sat 02 Nov 2013 12:41:06 PM UTC, original submission:  

When I define a function on the command line, I do not seem to be able to clear it by specifying its name. The only way seems to clear its definition appears to be clearing everything (clear -a), as the following transcript illustrates (fresh session with empty .octaverc, on an up-to-date Debian stable (Wheezy)):


octave:1> exist("foo")
ans = 0
octave:2> function foo "nop"; endfunction
octave:3> exist("foo")
ans =  103
octave:4> clear foo
octave:5> exist("foo")
ans =  103
octave:6> clear -f foo
octave:7> exist("foo")
ans =  103
octave:8> clear
octave:9> exist("foo")
ans =  103
octave:10> clear -a
octave:11> exist("foo")
ans = 0


I don't know whether this is intended behaviour, but the documentation seems to suggest it is not: "For example, suppose you have defined a function foo, and then hidden it by performing the assignment foo = 2. Executing the command clear foo once will clear the variable definition and restore the definition of foo as a function. Executing clear foo a second time will clear the function definition."


octave:12> function foo "nop"; endfunction
octave:13> exist("foo")
ans =  103
octave:14> foo=2;
octave:15> exist("foo")
ans =  1
octave:16> clear foo
octave:17> exist("foo")
ans =  103
octave:18> clear foo
octave:19> exist("foo")
ans =  103


Is this a problem of my installation/GNU-Linux distribution/octave version/... only, or some misunderstanding of the intended behaviour on my side, or indeed a bug ?

(I also do not seem to be able to type the function's definition ("type foo" yields "error: type: `foo' undefined"), but this is better submitted as another bug-report if this one is confirmed to be a bug).

Anonymous

 

(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 None (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 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2013-11-02 philipnienhuis StatusNone Fixed
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code