Bug 15715

Summary: make call() more flexible
Product: R Reporter: Michael Lawrence <michafla>
Component: LanguageAssignee: R-core <R-core>
Status: NEW ---    
Severity: enhancement CC: btyner, tomas.kalibera
Priority: P5    
Version: R-devel (trunk)   
Hardware: Other   
OS: Linux   
Attachments: Patch converting call to BUILTIN and adding support for symbols and functions

Description Michael Lawrence 2014-03-15 15:02:46 UTC
Created attachment 1580 [details]
Patch converting call to BUILTIN and adding support for symbols and functions

The attached patch changes call() from a SPECIAL to a BUILTIN and adds support for passing a symbol or function as the 'name' argument. 

The change to a BUILTIN was initially motivated by the (undocumented) lack of support for "...", i.e.,

> fun <- function(...) call("paste", ...)
> fun("a", "b")
Error in fun("a", "b") (from #1) : '...' used in an incorrect context

Combined with the fact that call() was just evaluating its arguments anyway.

Adding support for symbol and function as the name argument just makes sense (well at least for symbols) and avoids the need to refer the user to as.call().
Comment 1 Benjamin Tyner 2018-07-14 23:44:15 UTC
Another way to skin the cat:

fun <- function(...) do.call("paste", list(...))
Comment 2 Tomas Kalibera 2018-07-16 10:56:37 UTC
I agree it makes sense to support a symbol. I am not sure if we should allow a function (closure object) directly into a call object/AST.  Re changing to builtin: it is a special from the beginning and I wonder why, there must have been a reason. Perhaps the change to builtin could be tested separately and it would be worth checking closely that the duplication/NAMED management is equivalent or correct (running CRAN+BIOC tests, re-checking examples like PR#15115, etc).