Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

A “side-effect” in this case is the ability for a function you call to do something “outside” of itself. For example, to change the value of a global variable.

It’s generally considered best practice (in the functional programming community at least) to write “pure” functions (that is, functions without side effects) because it’s much easier to reason about what they are doing.

So good news, subshells can _only_ be pure (the only way to get anything back from them is if they write some string to stdout), but sometimes you do actually want to have some side-effects (imagine a function that reads a config file and then wants to set some of the global variables to the values found there).

Well, bad luck. If you use the subshell syntax you literally can’t do that.



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

Search: