Skip to content

[Incremental] Use the initial value of EnableFineGrainedDependencies as the default. #29390

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

Merged
merged 1 commit into from
Jan 23, 2020

Conversation

davidungar
Copy link
Contributor

Following up on a thought by @varungandhi-apple , centralize the default for enabling fine-grained-dependencies.

@davidungar
Copy link
Contributor Author

@swift-ci please smoke test

@davidungar
Copy link
Contributor Author

@swift-ci please smoke test

@varungandhi-apple
Copy link
Contributor

Ah I wasn't clear in my comment last time. What I meant in that PR was having something like say a header named swift/Basic/DefaultOptions.h which has stuff like

namespace swift {
namespace default {
static constexpr bool EnableFineGrainedDependencies = false;
// ... other default options.
}
}

And all the places which use it refer to it as default::EnableFineGrainedDependencies. I think we should consult other people on what they think, since if we start adopting such a style it would affect other parts of the code too.

The solution you've taken here also works, in that it achieves the same goal of avoiding duplicate magic constants. However, I feel that it ends up creating slightly awkward looking statements like

  Opts.EnableFineGrainedDependencies =
       Args.hasFlag(options::OPT_enable_fine_grained_dependencies,
                    options::OPT_disable_fine_grained_dependencies,
                    Opts.EnableFineGrainedDependencies);

where one needs to have the surrounding context that "Opts was default initialized before, and we are setting this parameter for the first time, not resetting it based on an 'old' value". Instead, if it were written like

  Opts.EnableFineGrainedDependencies =
       Args.hasFlag(options::OPT_enable_fine_grained_dependencies,
                    options::OPT_disable_fine_grained_dependencies,
                    default::EnableFineGrainedDependencies);

it doesn't require any surrounding context since convention dictates that all default::Foo values are const/constexpr.

@davidungar
Copy link
Contributor Author

@swift-ci please smoke test

@davidungar
Copy link
Contributor Author

Ah I wasn't clear in my comment last time. What I meant in that PR was having something like say a header named swift/Basic/DefaultOptions.h which has stuff like

namespace swift {
namespace default {
static constexpr bool EnableFineGrainedDependencies = false;
// ... other default options.
}
}

And all the places which use it refer to it as default::EnableFineGrainedDependencies. I think we should consult other people on what they think, since if we start adopting such a style it would affect other parts of the code too.

The solution you've taken here also works, in that it achieves the same goal of avoiding duplicate magic constants. However, I feel that it ends up creating slightly awkward looking statements like

  Opts.EnableFineGrainedDependencies =
       Args.hasFlag(options::OPT_enable_fine_grained_dependencies,
                    options::OPT_disable_fine_grained_dependencies,
                    Opts.EnableFineGrainedDependencies);

where one needs to have the surrounding context that "Opts was default initialized before, and we are setting this parameter for the first time, not resetting it based on an 'old' value". Instead, if it were written like

  Opts.EnableFineGrainedDependencies =
       Args.hasFlag(options::OPT_enable_fine_grained_dependencies,
                    options::OPT_disable_fine_grained_dependencies,
                    default::EnableFineGrainedDependencies);

it doesn't require any surrounding context since convention dictates that all default::Foo values are const/constexpr.

Thanks again! I agree about that there's some awkwardness here, but the ability to disable a somewhat risky change in a single place outweighs the awkward factor for me.

The "default" proposal interesting. It smacks of the challenge we face when we try to project a multidimensional problem down into a one-dimensional containment hierarchy. The projection forces us to privilege one dimension above all others.

@davidungar
Copy link
Contributor Author

@swift-ci please smoke test os x platform

@davidungar davidungar merged commit 2f79ff7 into swiftlang:master Jan 23, 2020
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