Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a canonical approach for ingesting a raw stream as integer64 #117

Open
MichaelChirico opened this issue Oct 23, 2024 · 1 comment
Open

Comments

@MichaelChirico
Copy link
Collaborator

MichaelChirico commented Oct 23, 2024

Dedicated issue for #39 / #116 which requested this through as.integer64.raw().

I think we can do this by adding yet-another hijack:

readBin <- function (con, what, n = 1L, size = NA_integer_, signed = TRUE, endian = .Platform$endian) {
  x <- base::readBin(...)
  if (is.integer64(what)) class(x) = 'integer64'
  x  
}

cc @hadley @coolbutuseless

@hadley
Copy link
Member

hadley commented Oct 24, 2024

I'd prefer to draw from what most other languages do and provide a dedicated parseInt64BE/parseInt64LE (and maybe UInit too?).

(I'm not sure what the correct prefix here is. read doesn't feel quite right to because it's usually about reading complete files from disk/a connection. But parse() isn't quite right either because there isn't really any parsing going on here.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants