bugGNU Octave - Bugs: bug #52585, Functions in namespace directories...


bug #52585: Functions in namespace directories are not recognized by path functions such as which() or type()

Submitter:  A.R. Burgers <arb>
Submitted:  Mon 04 Dec 2017 07:34:34 PM UTC
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Confirmed Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup

Jump to the original submission

Sat 19 Jan 2019 05:59:41 AM UTC, comment #6: 

Same goes for `edit()`.

Andrew Janke <apjanke>
Thu 07 Dec 2017 07:00:26 PM UTC, comment #5: 

As another workaround, can also give the namespace and the m-file name.

type +containers/Map.m

The root problem is that which() should be able to find


when the parent directory to +containers is on the the path.

As yet another workaround, adding the namespace to the path explicitly makes things work.

addpath scripts/+containers

This is probably a clue as to the eventual solution.  When directories are added using addpath, they should probably be scanned for +namespace directories and those might be added to the internal path variable, although not displayed if someone calls path().

Rik <rik5>
Group administrator
Thu 07 Dec 2017 04:32:49 PM UTC, comment #4: 

Seems pretty clear that Octave should be able handle this.

Rik <rik5>
Group administrator
Thu 07 Dec 2017 04:25:54 PM UTC, comment #3: 


>> help type
 type List program file.
    type foo.bar lists the ascii file called 'foo.bar'.
    type foo lists the ascii file called 'foo.m'.

    If files called foo and foo.m both exist, then
       type foo lists the file 'foo', and
       type foo.m lists the file 'foo.m'.

    type PATHNAME/FUN lists the contents of FUN (or FUN.m)
    given a full pathname or a MATLABPATH relative partial
    pathname (see PARTIALPATH).

>> help partialpath
 partialpath Partial pathnames.
    A partial pathname is a MATLABPATH relative pathname that is used to
    locate private and method files which are usually hidden or to
    restrict the search for files when more than one file with the given
    name exists.

    A partial pathname contains the last component, or last several
    components, of the full pathname separated by '/'. For example,
    "matfun/trace", "private/children", "inline/formula", and
    "demos/clown.mat" are valid partial pathnames.  Specifying the
    "@" in method directory names is optional so "funfun/inline/formula"
    is also a valid partial pathname.

    Many commands accept partial pathnames instead of a full pathname.
    Here's a (partial) list of such commands

    Partial pathnames make it easy to find toolbox or MATLAB relative
    files on your path in a portable way that is independent of
    where MATLAB is installed.

This also seems relevant:

Amro <amro_octave>
Wed 06 Dec 2017 07:19:02 AM UTC, comment #2: 

suppose there is a function foo.m in dir +pkg.

On matlab (R2015B) these two both work

type +pkg/foo
type pkg/foo

both when the current working directory is the parentdir of +pkg and when the current working directory is different, but the parentdir of +pkg is present in the path.

A.R. Burgers <arb>
Tue 05 Dec 2017 12:00:50 AM UTC, comment #1: 

As a workaround, you can give the full path to the file.  For example, if you are at the top of a development tree.

type scripts/+containers/Map.m

But in general, you're right that there should be a way to do this by either using

type Map
type +containers/Map

For reference, does this work with Matlab?

Rik <rik5>
Group administrator
Mon 04 Dec 2017 07:34:34 PM UTC, original submission:  

I haven't found a way yet to type the source of e.g. containers.Map from the command line.

all of "type containers.Map", "type Map" or "type +containers.Map" fail.

A.R. Burgers <arb>


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

Attach Files:

No files currently attached


Carbon-Copy List
  • -email is unavailable- added by apjanke (Posted a comment)
  • -email is unavailable- added by amro_octave (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by arb (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 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-01-20 siko1056 Dependencies- bugs #55457 is dependent
    2018-05-14 mtmiller Dependencies- bugs #53900 is dependent
    2017-12-07 rik5 Summarytype cannot list the source of a function in a namespace Functions in namespace directories are not recognized by path functions such as which() or type()
    2017-12-05 rik5 Item GroupUnexpected Error or Warning Incorrect Result
        StatusNone Confirmed
        Summarytype cannot list source of functions in namespace type cannot list the source of a function in a namespace

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code