collections icon indicating copy to clipboard operation
collections copied to clipboard

Backwards compatibility issue

Open christopher-hardy opened this issue 4 years ago • 2 comments

Hi,

Thanks for creating this package it has been a great help.

I was using v0.3.3 and had saved the object, then upgraded to v0.3.5. When I read the v0.3.3 object into a v0.3.5 environment I get the following error: Error in missing_arg(default) : could not find function "missing_arg". If I re-create the same hash using v0.3.5 everything works OK.

Reproducible Example:

# install v0.3.3 & v0.3.5
devtools::install_version(
  "collections", 
  version = "0.3.3",
  lib = "~/v3.3"
)
devtools::install_version(
  "collections", 
  version = "0.3.5",
  lib = "~/v3.5"
)

# create and save hash in v0.3.3
detach("package:collections", unload = TRUE)
library("collections", lib = "~/v3.3")
h3.3 <- dict(
  items = list(1, 2, 3),
  keys = list("A", "B", "C")
)
saveRDS(h3.3, file = "~/v3.3.rds")

# load v0.3.5
detach("package:collections", unload = TRUE)
library("collections", lib = "~/v3.5")
h3.3 <- readRDS(file = "~/v3.3.rds")
h3.3$get("A")
# Error in missing_arg(default) : could not find function "missing_arg"

# create and test new hash in v0.3.5
h3.5 <- dict(
  items = list(1, 2, 3),
  keys = list("A", "B", "C")
)
h3.5$get("A")

christopher-hardy avatar Aug 11 '20 22:08 christopher-hardy

Unfortunately, the dict object is not meant to be portable in such way. It is very easy to break things. We might need to encapsulate the whole closure in order to make it portable.

Thank you for raising the issue though.

randy3k avatar Aug 11 '20 23:08 randy3k

Actually it isn't limited to this package. A lot of other packages are subjected to break if an object is serialised and deserialised under different versions.

randy3k avatar Aug 11 '20 23:08 randy3k