catchr-DSL: The language of catchr

Description Special reserved terms Masking

Description

catchr implements a small but helpful "domain-specific language" (DSL) to make building condition-handling functions simpler to read and type. Essentially, catchr reserves special 'terms' that mean something different than they do in the rest of R. When given as part of the input for a catchr plan, these terms will be substituted for special catchr functions used to handle conditions.

These special terms can be inputted as strings (e.g., warning = list('collect', 'muffle')) or as unquoted terms (e.g., warning = c(collect, muffle)); catchr internally converts the unquoted terms to strings regardless, but being able to input them unquoted saves keystrokes and can highlight their special meanings for code readability.

Special reserved terms

The following are the special terms and what they do. Note that there are also some special condition names, but those are different from the following.

Masking

catchr will turn unquoted special terms into functions, but what happens if these unquoted terms are identical to variables previously declared?

If muffle is the name of a user-defined function, e.g., muffle <- function(x) print("Wooo!"), in normal R we would expect warning = muffle to make function(x) print("Wooo!") the warning handler.

However, catchr's DSL "masks" any symbol that matches one of its reserved terms, and when it evaluates these symbols, they are converted into strings. For the most part, catchr will warn you when this happens.

Importantly, catchr does not mask reserved terms when:


burchill/catchr documentation built on July 10, 2019, 5:07 a.m.