Repository navigation
Conversation
This allows for option syntax similar to V8’s one, e.g. `--no_warnings` has the same effect as `--no-warnings`.
|
A test is not happy: |
|
@targos Yeah, should be fixed now :) |
| <!-- YAML | ||
| changes: | ||
| - version: REPLACEME | ||
| pr-url: https://github.com/nodejs/node/pull/REPLACEME |
commented
Sep 22, 2018
|
Do we know if this has any down side? AFAIK It's not a common practice with CLI interfaces? I'd love to have some discussion around this. I can think of some minor concerns, like: less " Maybe we should go the other way, and deprecate flags with |
commented
Sep 22, 2018
|
@refack I think we would still document and list exclusively the The upsides here are consistency with V8 options and simplification of our own options-related code. We’ve had options like I would also prefer not to deprecate V8 flags in our code… |
| if (equals_index != std::string::npos) | ||
| original_name += '='; | ||
|
|
||
| { |
There was a problem hiding this comment.
IMO should be:
for(auto& i: name) {
if (i == '_') i = '-';
}
So there's no need for the scope, and no use of while when there's an iterator.
ES.71
There was a problem hiding this comment.
We still have as a rule here to avoid using non-const references., and the rule you linked doesn’t seem to apply here (this is not a for loop to begin with). If you want, this can be
for (std::string::size_type i = 0; i < name.size(); ++i) {
if (name[i] == '_')
name[i] = '-';
}There was a problem hiding this comment.
I do like the for variant better. It's simple, and probably has comparable performance.
There was a problem hiding this comment.
P.S. There ES.72 - Prefer a for-statement to a while-statement when there is an obvious loop variable
There was a problem hiding this comment.
Which for variant? The no-non-const-references rule has a good reason, which is that it should be obvious what is being modified (and in your code that is name and not just i itself).
There was a problem hiding this comment.
The no-non-const-references rule has a good reason
I have no doubt rules have good reasons. Personally I'm assuming anything that is not const is going to be changed, but I'd be happy to discuss this in the context of updating the c++ style guide.
There was a problem hiding this comment.
The no-non-const-references rule
Where can I find a reference to that?
commented
Sep 22, 2018
I agree with the upsides. But are there any downsides? |
commented
Sep 22, 2018
|
@refack I have switched to the second
It’s not been written down so far, as far as I can tell; it’s come up as part of reviews a lot, though. I’ve opened #23028.
Nothing that you haven’t mentioned yourself, I think. |
commented
Sep 23, 2018
commented
Sep 23, 2018
Maybe a tiny, most probably unmeasurable difference in start up due to option parsing normalisation? |
commented
Sep 24, 2018
I believe that is negligible (maybe the added code burden, but I think we actually end up with less code).
Just a point of thought, V8 doesn't have CLI options, it's an embedded engine. We decide what options it gets. We have a legacy code path that passes our CLI options to V8 verbatim. |
commented
Sep 24, 2018
The V8 API is called |
commented
Sep 25, 2018
|
Re-run of failing node-test-commit-arm. |
commented
Sep 25, 2018
|
Landed in 0227635. |
This allows for option syntax similar to V8’s one, e.g.
--no_warningshas the same effect as--no-warnings.Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes