bugGNU Octave - Bugs: bug #32088, Feature request: -ALL option for...

 
 

bug #32088: Feature request: -ALL option for WHICH

Submitted by:  Guillaume <gyom>
Submitted on:  Mon Jan 10 12:51:24 2011  
 
Category: InterpreterSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Feature Request
Status: In ProgressAssigned to: None
Originator Name: GuillaumeOpen/Closed: Open
Release: devOperating System: GNU/Linux

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

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

 

(Jump to the original submission Jump to the original submission)

Mon Nov 21 15:46:46 2016, comment #15:

I'm still very interested in this, and it seems that I'm not alone.

Looking at it again, I found an interesting file_in_loadpath which allows for a second optional argument "all" to be supplied. What is the best way to proceed? Shall we change _which_/do_which in libinterp/corefcn/help.cc to call load_path::find_all_first_of or stay at the M-code level and have which call file_in_loadpath?

Guillaume <gyom>
Sat Nov 19 14:41:29 2016, comment #14:

The requested new feature "which -all" doesn't seem to be implemented in Octave 4.2.0, yet.

Hartmut <hardy>
Thu Nov 12 03:56:24 2015, comment #13:

@Shaun: Following up on your post in June, since there was no response I think it is fair to proceed in the manner you suggested. Modify do_which to return a string_vector. The C++ function _which_ can decide based on the length whether to return a Cell with multiple entries, or just a single entry of type std::string.

Rik <rik5>
Project Administrator
Sun Jun 28 05:14:58 2015, comment #12:

Preparing to work on help.cc to implement this. The primary issue as I understand it is that do_which is capable of only returning std::string instead of string_vector. Several ways to address this, jwe is there a preference or model for how you would like it handled?

Most obvious to me would be to change do_which to always return a string vector, then have which.m handle the issue of changing it back to a char or leave as a cellstr depending on the size of the _which_ return value. Appears to be limited calls to do_which throughout the codebase so modification of its return value may be feasible.

Shaun Eack <seack>
Sat Jan 25 21:56:12 2014, comment #11:

Thanks, that looks good. There may be other cases, I haven't started looking at adding this feature yet, but I wanted to see how which interacts with variables.

Mike Miller <mtmiller>
Project Administrator
Sat Jan 25 14:21:45 2014, comment #10:

Here you go!

Michael C. Grant <mcgrant>
Sat Jan 25 09:01:23 2014, comment #9:

If there is a normal workspace variable that shadows one or more functions, does which -all also show the variable at the top of the list? For example,

Thanks for the info.

Mike Miller <mtmiller>
Project Administrator
Tue Jan 7 15:54:02 2014, comment #8:

From what I am seeing, both in the documentation and my own usage of the command, WHICH -ALL has the following priorities:

-- non-shadowed standard functions/scripts in the path (e.g., 'norm')
-- all class methods in the path (e.g., '@cvx/norm'), in path order, including shadowed methods (which i grant you are very unlikely)
-- shadowed standard functions/scripts in the path, in path order

Michael C. Grant <mcgrant>
Mon Jan 31 13:36:16 2011, comment #7:

I agree that changing _which_ is the way forward.

There does not seem to be a mention of the order of the results to '-all' in the MATLAB documentation but, in practice, the order corresponds to the order of how the matching results are found in the path, so that the first one would actually be the function called. The output is like this:

For methods, you get:

At last, concerning subfunctions, I was not aware of the ">" notation and this is not mentioned in the MATLAB documentation, but it works:

i.e. the '-all' option does not work for subfunctions of methods of a class. It seems to me, however, to be of a very specific and limited use.

Guillaume <gyom>
Sat Jan 22 18:23:32 2011, comment #6:

I think it would be better to do this by changing the way _which_ works instead of playing tricks with the load path.

In Matlab, what exactly does which -all find, and does the order of the results matter? Does it find subfucntions in the current scope, or all possible subfunctions (I don't think that is reasonable, as it means parsing every function on the load path).

What does it do for

Does it find every @foo/bar.m file on the path if there are multiple @foo directories?

What about

for looking up subfunctions?

I'm not sure this will make it into 3.4, but you do have a workaround with the function you've written.

John W. Eaton <jwe>
Project Administrator
Thu Jan 20 21:04:02 2011, comment #5:

For coding guidelines and mercurial tips, take a look at the doc/interpreter/contrib.txi file. If you have the documentation built as part of your local build from the hg archive, look at the "Contributing Guidelines" chapter in the manual.

John W. Eaton <jwe>
Project Administrator
Thu Jan 20 18:44:48 2011, comment #4:

Another version for compatibility with MATLAB: WHICH should return a string while WHICH -ALL returns a cell array.
Maybe this should be implemented in octave/src/help.cc.

(file #22472)

Guillaume <gyom>
Thu Jan 20 15:29:36 2011, comment #3:

I've added an unwind_protect statement and slightly simplified the code.
Where can I find some more information about coding conventions used in Octave?
The new attached file is the output from 'hg diff'.

(file #22468)

Guillaume <gyom>
Thu Jan 20 08:37:52 2011, comment #2:

If you modify global state like the loadpath, you need to use some method to protect it from being changed in the event of an interrupt, either with unwind_protect or onCleanup.

It would help if you followed the coding conventions used in Octave and also submitted a Mercurial changeset instead of a new copy of the function.

John W. Eaton <jwe>
Project Administrator
Wed Jan 19 19:47:44 2011, comment #1:

Please find attached a suggestion for an implementation of WHICH with the -ALL option.

(file #22458)

Guillaume <gyom>
Mon Jan 10 12:51:24 2011, original submission:

It would be useful if the WHICH command could support a '-ALL' option that would return the full path of all occurrences of a function.
See http://www.mathworks.com/help/techdoc/ref/which.html

Guillaume <gyom>

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #22472:  which.patch added by gyom (2kB - text/x-patch)
file #22468:  which.patch added by gyom (2kB - text/x-patch)
file #22458:  which.m added by gyom (2kB - text/x-matlab)

 

Depends on the following items: None found

Digest:
   bug dependencies.

 

Carbon-Copy List
  • -unavailable- added by hardy (Posted a comment)
  • -unavailable- added by lachlan (Updated the item)
  • -unavailable- added by seack (Posted a comment)
  • -unavailable- added by mcgrant (Posted a comment)
  • -unavailable- added by rik5 (Updated the item)
  • -unavailable- added by mtmiller (Updated the item)
  • -unavailable- added by jwe (Updated the item)
  • -unavailable- added by gyom (Submitted the item)
  •  

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

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 10 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon Feb 8 03:50:44 2016lachlanStatusPatch Submitted=>In Progress
    Sat Jan 11 21:52:38 2014mtmillerDependencies-=>bugs #32973 is dependent
    Tue Jan 7 15:42:47 2014mtmillerDependencies-=>bugs #41135 is dependent
    Thu Oct 17 18:12:45 2013rik5StatusPostponed=>Patch Submitted
    Fri Apr 19 23:35:15 2013mtmillerCategoryNone=>Interpreter
      StatusNone=>Postponed
    Thu Jan 20 18:44:48 2011gyomAttached File-=>Added which.patch, #22472
    Thu Jan 20 15:29:36 2011gyomAttached File-=>Added which.patch, #22468
    Wed Jan 19 19:47:44 2011gyomAttached File-=>Added which.m, #22458
    Mon Jan 10 19:59:45 2011jweSummary-ALL option for WHICH=>Feature request: -ALL option for WHICH

    Back to the top


    Powered by Savane 3.1-cleanup