[R] weirdness in sourc()ing a dump() (bug?)
Duncan Murdoch
dmurdoch at pair.com
Wed May 5 21:40:48 CEST 2004
On Wed, 5 May 2004 20:20:51 +0100 (BST), Prof Brian Ripley
<ripley at stats.ox.ac.uk> wrote :
>I don't think it is a bug. Note that dump does not even claim to dump
>lists let alone symbols, but ?dump says
>
> At present the implementation of 'dump' is very incomplete and it
> really only works for functions and simple vectors.
>
>Given that, this is not unexpected. (Looks like more than one person did
>not check the help page ....)
>
>I think save/load is a much safer way to handle saving R objects, and it
>does work in PD's example.
I'd still call it a bug, since 'dump("x"); source("dumpdata.R")' could
change the meaning of x without any warning, and that can't be
desirable behaviour.
For example,
> f<-function (...)
+ {
+ return(list(call.list = as.list(match.call())))
+ }
> x <- f(y=4)
> x
$call.list
$call.list[[1]]
f
$call.list$y
[1] 4
> f <- quote(g)
> dump("x")
> source("dumpdata.R")
> x
$call.list
$call.list[[1]]
g
$call.list$y
[1] 4
If dump() can't handle certain kinds of objects, then it should signal
an error, it shouldn't dump something that can't be sourced properly.
Duncan Murdoch
More information about the R-help
mailing list