dput(as.list(function...)...) bug
Stavros Macrakis wrote:
Tested in R 2.8.1 Windows
ff <- formals(function(x)1)
ff1 <- as.list(function(x)1)[1]
# ff1 acts the same as ff in the examples below, but is a list rather than a pairlist
dput( ff , control=c("warnIncomplete"))
list(x = ) This string is not parsable, but dput does not give a warning as specified.
same in 2.10.0 r48200, ubuntu 8.04 linux 32 bit
dput( ff , control=c("all","warnIncomplete"))
list(x = quote())
likewise.
This string is parseable, but quote() is not evaluable, and again dput
does not give a warning as specified.
In fact, I don't know how to write out ff$x. It appears to be the
zero-length name:
is.name(ff$x) => TRUE
as.character(ff$x) => ""
but there is no obvious way to create such an object:
as.name("") => execution error
quote(``) => parse error
The above examples should either produce a parseable and evaluable
output (preferable), or give a warning.
interestingly,
quote(NULL)
# NULL
as.name(NULL)
# Error in as.name(NULL) :
# invalid type/length (symbol/0) in vector allocation
?sj.
vQ
-s PS As a matter of comparative linguistics, many versions of Lisp allow zero-length symbols/names. But R coerces strings to symbols/names in a way that Lisp does not, so that might be an invitation to obscure bugs in R where it is rarely problematic in Lisp. PPS dput(pairlist(23),control="all") also gives the same output as dput(list(23),control="all"), but as I understand it, pairlists will become non-user-visible at some point.
______________________________________________ R-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
------------------------------------------------------------------------------- Wacek Kusnierczyk, MD PhD Email: waku at idi.ntnu.no Phone: +47 73591875, +47 72574609 Department of Computer and Information Science (IDI) Faculty of Information Technology, Mathematics and Electrical Engineering (IME) Norwegian University of Science and Technology (NTNU) Sem Saelands vei 7, 7491 Trondheim, Norway Room itv303 Bioinformatics & Gene Regulation Group Department of Cancer Research and Molecular Medicine (IKM) Faculty of Medicine (DMF) Norwegian University of Science and Technology (NTNU) Laboratory Center, Erling Skjalgsons gt. 1, 7030 Trondheim, Norway Room 231.05.060