bugGNU Octave - Bugs: bug #53900, which does not work for functions...


bug #53900: which does not work for functions in packages (+package directories)

Submitted by:  Richard <crobar>
Submitted on:  Mon 14 May 2018 02:51:44 PM UTC  
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Duplicate Assigned to:  None
Originator Name:  Richard Crozier Open/Closed:  Closed
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.


Mon 14 May 2018 08:59:52 PM UTC, comment #4: 

This is a known bug, see bug #52585. Closing as a duplicate. Please post any additional comments on that bug report.

Mike Miller <mtmiller>
Project Administrator
Mon 14 May 2018 03:56:15 PM UTC, comment #3: 

I can confirm my hunch in comment #2, the 'which' call fails to find the function because it is assumed to be a file search. I would attempt a fix but I have no clue what's returned by symtab.find_function (name) that I might be able to test to see if it's a function in a package.

Richard <crobar>
Mon 14 May 2018 03:35:35 PM UTC, comment #2: 

I suspect the reason is due to this test in help_system::which in help.cc:

if (name.find_first_of ('.') == std::string::npos)

if this is false it is assumed to be a file search, but I guess the name has '.' in it for functions in packages? I haven't run it to find out

Richard <crobar>
Mon 14 May 2018 02:57:20 PM UTC, comment #1: 

Actually my comment about the syntax error was nonsense (trying to get a return variable with this syntax obviously doesn't work) but everything else stands!

Richard <crobar>
Mon 14 May 2018 02:51:44 PM UTC, original submission:  

On matlab you can get the file containing a function in a namespace (i.e. in a package directory) using 'which' like below. Here I've created a directory '+example_pkg' and put the m-file 'example_pkg_fcn.m' in it. This is a valid mfile, just prints 'hello' which can be run in both matlab and octave. I've attached it.

Matlab returns the following:

>> which example_pkg.example_pkg_fcn
/home/rcrozier/Sync/work/mfiles/octave_tests/+example_pkg/example_pkg_fcn.m  % static method or package function

on Octave, 'which' returns nothing

>> x = which ('example_pkg.example_pkg_fcn')
x =


actually, if you try to do the exact same as in matlab you get a syntax error:

>> which example_pkg.example_pkg_fcn
>> x = which example_pkg.example_pkg_fcn
parse error:

  syntax error

>>> x = which example_pkg.example_pkg_fcn

Octave doesn't seem to treat it as a string, but that's for another bug report I guess!

For completeness, using function syntax on matlab gives

>> x = which ('example_pkg.example_pkg_fcn')

x =


Richard <crobar>


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

Attach Files:

Attached Files
file #44155:  example_pkg_fcn.m added by crobar (54B - text/x-objcsrc)


   bug dependencies.

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by crobar (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 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-05-14 mtmiller StatusNone => Duplicate
        Open/ClosedOpen => Closed
        Dependencies- => Depends on bugs #52585
    2018-05-14 crobar Attached File- => Added example_pkg_fcn.m, #44155

    Back to the top

    Powered by Savane 3.5