refactor: Refactor Ptr struct to generic with type Tag #651
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
andContPtr
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
Ptr
struct into a genericGPtr
struct, introducing type parameterT
and associating it withTag
interface.Ptr
andContPtr
types derived fromGPtr
.GPtr
,is_nil
,is_cons
,is_atom
,is_list
,as_cons
,as_list
toGPtr<F, ExprTag>
.ContPtr
struct and corresponding methods toGPtr<F, ContTag>
.ExprTag
/ContTag
and associated enum elements intag.rs
.std::hash::Hash
trait toTag
interface intag.rs
.