© Thomas Mailund 2018
Thomas MailundDomain-Specific Languages in Rhttps://doi.org/10.1007/978-1-4842-3588-1_7

7. Environments and Expressions

Thomas Mailund1 
(1)
Aarhus N, Staden København, Denmark
 

We have already used environments in a couple of examples to evaluate expressions in a different context than where we usually evaluate them, which is known as non-standard evaluation . Many domain-specific languages that we could implement in R will need some variety of non-standard evaluation, but getting the evaluation to occur in the right context can be problematic. The rules for how expressions are evaluated are simple, while evaluation contexts, which are chains of environments, can be complicated.

We will use the rlang package.

library(rlang)

Get Domain-Specific Languages in R: Advanced Statistical Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.