-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Refactor CppWitness as CustomWitness #6491
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
Conversation
danakj
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
|
||
| // A witness synthesized for an arbitrary construct. For example, a `Destroy` | ||
| // witness, or a C++ overloaded operator. | ||
| struct CustomWitness { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe BuiltinWitness to explain its meaning and difference from a witness coming from carbon code a little more? And as opposed to "custom" as in user-customized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's user-customized similar to CustomLayoutType. That is, both tracking the mapping of user code (references to members of a type) in a particular layout that Carbon expects. Neither instruction is directly modified by users, but both track things in a way distinct from how more standard types/witnesses behave (and could in theory support arbitrary things, including the more standard Carbon equivalent).
Note too, there's not much builtin here:
- The
Destroyinterface is user-defined. - For C++, it's a thin wrapper around a C++ destructor thunk.
- Equivalent for other things, like copy, move,
+, etc
- Equivalent for other things, like copy, move,
- For Carbon, it will eventually become a thin wrapper around a call to a vtable function for destroy.
- Perhaps only copy, move as equivalents (not sure how far this will go)
This is in anticipation of using the same construct for all implementations of
Destroy, as well as other similar use-cases with language-defined interfaces.