18.3 Infix calls

Every call in R can be written in tree form because any call can be written in prefix form.

y <- x * 10
`<-`(y, `*`(x, 10))
  • Since this is a characteristic of the language, regardless if it’s a function written in infix or prefix form, all function calls can be represented using an AST.

lobstr::ast(y <- x * 10)
#> █─`<-` 
#> ├─y 
#> └─█─`*` 
#>   ├─x 
#>   └─10
lobstr::ast(`<-`(y, `*`(x, 10)))
#> █─`<-` 
#> ├─y 
#> └─█─`*` 
#>   ├─x 
#>   └─10
  • There is no difference between the ASTs, and if you generate an expression with prefix calls, R will still print it in infix form:
rlang::expr(`<-`(y, `*`(x, 10)))
#> y <- x * 10