bugGNU Octave - Bugs: bug #35436, Private function strange behaviour

 
 

bug #35436: Private function strange behaviour

Submitter:  RPS <ryanst>
Submitted:  Thu 02 Feb 2012 01:26:09 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  ryanst Open/Closed:  * Closed
Release:  * 3.4.3 Operating System:  * Microsoft Windows
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 02 Feb 2012 10:07:13 PM UTC, comment #1: 

Happily this has been fixed.  Please upgrade to version 3.6.0, or 3.6.1 which is scheduled for release in the next week or so.  Alternatively, you can build from the Mercurial development sources.

I see that your reported OS is Microsoft Windows.  You might want to check (http://www.octave.org/wiki/index.php?title=Octave_for_Windows) where links to the new 3.6.0 version are available.

Rik <rik5>
Group administrator
Thu 02 Feb 2012 01:26:09 PM UTC, original submission:  

Private function behaviour seems strange - the private function does not always override the built-in function.  I've added an example to replicate the problem:

place the following function (test.m) in the test folder:


function test()
while 1
  res=sin(pi)
  m=menu('test', 'option1', 'option2')
  pause;
end


Then add the following two functions under {working folder}/private:

menu.m

function choice = menu(header, varargin)
varargin
choice = input(strcat(header, ' '))
end


sin.m

function res = sin(angle)
res = 'thundercougarfalconbird';
end


Run 'test'.  The output is as follows:


octave:6> test
res = thundercougarfalconbird
varargin =
{
  [1,1] = option1
  [1,2] = option2
}
test1
choice =  1
m =  1
res = thundercougarfalconbird
test

  [ 1] option1
  [ 2] option2

pick a number, any number: 1
m =  1
res = thundercougarfalconbird
test

  [ 1] option1
  [ 2] option2

pick a number, any number:


In short, the private sin.m function always gets used while the menu.m function only gets used the first time.  This occurs in both 3.4.3 under Windows XP and Linux (Ubuntu 11.10 in this case, the 3.4.3 version I compiled).  This works properly when run in MATLAB (R2011b):



>> test

res =

thundercougarfalconbird


varargin =

    'option1'    'option2'

test

choice =

     []


m =

     []


res =

thundercougarfalconbird


varargin =

    'option1'    'option2'

test

choice =

     []


m =

     []


RPS <ryanst>

 

(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 ryanst (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
    2012-02-02 rik5 StatusNone Fixed
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-bb6a.
    Corresponding source code