-
Notifications
You must be signed in to change notification settings - Fork 3
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
The meaning of side effects
馃
#2
Comments
I guess maybe we could remove that section, as explaining side-effect is probably not in the scope if the spec? Otherwise, feel free to send PRs to rewrite them into what make send to you |
AFAIK, to Terser and uglifyjs, the pure annotation also asserts that the function will not be throwing an error. When minifying, you shouldn't remove code that throws. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think the current definition of
side effects
is incorrect:I believe the above description suits
pure
more thanside effects
. A function can have no side effects even if it reads external data such as files or variables from outer scopes. On the other hand, it would cause side effects if the function wrote to a file or modified variable from outer scopes (note that modifying variables created in its own scope still doesn't count as having side effects).Although, I understand that even reading a JS variable may cause a side effect in certain situations (for example, when using a proxy). Network requests, even GET requests, may cause side effects too (eg, a page view counter that increases for each visit). Finally, reading files may cause the OS to update some file descriptors or whatever... But still, is it safe to assume that most of the time, those operations shouldn't count as side effects?
The text was updated successfully, but these errors were encountered: