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

integer64 support (follow up to #121) #122

Merged
merged 16 commits into from
Dec 11, 2018
Merged

integer64 support (follow up to #121) #122

merged 16 commits into from
Dec 11, 2018

Conversation

romainfrancois
Copy link
Contributor

No description provided.

NAMESPACE Outdated Show resolved Hide resolved
@romainfrancois romainfrancois changed the title follow up to #121 integer64 support (follow up to #121) Oct 19, 2018
R/arith.R Outdated Show resolved Hide resolved
@romainfrancois
Copy link
Contributor Author

Is it worth doing this as a record with a single field for better control of things and then relay back to bit64 only for the low level ?

@hadley
Copy link
Member

hadley commented Oct 24, 2018

I'd prefer to stick with raw bit64 for now

@@ -27,7 +27,8 @@ Suggests:
pkgdown,
rmarkdown,
testthat,
tibble
tibble,
bit64
Copy link

@javierluraschi javierluraschi Oct 30, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we really add bit64 as suggest but not under imports? In arrow, it was easy to hit crashes if bit64 gets unloaded, see apache/arrow#2867, but maybe that's not the case in vctrs, just passing along FWIW.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine to use Suggests and then bit64:: when we need a function from it.

@romainfrancois
Copy link
Contributor Author

Was there anything else needed for this ?

@hadley
Copy link
Member

hadley commented Nov 19, 2018

I just need some time to think it through. Is it blocking you?

@romainfrancois
Copy link
Contributor Author

Not really, arrow just uses a remote, that's fine.

https://github.com/apache/arrow/blob/master/r/DESCRIPTION#L31

Copy link
Member

@hadley hadley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#' @param ...,class Used to for subclasses.
#' @keywords internal
#' @export
new_int64 <- function(x = bit64::integer64(), ..., class = character()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we actually need this function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really, was mostly following the pattern, and provision for derived classes.


# Coerce ------------------------------------------------------------------

#' @export
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please check this is up to date with the advice in https://vctrs.r-lib.org/articles/s3-vector.html#double-dispatch?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just unsure about

#' @export
#' @method vec_cast.integer64 logical
vec_cast.integer64.logical <- function(x, to) {
  bit64::as.integer64(x)
}

Does this need to distinguish the unspecified case given that cast to logical is allowed, or is this good enough:

library(vctrs)
x <- bit64::as.integer64(1:10)
vec_cast(x, unspecified())
#> Error: Can't cast <integer64> to <vctrs_unspecified>
vec_cast(x, NA)
#>  [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE

Created on 2018-11-20 by the reprex package (v0.2.1.9000)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the other way around:

library(vctrs)
x <- bit64::as.integer64(1:10)
vec_cast(unspecified(), x)
vec_cast(NA, x)

And I think you need to use vec_unspecified_cast(x, to) in that method

- new_int64 function
+ vec_type2.integer64.vctrs_unspecified
+ vec_type2.vctrs_unspecified.integer64
@hadley
Copy link
Member

hadley commented Nov 21, 2018

Looks good. I'll merge once vctrs is on CRAN.

@hadley hadley mentioned this pull request Nov 21, 2018
12 tasks
@javierluraschi
Copy link

@hadley can we merge since vctrs is in CRAN?

@hadley hadley merged commit 852c428 into r-lib:master Dec 11, 2018
@hadley
Copy link
Member

hadley commented Dec 11, 2018

Done!

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

Successfully merging this pull request may close these issues.

3 participants