[Rd] serialize changes for 2.4.0

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Sep 5 22:39:54 CEST 2006


NEW FEATURES

    o	serialize(connection = NULL) now returns a raw vector (and not
	a character string).  unserialize() accepts both old and new
	formats (and has since 2.3.0).

serialize.Rd:

  The function \code{serialize} writes \code{object} to the specified
  connection.  Sharing of reference objects is preserved within the
  object but not across separate calls to serialize.  If
  \code{connection} is \code{NULL} then \code{object} is serialized to a
  raw vector, which is returned as the result of \code{serialize}.
  ^^^^^^^^^^
\section{Warning}{
  These functions are still experimental.  Names, interfaces and
  values might change in future versions (and was changed for \R 2.4.0).
  \code{.saveRDS} and \code{.readRDS} are intended for internal use.
}

\examples{
x <- serialize(list(1,2,3), NULL)
unserialize(x)
## test pre-2.3.0 interface as a length-one character vector
y <- rawToChar(x)
unserialize(y)
}

all seem clear enough to me ..., including the statement about being 
experimental.


On Tue, 5 Sep 2006, Roger D. Peng wrote:

> I noticed today that in R 2.3.1, I get
> 
>  > serialize(list(1,2,3), NULL, ascii = TRUE)
> [1] "A\n2\n131841\n131840\n19\n3\n14\n1\n1\n14\n1\n2\n14\n1\n3\n"
>  >
> 
> but in R 2.4.0 alpha I get
> 
>  > serialize(list(1,2,3), NULL, ascii = TRUE)
>   [1] 41 0a 32 0a 31 33 32 30 39 36 0a 31 33 31 38 34 30 0a 31 39 0a 33 0a 31 34
> [26] 0a 31 0a 31 0a 31 34 0a 31 0a 32 0a 31 34 0a 31 0a 33 0a
>  >
> 
> It seems I need to use 'rawToChar()' to get the character vector that I used to 
> get in R 2.3.1.
> 
> Is this intentional?  I couldn't find any mention of this change in the NEWS 
> file; from the docs, it seems to me that either return value could be correct.
> 
>  > version
>                 _
> platform       x86_64-unknown-linux-gnu
> arch           x86_64
> os             linux-gnu
> system         x86_64, linux-gnu
> status         alpha
> major          2
> minor          4.0
> year           2006
> month          09
> day            05
> svn rev        39121
> language       R
> version.string R version 2.4.0 alpha (2006-09-05 r39121)
>  >
> 
> -roger
> 

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-devel mailing list