Skip to content

Request: make ast() not automatically unwrap quosures #50

@wch

Description

@wch

I was using rlang::blast(), and trying to understand how it works.

lazyeval::ast_() shows the actual call:

blast <- function(expr, env = caller_env()) {
  eval_bare(enexpr(expr), env)
}
exp <- quo(a + b)

f <- function(x) {
  lazyeval::ast_(sys.call())
  invisible()
}
blast(f(!!exp))
#> ┗ ()
#>  ┗ `f
#>  ┗ ()
#>   ┗ `~
#>   ┗ ()
#>    ┗ `+
#>    ┗ `a
#>    ┗ `b 

However lobstr::ast(!!x) unwraps the quosures so you don't see the actual call:

g <- function(x) {
  lobstr::ast(!!sys.call())
  invisible()
}
blast(g(!!exp))
#> █─g 
#> └─█─`+` 
#>   ├─a 
#>   └─b 

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions