[Rd] support of `substitute(...())`
William Dunlap
wdun|@p @end|ng |rom t|bco@com
Thu Mar 12 16:06:05 CET 2020
Note that substitute(...()) and substitute(someFunc(...))[-1] give slightly
different results, the former a pairlist and the latter a call.
> str((function(...)substitute(...()))(stop(1),stop(2),stop(3)))
Dotted pair list of 3
$ : language stop(1)
$ : language stop(2)
$ : language stop(3)
>
str((function(...)substitute(someFunc(...))[-1])(stop(1),stop(2),stop(3)))
language stop(1)(stop(2), stop(3))
The ...() idiom has been around for a long time, but more recently
(slightly after R-3.4.0?) the ...elt(n) and ...length() functions were
introduced so you don't have to use it much. I don't see a ...names()
function that would give the names of the ... arguments -
names(substitute(...())).
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Thu, Mar 12, 2020 at 2:09 AM Dénes Tóth <toth.denes using kogentum.hu> wrote:
> Dear R Core Team,
>
> I learnt approx. two years ago in this mailing list that one can use the
> following "trick" to get a (dotted pair)list of the ellipsis arguments
> inside a function:
>
> `substitute(...())`
>
> Now my problem is that I can not find any occurrence of this call within
> the R source - the most frequent solution there is
> `substitute(list(...))[-1L] `
>
> I would like to know if:
> 1) substitute(...()) is a trick or a feature in the language;
> 2) it will be supported in the future;
> 3) when (in which R version) it was introduced.
>
> A hint on where to look for the machinery in the R source would be also
> appreciated.
>
> Regards,
> Denes
>
> ______________________________________________
> R-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
[[alternative HTML version deleted]]
More information about the R-devel
mailing list