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 10 Jan 2011 12:51:24 PM UTC  
 
Category: InterpreterSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Feature Request
Status: Patch SubmittedAssigned 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)

Sat 25 Jan 2014 09:56:12 PM UTC, 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 Member
Sat 25 Jan 2014 02:21:45 PM UTC, comment #10:

Here you go!

Michael C. Grant <mcgrant>
Sat 25 Jan 2014 09:01:23 AM UTC, 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 Member
Tue 07 Jan 2014 03:54:02 PM UTC, 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 31 Jan 2011 01:36:16 PM UTC, 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 22 Jan 2011 06:23:32 PM UTC, 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 20 Jan 2011 09:04:02 PM UTC, 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 20 Jan 2011 06:44:48 PM UTC, 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 20 Jan 2011 03:29:36 PM UTC, 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 20 Jan 2011 08:37:52 AM UTC, 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 19 Jan 2011 07:47:44 PM UTC, comment #1:

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

(file #22458)

Guillaume <gyom>
Mon 10 Jan 2011 12:51:24 PM UTC, 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 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 9 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sat 11 Jan 2014 09:52:38 PM UTCmtmillerDependencies-=>bugs #32973 is dependent
    Tue 07 Jan 2014 03:42:47 PM UTCmtmillerDependencies-=>bugs #41135 is dependent
    Thu 17 Oct 2013 06:12:45 PM UTCrik5StatusPostponed=>Patch Submitted
    Fri 19 Apr 2013 11:35:15 PM UTCmtmillerCategoryNone=>Interpreter
      StatusNone=>Postponed
    Thu 20 Jan 2011 06:44:48 PM UTCgyomAttached File-=>Added which.patch, #22472
    Thu 20 Jan 2011 03:29:36 PM UTCgyomAttached File-=>Added which.patch, #22468
    Wed 19 Jan 2011 07:47:44 PM UTCgyomAttached File-=>Added which.m, #22458
    Mon 10 Jan 2011 07:59:45 PM UTCjweSummary-ALL option for WHICH=>Feature request: -ALL option for WHICH

    Back to the top


    Powered by Savane 3.1-cleanup