[ on call
On 07/07/2015 6:33 PM, Mick Jordan wrote:
I'm rather puzzled by this behavior:
e
export("caption<-", "caption", "label", "label<-", "align<-",
"align", "digits<-", "digits", "display<-", "display", "xtable",
"print.xtable", "toLatex.xtable")
> e[[1L]]
e[[1L]] export
> e[-1L]
e[-1L]
"caption<-"("caption", "label", "label<-", "align<-", "align",
"digits<-", "digits", "display<-", "display", "xtable",
"print.xtable",
"toLatex.xtable")
I'm not at all clear what should result from removing the first element,
i.e. the 'export', but I would not expect the first argument to be
promoted into the function position. I guess I would expect a coercion
to list or pairlist first, after which the [-1L] would produce a
meaningful result on that coercion. In any event I do observe that
as.character(e[-1L]) produces the expected result:
as.character(e[-1L])
[1] "caption<-" "caption" "label" "label<-"
[5] "align<-" "align" "digits<-" "digits"
[9] "display<-" "display" "xtable" "print.xtable"
[13] "toLatex.xtable"
This code is from parseNamespaceFile (on the xtable package).
In R, language objects are specially marked pairlists. The first element is the function to call, the second is its first argument, etc. So if you delete the first element and do nothing else, that promotes the first argument to the function to call. Duncan Murdoch