Hacker News new | past | comments | ask | show | jobs | submit login

Not a downvoter, but I believe "Without side effects you couldn't do anything" means that any interesting program ultimately has a side effect. The rocket is launched, the form is printed, pi is displayed on the monitor, etc.



Isn't that an effect, not neccesarily a side effect?


"Function with side effect" is a term of art in functional programming. It's a function which (like all other functions) takes in arguments and puts out arguments (that's the "effect", if you like). But also, with a "side effect" -- the simplest example being, display something on the monitor.

I.e.,

  (display "hello world")
returns whatever it returns (we throw it away), but also puts that string on the monitor. The latter action is not just computing a function (in the sense of FP) of the inputs.

For more, see http://www.eecs.berkeley.edu/~bh/ssch20/io.html (search for "side effect").




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: