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

Extend Interfaces and Existing R Types #7

Closed
dereckmezquita opened this issue Jul 6, 2024 · 0 comments
Closed

Extend Interfaces and Existing R Types #7

dereckmezquita opened this issue Jul 6, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@dereckmezquita
Copy link
Owner

Description

Allow interfaces to extend other interfaces or existing R types, similar to inheritance in object-oriented programming.

Related to #3

Implementation Ideas

  • Modify the interface() function to accept a extends parameter.
  • Update the check_interface() function to check properties from extended interfaces or types.
  • Implement a mechanism to resolve property conflicts in case of multiple extensions.

Example Usage

# Extend an existing interface
Person <- interface("Person",
    name = "character",
    age = "numeric"
)

Employee <- interface("Employee",
    extends = Person,
    job_title = "character",
    salary = "numeric"
)

john <- implement(Employee,
    name = "John Doe",
    age = 30,
    job_title = "Developer",
    salary = 75000
)

# TODO: this needs more work
# Extend an existing R type
EnhancedDataFrame <- interface("EnhancedDataFrame",
    extends = "data.frame",
    metadata = "list"
)

my_df <- implement(EnhancedDataFrame,
    data.frame(x = 1:3, y = c("a", "b", "c")),
    metadata = list(created_at = Sys.time())
)

Integration with Existing Codebase

  • Modify R/interface.R to handle the extends parameter.
  • Update R/helpers.R to include extended property checking in check_interface().
  • Add new test cases in tests/testthat/test-interface.R for extension functionality.
@dereckmezquita dereckmezquita added the enhancement New feature or request label Jul 6, 2024
@dereckmezquita dereckmezquita added this to the v0.1.0 milestone Jul 6, 2024
@dereckmezquita dereckmezquita self-assigned this Jul 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant