Skip to content

Add support for NSE functions and semantic effects #1338

Description

@lionel-

Most important effect to support: evaluation in a nested scope (e.g. test_that()). Definitions in a nested scope shouldn't escape.

Other effects to support soon:

  • Attach (library(), require())
  • Source
  • Assign (S7's :=, magrittr's %<>%, base::delayedAssign(), etc)
  • Quote (quote(), bquote()), including unquoted holes with e.g. .(arg) or !!arg

Effects for later:

  • Eval (to be done a bit later because this requires data flow to be useful)
  • ExprCapture (substitute())
  • EnvCapture (new.env(), parent.frame(), environment())

Not straightforward because these effects can interact with each other, e.g. a Source may hide effects, a nested NSE scope may cause an effect to be masked, or on the contrary may prevent an effect to be masked, etc. Main idea: resolve effect linearly. Any effect in a lazy scope that contradicts a linear effect is an ambiguous program that should be linted.

All these effects should be expressible with either:

  • Local declarations with declare(), which requires a mini language spec for describing these effects

  • Custom Rust handlers vendored in Oak. Many functions have complex effects depending on arguments and trying to express these with a DSL is a lost cause. We'll provide support for argument matching, static resolution of values, etc.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions