Tidy evaluation

These functions support quasiquotation. They return quosures or raw expressions.

expr enexpr exprs enexprs ensym ensyms quo enquo quos enquos

Quotation

!! !!! := qq_show

Quasiquotation of an expression

Creating tidy evaluation APIs

This set of functions makes it easy to create tidy eval APIs. They are meant for developers rather than users.

.data

Data pronoun for tidy evaluation

eval_tidy

Evaluate an expression with quosures and pronoun support

as_data_mask as_data_pronoun new_data_mask

Create a data mask

Evaluate expressions

eval_tidy

Evaluate an expression with quosures and pronoun support

eval_bare

Evaluate an expression in an environment

invoke

Invoke a function with a list of arguments

Symbols

sym syms

Create a symbol or list of symbols

is_symbol

Is object a symbol?

Calls

call2

Create a call

is_call

Is object a call?

call_modify

Modify the arguments of a call

call_standardise

Standardise a call

call_fn

Extract function from a call

call_name

Extract function name of a call

call_args call_args_names

Extract arguments from a call

Expressions

is_expression is_syntactic_literal is_symbolic

Is an object an expression?

expr_label expr_name expr_text

Turn an expression to a label

set_expr get_expr

Set and get an expression

parse_quosures parse_expr parse_exprs

Parse R code

expr_interp

Process unquote operators in a captured expression

exprs_auto_name quos_auto_name

Ensure that list of expressions are all named

expr_print expr_deparse

Print an expression

Quosures

as_quosure new_quosure

Coerce object to quosure

is_quosure quo_is_missing quo_is_symbol quo_is_call quo_is_symbolic quo_is_null quo_get_expr quo_get_env quo_set_expr quo_set_env is_quosures

Quosure getters, setters and testers

quo_squash

Squash a quosure

quo_label quo_text quo_name

Format quosures for printing or labelling

exprs_auto_name quos_auto_name

Ensure that list of expressions are all named

Formulas

new_formula

Create a formula

is_formula is_bare_formula

Is object a formula?

f_rhs f_rhs<- f_lhs f_lhs<- f_env f_env<-

Get or set formula components

f_text f_name f_label

Turn RHS of formula into a string or label

Functions

new_function

Create a function

fn_fmls fn_fmls_names fn_fmls_syms fn_fmls<- fn_fmls_names<-

Extract arguments from a function

is_function is_closure is_primitive is_primitive_eager is_primitive_lazy

Is object a function?

fn_env fn_env<-

Return the closure environment of a function

as_function as_closure

Convert to function or closure

Environments

env child_env new_environment

Create a new environment

env_parent env_tail env_parents

Get parent environments

env_depth

Depth of an environment chain

get_env set_env env_poke_parent

Get or set the environment of an object

env_bind

Bind symbols to objects in an environment

env_bind_exprs env_bind_fns

Bind lazy or active bindings

env_bury

Mask bindings by defining symbols deeper in a scope

env_unbind

Remove bindings from an environment

env_has

Does an environment have or see bindings?

env_get env_get_list

Get an object in an environment

env_names

Names of symbols bound in an environment

env_clone

Clone an environment

env_inherits

Does environment inherit from another environment?

is_environment is_bare_environment

Is object an environment?

as_environment

Coerce to an environment

scoped_bindings with_bindings

Temporarily change bindings of an environment

caller_env caller_frame caller_fn

Get the environment of the caller frame

Search path and namespaces

scoped_env pkg_env pkg_env_name scoped_names scoped_envs is_scoped base_env global_env

Scoped environments

empty_env

Get the empty environment

is_installed

Is a package installed in the library?

S3

inherits_any inherits_all inherits_only

Does an object inherit from a set of classes?

new_box is_box as_box as_box_if unbox

Box a value

Create vectors

Atomic vector constructors have implicit splicing (i.e. splice lists automatically), while the list constructor has explicit splicing.

lgl int dbl cpl chr bytes ll

Create vectors

dots_list list2

Collect dots tidily

string

Create a string

new_logical_along new_integer_along new_double_along new_character_along new_complex_along new_raw_along new_list_along rep_along

Create vectors matching the length of a given vector

new_logical new_integer new_double new_character new_complex new_raw new_list

Create vectors matching a given length

Coerce vectors

These coercers skip S3 dispatch and have stricter implicit coercion rules.

as_logical as_integer as_double as_complex as_character as_string as_list

Coerce an object to a base type

as_bytes

Coerce to a raw vector

Flatten and squash vectors

flatten flatten_lgl flatten_int flatten_dbl flatten_cpl flatten_chr flatten_raw squash squash_lgl squash_int squash_dbl squash_cpl squash_chr squash_raw flatten_if squash_if

Flatten or squash a list of lists into a simpler vector

Vectors tools

seq2 seq2_along

Increasing sequence of integers in an interval

Missing values

na_lgl na_int na_dbl na_chr na_cpl

Missing values

are_na is_na is_lgl_na is_int_na is_dbl_na is_chr_na is_cpl_na

Test for missing values

Attributes

set_names

Set names of a vector

names2

Get names of a vector

Vectors and lists predicates

is_list is_atomic is_vector is_integer is_double is_character is_logical is_raw is_bytes is_null

Type predicates

is_scalar_list is_scalar_atomic is_scalar_vector is_scalar_integer is_scalar_double is_scalar_character is_scalar_logical is_scalar_raw is_string is_scalar_bytes

Scalar type predicates

is_bare_list is_bare_atomic is_bare_vector is_bare_double is_bare_integer is_bare_numeric is_bare_character is_bare_logical is_bare_raw is_bare_string is_bare_bytes

Bare type predicates

is_empty

Is object an empty vector or NULL?

is_integerish is_bare_integerish is_scalar_integerish

Is a vector integer-like?

Other R types and objects predicates

is_list is_atomic is_vector is_integer is_double is_character is_logical is_raw is_bytes is_null

Type predicates

is_true is_false

Is object identical to TRUE or FALSE?

is_scalar_list is_scalar_atomic is_scalar_vector is_scalar_integer is_scalar_double is_scalar_character is_scalar_logical is_scalar_raw is_string is_scalar_bytes

Scalar type predicates

is_bare_list is_bare_atomic is_bare_vector is_bare_double is_bare_integer is_bare_numeric is_bare_character is_bare_logical is_bare_raw is_bare_string is_bare_bytes

Bare type predicates

is_copyable

Is an object copyable?

Operators

%||%

Default value for NULL

%|%

Replace missing values

%@%

Infix attribute accessor

Capture dots

Capture dots with different kinds of splicing semantics.

dots_list list2

Collect dots tidily

dots_n

How many arguments are currently forwarded in dots?

Function arguments

arg_match

Match an argument to a character vector

missing_arg is_missing maybe_missing

Generate or handle a missing argument

Create conditions

These helpers make it easy to create typed conditions.

catch_cnd

Catch a condition

cnd error_cnd warning_cnd message_cnd

Create a condition object

is_condition

Is object a condition?

Signal conditions

abort warn inform

Signal an error, warning, or message

cnd_signal cnd_inform cnd_warn cnd_abort

Signal a condition

Restarts

with_restarts

Establish a restart point on the stack

rst_list rst_exists rst_jump rst_maybe_jump

Restarts utilities

rst_abort

Jump to the abort restart

rst_muffle

Jump to a muffling restart

Condition handlers

with_handlers

Establish handlers on the stack

exiting inplace

Create an exiting or in place handler

restarting

Create a restarting handler