Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

docs(guide/Filters): Fix incorrect wording #15173

Closed
wants to merge 1 commit into from
Closed

docs(guide/Filters): Fix incorrect wording #15173

wants to merge 1 commit into from

Conversation

3noch
Copy link
Contributor

@3noch 3noch commented Sep 21, 2016

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.

@googlebot
Copy link

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. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

1 similar comment
@googlebot
Copy link

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. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

@googlebot
Copy link

CLAs look good, thanks!

1 similar comment
@googlebot
Copy link

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.
Copy link
Member

@gkalpak gkalpak Sep 22, 2016

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).

Copy link
Contributor Author

@3noch 3noch Sep 22, 2016

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Member

@gkalpak gkalpak Sep 23, 2016

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 of stateless 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.

Copy link
Contributor Author

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.

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 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.
@gkalpak
Copy link
Member

gkalpak commented Sep 25, 2016

LGTM

@gkalpak gkalpak closed this in f604470 Sep 25, 2016
gkalpak pushed a commit that referenced this pull request Sep 25, 2016
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
@3noch 3noch deleted the patch-1 branch September 26, 2016 02:12
petebacondarwin pushed a commit to petebacondarwin/angular.js that referenced this pull request Nov 21, 2016
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
petebacondarwin pushed a commit to petebacondarwin/angular.js that referenced this pull request Nov 21, 2016
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
petebacondarwin pushed a commit to petebacondarwin/angular.js that referenced this pull request Nov 21, 2016
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
petebacondarwin pushed a commit to petebacondarwin/angular.js that referenced this pull request Nov 21, 2016
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
petebacondarwin pushed a commit to petebacondarwin/angular.js that referenced this pull request Nov 21, 2016
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
petebacondarwin pushed a commit that referenced this pull request Nov 23, 2016
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
petebacondarwin pushed a commit that referenced this pull request Nov 24, 2016
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
ellimist pushed a commit to ellimist/angular.js that referenced this pull request Mar 15, 2017
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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants