bugGNU Octave - Bugs: bug #46553, Addpath shadows builtin functions...

 
 

bug #46553: Addpath shadows builtin functions without warning

Submitter:  Max Görner <maxg>
Submitted:  Fri 27 Nov 2015 08:45:24 AM UTC
   
 
Category:  Octave Function Severity:  2 - Minor
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 02 Dec 2015 06:44:52 PM UTC, comment #4: 

The actual bug is solved (works for me on MingW and Linux), so can this bug report be closed?

Philip Nienhuis <philipnienhuis>
Group Member
Sun 29 Nov 2015 09:09:32 AM UTC, comment #3: 

I have been thinking for a while that it would be nice to have another option that places a directory after the built-ins in the search path.

Two of my use-cases (admittedly specialised) are:
- while I'm developing a built-in textscan, I keep removing scripts/io/textscan.m so that I can make check, and keep putting it back whenever I want to make a patch for an unrelated issue.  (If I knew mercurial better, there's probably a clean workaround).

- I have some directories from an old Matlab install in my path, because at one point I needed the function and either didn't want to hunt for the correct Forge module, or had no internet access at the time.  This often shadows Octave built-ins.

If I implemented this, would it be likely to get applied?

Lachlan Andrew <lachlan>
Fri 27 Nov 2015 07:11:19 PM UTC, comment #2: 
John W. Eaton <jwe>
Group administrator
Fri 27 Nov 2015 12:38:44 PM UTC, comment #1: 

Matlab (r2014a) does warn when paths added using addpath shadow builtins (I tried with sin()), unlike Octave (also development version) => confirmed.

Note that str2double is a builtin in Octave but an .m-file function in Matlab - hence your addpath() trick may work with Matlab (although I don't follow) but not with Octave.

BTW, If I've interpreted your explanation correctly I would blame the creators of your projects rather than The Mathworks. Shadowing core functions in projects is rarely a Good Idea.
It is always possible to name functions along the lines of "str2double_1" or "size_B"; at my work we have several "improved" Matlab functions named along that principle.
As you're on Linux, a simple search & replace script recursing directories could help you a lot.

I'll set Item Group to Matlab Compatibility and Severity to minor as there are workarounds.
Status and Release also adapted.

Philip Nienhuis <philipnienhuis>
Group Member
Fri 27 Nov 2015 08:45:24 AM UTC, original submission:  

When I add directories to the search path using the "'-end'"-switch, addpath shadows builtin functions without issuing a warning.

I'm on Ubuntu 15.10.


/tmp$ octave --no-gui --silent
>> addpath (genpath ('/tmp/ext'), '-end')
>> size
error: assert (false) failed
error: called from
    assert at line 92 column 11
    size at line 2 column 3
>> str2double
error: assert (false) failed
error: called from
    assert at line 92 column 11
    str2double at line 2 column 3
>>
/tmp$


The functions size and str2double in /tmp/ext only contain an assertion.

Since I have to deal with some projects containing their own versions of essential functions (thanks Mathworks), I use the "'-end'"-switch to prevent shadowing. If it can't be avoided, a warning would be great.

sincerely

Max Görner <maxg>

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Updated the item)
  • -email is unavailable- added by lachlan (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by maxg (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 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-12-08 rik5 StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2015-11-27 jwe StatusConfirmed Ready For Test
    2015-11-27 philipnienhuis Severity3 - Normal 2 - Minor
        Item GroupOther Matlab Compatibility
        StatusNone Confirmed
        Release4.0.0 dev

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code