R-alpha: names(j) <- NULL fails for a `call' object

Martin Maechler Martin Maechler <maechler@stat.math.ethz.ch>
Thu, 30 Oct 1997 11:54:52 +0100


I found this ((as part of a more severe problem which WAS fixed))
in   ``old closed tasks'' a while ago..

It still _is_ a  (minor) problem, i.e. an  R<-->S inconsistency


##- TASK:	Name Attributes on Calls
##- STATUS: Closed
##- FROM:	<p.dalgaard@kubism.ku.dk>
##- 	A call with tagged arguments is something like a list, the tags
##- 	can be used to access elements, but the names attribute is absent,
##- 	until the call is coerced to a list. (Attempting to set the names()
##- 	causes evaluation. Changing "list" to "blipblop" causes an 'Error:
##- 	couldn't find function "blipblop"' at that point.)

print(j <- substitute(list(a=1, b=2)))##	list(a = 1, b = 2)
mode(j); is.call(j)#  "call" ,  TRUE
j$b##	[1] 2
names(j)# [1] ""  "a" "b"

names(j) <- NULL ; j #-- doesn't do anything in R -- but does in S-plus
## S:   list(1, 2)
## R-0.50-a2 and  R-0.50-a4 :
##	list(a = 1, b = 2)
mode(j)#>  [1] "call"
names(j)# S: NULL;  R:  ""  "a" "b"

names(j) <- c("", "CC", "DD"); j #-- this DOES work ...
names(j) <- c("", "", ""); j #-- this DOES work ...
names(j) <- c("blipblop", "x", "y"); j# no change to 'list' [[same for R and S]]
## list(x = 1, y = 2)
names(j) #  [[same for R and S]]:
## [1] "blipblop" "x"        "y"
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=