[R] builtin vs. closure

Berwin A Turlach berwin at maths.uwa.edu.au
Sun Mar 15 06:29:39 CET 2009

G'day Edna,

On Sat, 14 Mar 2009 23:00:12 -0500
Edna Bell <edna.bell01 at gmail.com> wrote:

> Anyway, my question now is:  what determines if a function is a
> builtin vs. a closure, please?

The help page of typeof states that:

The possible values are listed in the structure 'TypeTable' in
'src/main/util.c'. Current values are [...]
   '"closure"' (function)
   '"special"' and '"builtin"' (basic functions and operators)

Which might raise the question what "basic functions" are.  But since
"basic" and "primitive" are synonyms it is not hard to guess that
primitive functions are returning "special" or "builtin"; and the help
page of ?is.primitive confirms this.  

Note, a return value of "special" is possible for a primitive function:
R> UseMethod
function (generic, object)  .Primitive("UseMethod")
R> typeof(UseMethod)
[1] "special"




More information about the R-help mailing list