curly_arg: Process curly parameters

View source: R/base_utils.R

curly_argR Documentation

Process curly parameters

Description

Curly parameters are processed using NSE, unless they are encapsulated in curlies {}, which optionally triggers standard evaluation. This function is only intended to be used inside another function, and it is used in a very similar way to match.arg(). The examples are very useful ...

Usage

curly_arg(param)

Arguments

param

The parameter to process as a curly param.

Examples

# Not run automatically because curly_arg() is private
## Not run: 
  # Usage of curly_arg() compared with match.arg()
  curly_demo <- function(x, y = c("yes", "no")) {
    x <- zfit:::curly_arg(x)
    y <- match.arg(y)
    x
  }

  myparam  <- "a string"
  myvector <- c("string 1", "string 2")

  curly_demo(a_symbol)       # NSE ON
  curly_demo("a string")     # NSE disabled with "" for constant strins
  curly_demo({"curly-wrap"}) # NSE disabled with {}
  curly_demo(c("a","b"))     # NSE ON, usually not wanted, quoting preferred
  curly_demo({c("a","b")})   # NSE disabled with {}, allowing vectors
  curly_demo(myparam)        # NSE ON, even if a value exists for myparam
  curly_demo("myparam")      # NSE disabled, result is a string constant
  curly_demo({myparam})      # NSE disabled, value of myparam propagates
  curly_demo({myvector})     # NSE disabled, value of myvector propagates

## End(Not run)


zfit documentation built on Aug. 27, 2023, 5:06 p.m.