This is the
talk page for discussing improvements to the
Side effect (computer science) article. This is not a forum for general discussion of the article's subject. |
Article policies
|
Find sources: Google ( books · news · scholar · free images · WP refs) · FENS · JSTOR · TWL |
This article is rated C-class on Wikipedia's
content assessment scale. It is of interest to the following WikiProjects: | |||||||||||||||||||||||||||||||
|
In the future, this article should live at side effect (computer science)...
I was thinking; are functions without side-effects per definition idempotent? If so; would it be worth mentioning idempotence in this article? -- EdSchouten 14:14, 18 March 2006 (UTC)
I think side effects are not just state, they are also I/O. More generally, any effect besides returning a value is a side-effect. Ideogram 19:27, 28 May 2006 (UTC)
This article should not concentrate on functions; the concept extends to the evaluation of any expression. For instance, in C, the expression "x++" is side-effecting, as is the expression "getc(stdin)". — brighterorange ( talk) 17:17, 16 June 2006 (UTC)
the article states that, in imperative programming, side effects make program work, however, if I'm not wrong, imperative programs can (or must) perfectly work without any side effects at all, by using just explicit asignement sentences ¿ isn't it ?
Is looping forever/diverging a side effect? This article states that only changes in state can be side effects, but I've heard others say (possibly mistakenly) that looping forever/divering is a side effect.
Also, do the evaluations of function/operator arguments caused by call-by-value evaluation strategies count as side effects? What if the evaluation of an argument loops forever?
indil ( talk) 23:19, 16 December 2008 (UTC)
I removed the sentence: "Safe operations are also idempotent, although the reverse is not necessarily true" since it's not true.
There seems to be some confusion between side-effect-free and idempotent. As described on idempotent a function f is idempotent if forall x: f(x) = f(f(x)). An example of such an idempotent function is round, e.g. round(2.233)=2=round(round(2.233)).
This doesn't have anything to do with the round function being side-effect-free. E.g. if the round function increased a global counter each time it was called, then it would still be idempotent but not side-effect-free. A function like f(x):=x+1 is not idempotent but it is side-effect-free.
So side-effect-free <=> idempotent doesn't hold in any direction. Teglsbo ( talk) 11:46, 23 January 2009 (UTC)
I've narrowed the focus of the opening considerably. The article is still a bit of a mess because 'side effect' is not really a technical term (though it's definitely a popular one). In the definition I have tried to make things more precise by using the well-defined notion of an effect. The original author seems to have conflated this idea with another idea (side effect) meaning perhaps 'effect that was not manifest in the source code' or 'effect I didn't want'. A better article would distinguish these two ideas, but I don't know how. Norman Ramsey ( talk) 02:57, 20 April 2009 (UTC)
The stuff about CPUs and pipelines, while interesting, seems superfluous to an article on side effects. And in 2009, pipelined machines are very old news, and pipeline bubbles are not interesting. I think the article would be stronger and more focused if that paragraph were removed. What do others think? —Preceding unsigned comment added by Norman Ramsey ( talk • contribs) 03:06, 20 April 2009 (UTC)
Past history? Will shorten to history unless there are objections. —Preceding unsigned comment added by 68.155.251.109 ( talk) 10:06, 19 August 2009 (UTC)
Reading the definition in the current article I don't think it's obvious if a side effect free function is always pure.
The current definition is:
"In computer science, a function or expression is said to have a side effect if, in addition to producing a value, it also modifies some state or has an observable interaction with calling functions or the outside world."
Could interaction with the outside world be reading a global variable? The current article mentions "read data" as an example of a side effect.
In the section about Referential transparency a function is said to have referential transparency if it's side effect free and pure.
Pure is defined in a separate article as (my rephrasing): Independent of other inputs than given argument and side effect free.
But this article suggests that a side effect free function must not read data from the outside making pure and side effect free the same thing.
So my question is (which the article should make clear): Is today() from the pure function article side effect free? Teglsbo ( talk) 21:24, 25 February 2010 (UTC)
I've added some examples to demonstrate how side effects work in C++ with the assignment operator. It's somewhat of a rehash of the information found on the operator associativity page (so a link may be all that's required -- delete code if desired), but it's a little more specific to side effects and their gotchas. Glosser.ca ( talk) 16:02, 7 November 2011 (UTC)
Might a method that returns no value, not also have a side effect? Take a method `DrawLine`, for instance, that outputs a line on the screen. If this methods writes something to a log file, wouldn't this be considered as being a side effect?
See also: http://programmers.stackexchange.com/questions/40297/what-is-a-side-effect
O. Jacot-Descombes ( talk) 19:18, 1 January 2015 (UTC)
It is stated that:
xSetter is not idempotent under function composition because xSetter(5) and xSetter(xSetter(5)) set x to different values where return value of xSetter is x; in this example return value is always 5.
However, it seems to me that `xSetter(xSetter(5))` is idempotent, since,
xSetter(xSetter(5)) equals xSetter(5) equals 5
If I'm wrong, I'd still really like to see a better explanation in the article.
Hbogert ( talk) 13:45, 16 May 2016 (UTC)
This is the
talk page for discussing improvements to the
Side effect (computer science) article. This is not a forum for general discussion of the article's subject. |
Article policies
|
Find sources: Google ( books · news · scholar · free images · WP refs) · FENS · JSTOR · TWL |
This article is rated C-class on Wikipedia's
content assessment scale. It is of interest to the following WikiProjects: | |||||||||||||||||||||||||||||||
|
In the future, this article should live at side effect (computer science)...
I was thinking; are functions without side-effects per definition idempotent? If so; would it be worth mentioning idempotence in this article? -- EdSchouten 14:14, 18 March 2006 (UTC)
I think side effects are not just state, they are also I/O. More generally, any effect besides returning a value is a side-effect. Ideogram 19:27, 28 May 2006 (UTC)
This article should not concentrate on functions; the concept extends to the evaluation of any expression. For instance, in C, the expression "x++" is side-effecting, as is the expression "getc(stdin)". — brighterorange ( talk) 17:17, 16 June 2006 (UTC)
the article states that, in imperative programming, side effects make program work, however, if I'm not wrong, imperative programs can (or must) perfectly work without any side effects at all, by using just explicit asignement sentences ¿ isn't it ?
Is looping forever/diverging a side effect? This article states that only changes in state can be side effects, but I've heard others say (possibly mistakenly) that looping forever/divering is a side effect.
Also, do the evaluations of function/operator arguments caused by call-by-value evaluation strategies count as side effects? What if the evaluation of an argument loops forever?
indil ( talk) 23:19, 16 December 2008 (UTC)
I removed the sentence: "Safe operations are also idempotent, although the reverse is not necessarily true" since it's not true.
There seems to be some confusion between side-effect-free and idempotent. As described on idempotent a function f is idempotent if forall x: f(x) = f(f(x)). An example of such an idempotent function is round, e.g. round(2.233)=2=round(round(2.233)).
This doesn't have anything to do with the round function being side-effect-free. E.g. if the round function increased a global counter each time it was called, then it would still be idempotent but not side-effect-free. A function like f(x):=x+1 is not idempotent but it is side-effect-free.
So side-effect-free <=> idempotent doesn't hold in any direction. Teglsbo ( talk) 11:46, 23 January 2009 (UTC)
I've narrowed the focus of the opening considerably. The article is still a bit of a mess because 'side effect' is not really a technical term (though it's definitely a popular one). In the definition I have tried to make things more precise by using the well-defined notion of an effect. The original author seems to have conflated this idea with another idea (side effect) meaning perhaps 'effect that was not manifest in the source code' or 'effect I didn't want'. A better article would distinguish these two ideas, but I don't know how. Norman Ramsey ( talk) 02:57, 20 April 2009 (UTC)
The stuff about CPUs and pipelines, while interesting, seems superfluous to an article on side effects. And in 2009, pipelined machines are very old news, and pipeline bubbles are not interesting. I think the article would be stronger and more focused if that paragraph were removed. What do others think? —Preceding unsigned comment added by Norman Ramsey ( talk • contribs) 03:06, 20 April 2009 (UTC)
Past history? Will shorten to history unless there are objections. —Preceding unsigned comment added by 68.155.251.109 ( talk) 10:06, 19 August 2009 (UTC)
Reading the definition in the current article I don't think it's obvious if a side effect free function is always pure.
The current definition is:
"In computer science, a function or expression is said to have a side effect if, in addition to producing a value, it also modifies some state or has an observable interaction with calling functions or the outside world."
Could interaction with the outside world be reading a global variable? The current article mentions "read data" as an example of a side effect.
In the section about Referential transparency a function is said to have referential transparency if it's side effect free and pure.
Pure is defined in a separate article as (my rephrasing): Independent of other inputs than given argument and side effect free.
But this article suggests that a side effect free function must not read data from the outside making pure and side effect free the same thing.
So my question is (which the article should make clear): Is today() from the pure function article side effect free? Teglsbo ( talk) 21:24, 25 February 2010 (UTC)
I've added some examples to demonstrate how side effects work in C++ with the assignment operator. It's somewhat of a rehash of the information found on the operator associativity page (so a link may be all that's required -- delete code if desired), but it's a little more specific to side effects and their gotchas. Glosser.ca ( talk) 16:02, 7 November 2011 (UTC)
Might a method that returns no value, not also have a side effect? Take a method `DrawLine`, for instance, that outputs a line on the screen. If this methods writes something to a log file, wouldn't this be considered as being a side effect?
See also: http://programmers.stackexchange.com/questions/40297/what-is-a-side-effect
O. Jacot-Descombes ( talk) 19:18, 1 January 2015 (UTC)
It is stated that:
xSetter is not idempotent under function composition because xSetter(5) and xSetter(xSetter(5)) set x to different values where return value of xSetter is x; in this example return value is always 5.
However, it seems to me that `xSetter(xSetter(5))` is idempotent, since,
xSetter(xSetter(5)) equals xSetter(5) equals 5
If I'm wrong, I'd still really like to see a better explanation in the article.
Hbogert ( talk) 13:45, 16 May 2016 (UTC)