Skip to content
Back to formatted view

Raw Message

Message-ID: <20090315132939.208ca5d4@absentia>
Date: 2009-03-15T05:29:39Z
From: Berwin A Turlach
Subject: builtin vs. closure
In-Reply-To: <2d1ebb110903142100h381a619aw43672f196d945d8b@mail.gmail.com>

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"

HTH.

Cheers,

	Berwin