|
From: | John W. Eaton |
Subject: | Re: DEFMETHOD vs. DEFUN |
Date: | Fri, 24 Nov 2017 12:20:54 -0500 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 |
On 11/23/2017 05:09 PM, Rik wrote:
Why are some built-in functions defined using the macro DEFMETHOD and others using DEFUN? I happened to notice in file-io.cc that textscan() is defined using DEFMETHOD, but it seems like DEFUN should just be used. If I go to libinterp/corefcn I see a preference for DEFUN, but a fair number of DEFMETHOD as well. grep '^DEFUN' *.cc | wc -l 526 grep '^DEFMETHOD' *.cc | wc -l 110
DEFMETHOD and DEFUN are equivalent except that DEFMETHOD creates a function that has a reference to the octave::interpreter object as the first argument. If that is not needed, then DEFUN can be used.
I've only been converting to DEFMETHOD as needed. If textscan doesn't need the interpreter object, then it could be switched to use DEFUN.
jwe
[Prev in Thread] | Current Thread | [Next in Thread] |