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

refactor: Refactor Ptr struct to generic with type Tag #651

Merged
merged 1 commit into from
Sep 7, 2023

Conversation

huitseeker
Copy link
Contributor

Summary

In order to unify the current and LEM ways of defining the primary circuit and operating on it (so as to further #629), we need to abstract away a type that allows the developer to specify the associated types this circuit construction relies on. We started on this path with #644 and #647.

At a high level, each of the two implementations we have in mind for those traits define a single pointer type, rather than two. It would be ergonomic to have one.

The present PR defines Ptr and ContPtr as two distinct instantiations of a single pointer type, which is something we've wanted to do for a while already. We just needed an excuse.

Details

  • Refactored Ptr struct into a generic GPtr struct, introducing type parameter T and associating it with Tag interface.
  • Created Ptr and ContPtr types derived from GPtr.
  • Common methods are defined on GPtr,
  • Transferred pertinent predicate methods such as is_nil, is_cons, is_atom, is_list, as_cons, as_list to GPtr<F, ExprTag>.
  • Transferred ContPtr struct and corresponding methods to GPtr<F, ContTag>.
  • No modifications made to ExprTag / ContTag and associated enum elements in tag.rs.
  • Added std::hash::Hash trait to Tag interface in tag.rs.

@huitseeker huitseeker requested a review from a team as a code owner September 5, 2023 22:37
src/ptr.rs Outdated Show resolved Hide resolved
porcuquine
porcuquine previously approved these changes Sep 5, 2023
Copy link
Contributor

@porcuquine porcuquine left a comment

Choose a reason for hiding this comment

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

Okay, with one pointed but non-blocking question.

- Refactored `Ptr` struct into a generic `GPtr` struct, introducing type parameter `T` and associating it with `Tag` interface.
- Created `Ptr` and `ContPtr` types derived from `GPtr`.
- Transferred pertinent predicate methods such as `is_nil`, `is_cons`, `is_atom`, `is_list`, `as_cons`, `as_list` to the new `GPtr<F, ExprTag>` implementation.
- Transferred `ContPtr` struct and corresponding methods to `GPtr<F, ContTag>`.
- No modifications made to `ExprTag` and associated enum elements in `tag.rs`.
- Added `std::hash::Hash` trait to `Tag` interface in `tag.rs`.
@huitseeker huitseeker added this pull request to the merge queue Sep 7, 2023
Merged via the queue into lurk-lab:master with commit c678647 Sep 7, 2023
6 checks passed
@huitseeker huitseeker deleted the fuse_cont_ptr branch September 7, 2023 23:36
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