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

Hide Interpreter in .cpp #1036

Merged
merged 4 commits into from
Jan 26, 2022
Merged

Hide Interpreter in .cpp #1036

merged 4 commits into from
Jan 26, 2022

Conversation

geoffromer
Copy link
Contributor

This improves encapsulation, and makes Interpreter lifetimes clearer (and shorter).

This improves encapsulation, and makes Interpreter lifetimes clearer (and shorter).
@geoffromer geoffromer requested a review from a team as a code owner January 21, 2022 20:43
@@ -27,6 +27,83 @@ using llvm::isa;

namespace Carbon {

// Tag types for selecting Interpreter constructors.
struct CompileTimeTag {};
Copy link
Contributor

@jonmeow jonmeow Jan 21, 2022

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?

Copy link
Contributor Author

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?

Copy link
Contributor

@jonmeow jonmeow left a 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>
@geoffromer geoffromer merged commit 2a74a42 into carbon-language:trunk Jan 26, 2022
@geoffromer geoffromer deleted the interpreter branch January 26, 2022 17:57
chandlerc pushed a commit that referenced this pull request Jun 28, 2022
This improves encapsulation, and makes Interpreter lifetimes clearer (and shorter).

Co-authored-by: Jon Meow <46229924+jonmeow@users.noreply.github.com>
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