Skip to content

Add class lookup table#461

Closed
t-kalinowski wants to merge 2 commits intomainfrom
class-lookup-table
Closed

Add class lookup table#461
t-kalinowski wants to merge 2 commits intomainfrom
class-lookup-table

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