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

[vcpkg] Rewriting CmdLineBuilder/Command (3/n) #15673

Merged
merged 1 commit into from Jan 16, 2021

Conversation

strega-nil
Copy link
Contributor

Rename CmdLineBuilder to Command, since it's no longer a builder but an actual data type.

This is the 3rd PR in the "rewrite CmdLineBuilder" saga; at this point, we need a new type name :)

@strega-nil strega-nil changed the title [vcpkg] Rewriting CmdLineBuilder/Command (3/n) [vcpkg] Rewriting CmdLineBuilder/CommandLine (3/n) Jan 15, 2021
explicit Command(const std::string& s) { string_arg(s); }
explicit Command(const char* s) { string_arg({s, ::strlen(s)}); }

Command& path_arg(const fs::path& p) & { return string_arg(fs::u8string(p)); }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit unhappy with the combination of the "data" name plus "data" named functions; specifically, it is not clear from the name of the type nor the name of the functions that these are mutating functions -- you need to either notice that the return type is & or read the implementation to know that these will mutate the existing object.

This is why I named the original type "Builder": so that the functions like path_arg could be short instead of append_path_arg() yet there was still nomenclature to note that these functions are mutating.

Copy link
Contributor

@ras0219 ras0219 Jan 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also generally don't see sufficient motivation for change in the name, this just introduces code churn for insufficient gain IMO.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree; it's fundamentally no longer a "builder", it's "the thing itself".

Also, I would argue that this kind of naming for functions makes sense; see Rust's Command type, which does the same thing.

@strega-nil strega-nil changed the title [vcpkg] Rewriting CmdLineBuilder/CommandLine (3/n) [vcpkg] Rewriting CmdLineBuilder/Command (3/n) Jan 15, 2021
Rename CmdLineBuilder to Command, since it's no longer a builder but an actual data type
@strega-nil strega-nil merged commit b60f003 into microsoft:master Jan 16, 2021
@strega-nil strega-nil deleted the fix-cmdlinebuilder branch January 19, 2021 19:51
strega-nil added a commit to strega-nil/vcpkg that referenced this pull request May 5, 2021
Rename CmdLineBuilder to Command, since it's no longer a builder but an actual data type
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.

None yet

3 participants