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

revert class_array and class_matrix #463

Merged
merged 1 commit into from
Oct 15, 2024
Merged

Conversation

t-kalinowski
Copy link
Member

This PR removes class_array and class_matrix, pending further design and discussion.

#401 (comment)

array and matrix are unique because these are implicit S3 classes based on the presence of a dim attribute.

Quoting from ?UseMethod:

If the object does not have a class attribute, it has an implicit class. Matrices and arrays have class "matrix" or "array" followed by the class of the underlying vector. Most vectors have class the result of mode(x), except that integer vectors have class c("integer", "numeric") and real vectors have class c("double", "numeric").

E.g.:

> x <- 1
> attr(x, "dim") <- c(1, 1)
> .class2(x)
[1] "matrix"  "array"   "double"  "numeric"

@t-kalinowski t-kalinowski merged commit 4c3cb81 into main Oct 15, 2024
11 checks passed
@t-kalinowski t-kalinowski deleted the revert-implicit-s3-array branch October 15, 2024 16:02
@lawremi
Copy link
Collaborator

lawremi commented Oct 15, 2024

I feel like this might have jumped the gun a little. An S7_S3_class for matrix and array is still useful, because there are objects with that class. Sure, the hierarchy varies, but we can still use these for dispatch and properties.

To make something responsive to is.matrix() is orthogonal to these classes, in my opinion.

@hadley
Copy link
Member

hadley commented Oct 16, 2024

@lawremi I think we just need to discuss this a bit more before committing to an API. And we want to do a minor release soon, so pulling these out just gives us a bit more time to think about them.

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