bugGNU Octave - Bugs: bug #37320, Documentation 'which' doesn't work...

 
 

bug #37320: Documentation 'which' doesn't work on variables

Submitter:  Sergei Steshenko <sergstesh>
Submitted:  Mon 10 Sep 2012 08:41:54 PM UTC
   
 
Category:  Interpreter Severity:  2 - Minor
Priority:  5 - Normal Item Group:  Documentation
Status:  Fixed Assigned to:  mtmiller
Originator Name:  Open/Closed:  * Closed
Release:  * 3.6.2 Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Thu 13 Feb 2014 05:35:44 AM UTC, comment #11: 

I pushed this change, with just one more test added to what I had attached here:

http://hg.savannah.gnu.org/hgweb/octave/rev/2bd78ab75b23

This will be part of the Octave 4.2 release.

Mike Miller <mtmiller>
Group Member
Tue 11 Feb 2014 05:09:34 PM UTC, comment #10: 

Thanks, I'll polish that (add another test case or two and comments) and push it to the default branch (since it changes the results of the which function under certain conditions, not suitable for the stable branch).

Mike Miller <mtmiller>
Group Member
Tue 11 Feb 2014 04:27:10 PM UTC, comment #9: 

Hi Mike, it's indeed much simpler and returns the same results :-)
 

Pantxo Diribarne <pantxo>
Group Member
Tue 11 Feb 2014 01:27:04 PM UTC, comment #8: 

Hi Pantxo, sorry for not posting on this bug report earlier and duplicating effort, but I have a simpler diff that I worked up one day a couple weeks ago but hadn't yet finished. Can you look at and test the attached and let me know if it does the same for you? I think it should suffice.

(file #30510)

Mike Miller <mtmiller>
Group Member
Tue 11 Feb 2014 11:51:02 AM UTC, comment #7: 

I have given a try to solve this issue, see attached patch.
In order to find if a symbol exist as a variable, we need to have access to the caller variable scope. I rewrote which as a builtin DEFUN (_wich_ in help.cc becomes which) so that the function is run in the caller scope.

I know that the policy is to have as much functions defined in .m files as possible, but I couldn't find another way to have access to the callers workspace (plus most part of the job is already done in _which_).

The patch is not complete as it makes the build process fail whith the following error


...
Making all in scripts
...
make[2]: *** No rule to make target « help/which.m »



(file #30509)

Pantxo Diribarne <pantxo>
Group Member
Tue 11 Sep 2012 07:51:14 PM UTC, comment #6: 

Octave has no professional development staff.  If you want something changed the best course is to submit a patch which implements what you are looking for.  The patch will be reviewed and, if accepted, entered into the code base.

Attacking me personally will not change that course of events.

Rik <rik5>
Group administrator
Tue 11 Sep 2012 07:15:19 PM UTC, comment #5: 

"Per your desire" - sorry, it's a blatant lie, and your participation in this bug report is an exercise in hypocrisy.

This is twice a big:

1) documentation contradicts actual behavior;
2) Octave actual behavior contradicts Matlab actual behavior.

I am really sorry I filed this bug report per advice of Octave help mailing list.

Such an attitude to bug reports is the best repellent for those who intend to file bugs - it's really a pity to spend one's energy proving obvious things that a bug is a bug.

Sergei Steshenko <sergstesh>
Tue 11 Sep 2012 02:48:46 PM UTC, comment #4: 

Per your desire, this issue has been changed to "Documentation" from "Feature Request".   

The function 'which' is implemented as an m-file in which.m.  It is therefore easy to modify the help string and submit a patch to resolve this issue.  It would probably also be useful, when creating the patch, to put a @seealso reference to the function exist().

Rik <rik5>
Group administrator
Tue 11 Sep 2012 10:49:22 AM UTC, comment #3: 

This is not a feature request, this is a plain bug.

In my very first post there is an excerpt from 'help which', and it says: "Display the type of each NAME".

I.e. expected behavior is: 'which' is supposed to display types.
Actual behavior is: it doesn't.

It's either a bug in 'which' code or in its documentation, or both.

But it is a bug.

Sergei Steshenko <sergstesh>
Tue 11 Sep 2012 07:06:30 AM UTC, comment #2: 

Just for reference, Matlab r2012b prerelease (empty lines in output removed):


>> foo = [1 2 3]
foo =
     1     2     3
>> type foo
Error using type
File 'foo' not found.
>> which foo
foo is a variable.
>> help which
 which  Locate functions and files.
 :
 <etc>


...and ML r2007a (> 5 years old)


>> foo = [1 2 3]
foo =
     1     2     3
>> type foo
??? Error using ==> type
File 'foo' not found.
>> which foo
foo is a variable.
>>


... so this change hasn't recently been made by TMW.

Philip Nienhuis <philipnienhuis>
Group Member
Mon 10 Sep 2012 09:24:49 PM UTC, comment #1: 

Yes, apparently Mathworks has extended the functionality of which to report whether NAME is a variable.  I have changed the item group to Matlab Compatibility and changed the severity to 1-Wish.

For equivalent functionality try


exist ("NAME", "var")



Rik <rik5>
Group administrator
Mon 10 Sep 2012 08:41:54 PM UTC, original submission:  

Please see the following ("which foo" produces nothing) :

octave:2> foo = [1 2 3]
foo =

   1   2   3

octave:3> type foo
foo is a variable
   1   2   3

octave:4> which foo
octave:5> help which
`which' is a function from the file /home/qemu/AFSWD/20120424/octave-3.6.2/share/octave/3.6.2/m/help/which.m

 -- Command:  which name ...
     Display the type of each NAME.  If NAME is defined from a function
     file, the full name of the file is also displayed.

     See also: help, lookfor



Additional help for built-in functions and operators is
available in the on-line version of the manual.  Use the command
`doc <topic>' to search the manual index.

Help and information about Octave is also available on the WWW
at http://www.octave.org and via the help@octave.org
mailing list.
octave:6>

.

A member of Octave help list claims "which foo" for the 'foo' above works in Matlab.

Thanks,
  Sergei.

Sergei Steshenko <sergstesh>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #30510:  which-vars.diff added by mtmiller (1KiB - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mtmiller (Updated the item)
  • -email is unavailable- added by pantxo (Updated the item)
  • -email is unavailable- added by philipnienhuis (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by sergstesh (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 11 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2014-02-13 mtmiller StatusPatch Submitted Fixed
        Open/ClosedOpen Closed
    2014-02-11 mtmiller Assigned toNone mtmiller
    2014-02-11 mtmiller Attached File- Added which-vars.diff, #30510
        StatusNone Patch Submitted
    2014-02-11 pantxo Attached File- Added whichasbuitin_bug37320.patch, #30509
    2012-09-11 rik5 Severity1 - Wish 2 - Minor
        Item GroupMatlab Compatibility Documentation
        Summary\'which\' doesn\'t work on variables Documentation 'which' doesn't work on variables
    2012-09-10 rik5 Severity3 - Normal 1 - Wish
        Item GroupIncorrect Result Matlab Compatibility

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code