quasiquote: Partial quoting in expressions

Description Usage Arguments Details Value Warning Examples

View source: R/quoting.R

Description

A reimplementation of the backquote macro from Lisp/Scheme, with more functionality than the base bquote function. quasiquote quotes its argument, except for two kinds of user-requested evaluation and interpolation. Adapted from base R's bquote.

Usage

1
quasiquote(expr, where = parent.frame())

Arguments

expr

The expression to be partially quoted.

where

The environment in which any evaluation should occur.

Details

Unlike the bquote() found in base R, this version handles both of the types of unquoting Lisp provides:

Value

The quoted expr, with partial evaluation and substitution done.

Warning

Splicing unquote via .s() works on a purely lexical basis, and unlike in Lisp, there is no guarantee the resulting object will make any sense.

Examples

1
2
3
4
5
f <- list(1,2,3)
eval(quasiquote(list(.c(f), 4, 5, 6)))

f <- list(5,6,7)
eval(quasiquote(list(1, 2, 3, 4, .s(f), 8, 9, 10)))

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