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 class lookup table #461

Closed
wants to merge 2 commits into from
Closed

Add class lookup table #461

wants to merge 2 commits into from

Conversation

t-kalinowski
Copy link
Member

@t-kalinowski t-kalinowski commented Oct 10, 2024

This PR enables usage of the base constructors like base::character in new_class(), new_property(), and similar.

For example:

library(S7)
Foo <- new_class("Foo", parent = character)

Foo
#> <foo> class
#> @ parent     : <character>
#> @ constructor: function(.data) {...}
#> @ validator  : <NULL>
#> @ properties :
Foo()
#> <foo> chr(0)

@lawremi
Copy link
Collaborator

lawremi commented Oct 15, 2024

What is the rationale? We had considered this early on, since classes are constructors, but we went with reified class objects instead. I'm not sure about having both.

@t-kalinowski
Copy link
Member Author

classes are constructors

The consistency of this is enticing. Also, less typing.

One downside is that | wouldn't dispatch to new_union(), so usage would have to be
as_class(character) | numeric or new_union(character, numeric)

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.

2 participants