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

Replace vague 'may not' with definitive 'will not' #23143

Closed
wants to merge 6 commits into from
Closed

Replace vague 'may not' with definitive 'will not' #23143

wants to merge 6 commits into from

Conversation

mikemaccana
Copy link
Contributor

@mikemaccana mikemaccana commented Sep 28, 2018

This vagueness of 'may' has caused a great deal of confusion. See https://stackoverflow.com/questions/8887318/understanding-node-js-modules-multiple-requires-return-the-same-object

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added doc Issues and PRs related to the documentations. module Issues and PRs related to the module subsystem. labels Sep 28, 2018
@vsemozhetbyt vsemozhetbyt added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Sep 28, 2018
@vsemozhetbyt
Copy link
Contributor

CI-lite: https://ci.nodejs.org/job/node-test-pull-request-lite-pipeline/1050/

(Not sure why CI shows different commit though)

@vsemozhetbyt
Copy link
Contributor

Node.js Collaborators, please, add 👍 here if you approve fast-tracking.

@richardlau
Copy link
Member

CI-lite: https://ci.nodejs.org/job/node-test-pull-request-lite-pipeline/1050/

(Not sure why CI shows different commit though)

image

If you're referring to ea008c89204368d6534b1690a3fd99ed7976c9d2 (f4d400d02167747d4de3967589294fad1948fe31 is the commit for this PR) then it refers to the commit of the build repository that is used for the pipeline (we're storing the definition for the pipeline in the build repository, in this case https://github.com/nodejs/build/blob/ea008c89204368d6534b1690a3fd99ed7976c9d2/jenkins/pipelines/node-test-pull-request-lite-pipeline.jenkinsfile).

@refack
Copy link
Contributor

refack commented Sep 28, 2018

/CC @nodejs/modules

@jdalton
Copy link
Member

jdalton commented Sep 28, 2018

The may not is hinting at something that could be clarified in a more explicit way.
Which is that multiple calls to require('foo') will not cause the module code to be
executed multiple times unless it is removed from the module cache.

@Fishrock123
Copy link
Contributor

It could potentially be clarified that this will not happen under default circumstances. Once you modify the require cache all bets are off.

@@ -200,7 +200,7 @@ Modules are cached after the first time they are loaded. This means
(among other things) that every call to `require('foo')` will get
exactly the same object returned, if it would resolve to the same file.

Multiple calls to `require('foo')` may not cause the module code to be
Multiple calls to `require('foo')` will not cause the module code to be
Copy link
Member

Choose a reason for hiding this comment

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

It’s “may” because someone could have deleted it from require.cache - i think “will” is incorrect.

Copy link
Contributor Author

@mikemaccana mikemaccana left a comment

Choose a reason for hiding this comment

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

Updated as requested

Copy link
Contributor Author

@mikemaccana mikemaccana left a comment

Choose a reason for hiding this comment

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

Typo.

@mikemaccana
Copy link
Contributor Author

Updated per @Fishrock123 - now it's more specific:

By default (provided the require.cache is not modified), multiple calls to executed multiple times. This is an important feature. With it, require('foo') will not cause the module code to be executed multiple times.

executed multiple times. This is an important feature. With it,
"partially done" objects can be returned, thus allowing transitive
dependencies to be loaded even when they would cause cycles.
By default (provided the `require.cache` is not modified), multiple calls to
Copy link
Member

Choose a reason for hiding this comment

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

Optional nit: Get rid of By default and the parentheses:

Provided `require.cache` is not modified, multiple calls to

I'm fine with it the way it is but I think that change makes it a tiny bit more clear.

By default (provided the `require.cache` is not modified), multiple calls to
`require('foo')` will not cause the module code to be executed multiple times.

This is an important feature. With it, "partially done" objects can be returned,
Copy link
Contributor

Choose a reason for hiding this comment

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

This line has trailing space and exceeds the limit of 80 characters producing linter issue.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

LGTM with @Trott nit.

@trivikr trivikr removed the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Sep 30, 2018
Copy link
Member

@trivikr trivikr left a comment

Choose a reason for hiding this comment

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

LGTM.
Removing author ready label as there are some outstanding comments

@Trott Trott added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Sep 30, 2018
@Trott
Copy link
Member

Trott commented Sep 30, 2018

Since the comments were rather minor (remove a space here, optionally change wording there), I did them rather than waiting for OP to do it and have restored the author ready label.

@mikemaccana
Copy link
Contributor Author

mikemaccana commented Sep 30, 2018 via email

@trivikr
Copy link
Member

trivikr commented Oct 1, 2018

@trivikr
Copy link
Member

trivikr commented Oct 1, 2018

Landed in a82ac6e

@trivikr trivikr closed this Oct 1, 2018
trivikr pushed a commit that referenced this pull request Oct 1, 2018
This vagueness of 'may' has caused a great deal of confusion.
See https://stackoverflow.com/questions/8887318

PR-URL: #23143
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: John-David Dalton <john.david.dalton@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
targos pushed a commit that referenced this pull request Oct 3, 2018
This vagueness of 'may' has caused a great deal of confusion.
See https://stackoverflow.com/questions/8887318

PR-URL: #23143
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: John-David Dalton <john.david.dalton@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. doc Issues and PRs related to the documentations. module Issues and PRs related to the module subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.