Skip to content

builtin vs. closure

4 messages · Edna Bell, Berwin A Turlach, Duncan Murdoch +1 more

#
Dear R Gurus:

I'm working slowly through "R Programming for Bioinformatics", which
is really interesting!

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

For instance:
[1] "builtin"
[1] "closure"
Thanks,
Edna Bell
#
G'day Edna,

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

            
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
#
On 15/03/2009 12:00 AM, Edna Bell wrote:
Closure is the normal type of function written in R code.  The other 
special types are built in to R; users can't create them except by 
modifying the R source code.  For details see the R Internals manual.

Duncan Murdoch
#
Thank you
On Sun, Mar 15, 2009 at 8:36 AM, Duncan Murdoch <murdoch at stats.uwo.ca> wrote: