-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Hide Interpreter
in .cpp
#1036
Hide Interpreter
in .cpp
#1036
Conversation
This improves encapsulation, and makes Interpreter lifetimes clearer (and shorter).
@@ -27,6 +27,83 @@ using llvm::isa; | |||
|
|||
namespace Carbon { | |||
|
|||
// Tag types for selecting Interpreter constructors. | |||
struct CompileTimeTag {}; |
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 you're doing this to disambiguate constructor overloads. My sense is that a factory method would be a more common approach (MakeRunTime/MakeCompileTime), although an enum (e.g., todo_(mode == RunTime ? &heap_ : nullptr)
) is also something I'm used to seeing. What do you think of switching approaches?
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.
Factory methods don't really help here, because I need to conditionally pass one member to the constructor of another, which can only happen during construction, not before or after. I've redone this to use an enum, but I'm not convinced it's a net improvement. WDYT?
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
Co-authored-by: Jon Meow <46229924+jonmeow@users.noreply.github.com>
This improves encapsulation, and makes Interpreter lifetimes clearer (and shorter).