-
Notifications
You must be signed in to change notification settings - Fork 27.4k
docs(guide/Filters): Fix incorrect wording #15173
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
1 similar comment
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
CLAs look good, thanks! |
1 similar comment
CLAs look good, thanks! |
@@ -109,7 +109,7 @@ as the first argument. Any filter arguments are passed in as additional argument | |||
function. | |||
|
|||
The filter function should be a [pure function](http://en.wikipedia.org/wiki/Pure_function), which | |||
means that it should be stateless and idempotent, and not rely for example on other Angular services. | |||
means that it should be deterministic and not rely, for example, on other Angular services. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why remove idempotent
? It is a very important characteristic and is not synonym to deterministic.
Also, "stateless" (even if not 100% accurate) is important (and again not covered by deterministic).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idempotent
is not actually correct for filters. Check out the commit message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deterministic
actually does cover the idea of stateless
since all stateless functions are inherently deterministic. However, it's also quite possible to have stateful functions that are also deterministic as long as the state is entirely self-contained. This is the reason I changed it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also note that in the context, this is giving explanation of "pure function" in the sentence. Pure functions are most certainly not idempotent by necessity (f(x) = x + 1
is pure but not idempotent), and they can even be stateful in careful cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idempotent is not actually correct for filters.
Here, it is used in the broader, "computer science" meaning:
"In computer science, the term idempotent is used more comprehensively to describe an operation that will produce the same results if executed once or multiple times."
But I agree it can be confusing, given the stricter mathematical (and pure functional programming) meanings.
deterministic
actually does cover the idea ofstateless
since all stateless functions are inherently deterministic.
This is not necessarily true (depending on the strictness of your definition). Basically, stateless
isn't accurate either.
Since we already have a link to formal definition of "pure function", why don't we keep it simple here and change it to something like:
The filter function should be a [pure function](http://en.wikipedia.org/wiki/Pure_function), which
-means that it should be stateless and idempotent, and not rely for example on other Angular services.
+means that it should always return the same result given the same input arguments and should not affect
+external state, for example, other Angular services.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent. I can live with that. I'll rework the commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
I don't think "Idempotence" is a property that filters need to fulfill: https://en.wikipedia.org/wiki/Idempotence. Idempotence means that `f(f(x)) == f(x)`, i.e. that applying a filter to the result of itself gives the same value as only applying it once. Many common filters are not idempotent. For example, applying reverse twice is not the same as applying it once.
LGTM |
Improve the explanation of what a "pure function" is in simple words. The previous explanation could be confusing, especially since the term "idempotent" (here used in it's broader "Computer Science" meaning) is overloaded and has much stricter semantics in Mathematics or pure Functional Programming. Closes #15173
Improve the explanation of what a "pure function" is in simple words. The previous explanation could be confusing, especially since the term "idempotent" (here used in it's broader "Computer Science" meaning) is overloaded and has much stricter semantics in Mathematics or pure Functional Programming. Closes angular#15173
Improve the explanation of what a "pure function" is in simple words. The previous explanation could be confusing, especially since the term "idempotent" (here used in it's broader "Computer Science" meaning) is overloaded and has much stricter semantics in Mathematics or pure Functional Programming. Closes angular#15173
Improve the explanation of what a "pure function" is in simple words. The previous explanation could be confusing, especially since the term "idempotent" (here used in it's broader "Computer Science" meaning) is overloaded and has much stricter semantics in Mathematics or pure Functional Programming. Closes angular#15173
Improve the explanation of what a "pure function" is in simple words. The previous explanation could be confusing, especially since the term "idempotent" (here used in it's broader "Computer Science" meaning) is overloaded and has much stricter semantics in Mathematics or pure Functional Programming. Closes angular#15173
Improve the explanation of what a "pure function" is in simple words. The previous explanation could be confusing, especially since the term "idempotent" (here used in it's broader "Computer Science" meaning) is overloaded and has much stricter semantics in Mathematics or pure Functional Programming. Closes angular#15173
Improve the explanation of what a "pure function" is in simple words. The previous explanation could be confusing, especially since the term "idempotent" (here used in it's broader "Computer Science" meaning) is overloaded and has much stricter semantics in Mathematics or pure Functional Programming. Closes #15173
Improve the explanation of what a "pure function" is in simple words. The previous explanation could be confusing, especially since the term "idempotent" (here used in it's broader "Computer Science" meaning) is overloaded and has much stricter semantics in Mathematics or pure Functional Programming. Closes #15173
Improve the explanation of what a "pure function" is in simple words. The previous explanation could be confusing, especially since the term "idempotent" (here used in it's broader "Computer Science" meaning) is overloaded and has much stricter semantics in Mathematics or pure Functional Programming. Closes angular#15173
What kind of change does this PR introduce? Docs
What is the current behavior? Incorrect wording
What is the new behavior (if this is a feature change)? Correct wording
Does this PR introduce a breaking change? No
Please check if the PR fulfills these requirements
Other information:
I don't think "Idempotence" is a property that filters need to fulfill: https://en.wikipedia.org/wiki/Idempotence. Idempotence means that
f(f(x)) == f(x)
, i.e. that applying a filter to the result of itself gives the same value as only applying it once. Many common filters are not idempotent. For example, applying reverse twice is not the same as applying it once.