macro: Lisp macros for R

Description Usage Arguments Details Value See Also

Description

These two functions create Lisp-style macros. macro creates and returns anonymous macros; defmacro is a convenience wrapper around macro which creates a macro and assigns it to a name in the current environment. A full discussion of macros and how to use them is beyond the scope of this page; see the vignettes for an R-focused introduction.

Usage

1
2
3
defmacro(nm, params, ...)

macro(params, ...)

Arguments

nm

The symbol to which defmacro should bind the generated macro.

params

A parameter list, which when coerced to pairlist is acceptable to the "function" constructor function.

...

Body statements.

Details

Even though R is descended from Scheme, the macros implemented here are based on the "non-hygienic" ones used in Common Lisp. They contrast with the hygienic form that's traditional in Scheme, which is based on syntax objects and the syntax-case special form.

Value

macro returns the created macro, which is an R function. defmacro, as in Common Lisp, returns the symbol it's bound the new macro to.

See Also

The gensym function, which generates temporary unique symbols that macro definitions can use to avoid capturing variables from the calling environment.


wwbrannon/schemeR documentation built on May 4, 2019, 12:03 p.m.