bugGNU Octave - Bugs: bug #57865, Builtin is not calling the built...

 
 

bug #57865: Builtin is not calling the built in version

Submitter:  None
Submitted:  Thu 20 Feb 2020 07:21:24 AM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  None
Status:  Invalid / Not an Octave Bug Assigned to:  None
Originator Name:  Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * dev
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Fri 24 Apr 2020 02:41:13 PM UTC, comment #7: 


> I'll close the report as invalid.


Another success.

Anonymous
Fri 21 Feb 2020 03:46:14 PM UTC, comment #6: 

Functions in the current directory take precedence over functions in the search path. If you know the path of the function you are shadowing, you could cd to that directory, call the function, and cd back.

The following seems to work for me:

>> type xlim
xlim is the user-defined function defined from: D:\Repositories\Octave\test\octave-2020-02-21-15-19-w64_terminal_colors2\octave-2020-02-21-15-19-w64
\xlim.m

function xlim (varargin)

disp ('test xlim shadowing')
olddir = cd (fullfile (getenv ('OCTAVE_HOME'), 'share\octave', ...
                       ver ('octave').Version, 'm\plot\appearance'));

xlim (varargin{:});

cd (olddir);

endfunction

>> xlim ([0 10])
test xlim shadowing
>>


Since this is how "builtin" is supposed to work in Octave, I'll close the report as invalid.

Markus Mützel <mmuetzel>
Group administrator
Fri 21 Feb 2020 01:53:48 PM UTC, comment #5: 

In Matlab try "which -all". DOesn't work in Octave

Anonymous
Fri 21 Feb 2020 04:12:48 AM UTC, comment #4: 

Does anyone know of a function that calls the Octave (or MATLAB) version of a function - either builtin or m-file - rather than the local override? I thought that was what builtin does.

Anonymous
Thu 20 Feb 2020 07:32:57 PM UTC, comment #3: 

Octave's 'builtin' function is closer to 'feval' than Matlab's is.

If we change the 'builtin' function to be Matlab compatible, then some functions may raise an error because they are interpreted m-file functions instead of compiled built-in functions.

Keeping the current behavior of 'builtin' seems like the best option to me, so that we can keep functions written as m-files and have them work with the 'builtin' function.

I'd resolve this as a known incompatibility.

Mike Miller <mtmiller>
Group Member
Thu 20 Feb 2020 10:05:43 AM UTC, comment #2: 

See also bug #50854

Guillaume <gyom>
Thu 20 Feb 2020 08:59:50 AM UTC, comment #1: 

This is because "cast" is a built-in function in Matlab but is an .m file in Octave. "zero" on the other hand is built-in in Matlab and in Octave.

Up until now, we didn't consider it a compatibility issue if functions are built-in or not.

FWIW, the corresponding error message in Matlab is different:

>> which xlim
C:\Program Files\MATLAB\R2016a\toolbox\matlab\graph3d\xlim.m
>> type xlim

function xlim(varargin)

builtin('xlim', varargin{:});

end
>> xlim([0 1])
Error using builtin
Cannot find builtin function 'xlim'

Error in xlim (line 3)
builtin('xlim', varargin{:});


Markus Mützel <mmuetzel>
Group administrator
Thu 20 Feb 2020 07:21:24 AM UTC, original submission:  

I'm using hacks to recognize the 'like' keyword. It works for zeros but fails for cast. For some reason, the last line is not calling the builtin version of cast but keeps calling this hack version.

E.g.

>> cast(0,'like',1)

error: max_recursion_depth exceeded
error: called from
    cast at line 20 column 3



function x = cast(varargin)

% search for 'like' or any char (e.g. 'single')
for k = 1:nargin
    if isequal(varargin{k},'like')
        if k==1 || k==nargin
            error('invalid usage of ''like'' keyword.');
        end
        varargin{k} = class(varargin{k+1});
    end
    if ischar(varargin{k})
        break;
    end
end

% fix octave bug (k undefined if nargin==0)
if nargin==0; k = []; end

% pass vararin to builtin function
x = builtin('cast',varargin{1:k});


Anonymous

 

(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 gyom (Posted a comment)
  • -email is unavailable- added by mmuetzel (Posted a comment)
  •  

    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
    2020-02-21 mmuetzel StatusConfirmed Invalid / Not an Octave Bug
        Open/ClosedOpen Closed
    2020-02-20 mmuetzel CategoryNone Interpreter
    2020-02-20 mmuetzel StatusNone Confirmed
        Release5.2.0 dev
        Operating SystemGNU/Linux Any

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code