Re: Does `side-effect-free` have to apply to sub-functions too?
Stefan Monnier via Users list for the GNU Emacs text editor <[email protected]>
| Newsgroups | gmane.emacs.help |
|---|---|
| Message-ID | <[email protected]> |
> I am wondering whether a function being free of side effects applies to > functions that use `seq-elt`, which could run an unknown method > implementation for an unknown custom type. If it is possible for the > unknown method implementation to have side effects, then is the function > which unknowingly triggers the unknown implementation considered to not > be side-effect free? Marking it as side-effect-free should be taken as a declaration of intent. I.e. if it turns out that in some cases it does have a side effect, then we have a bug. At that point we can look at the details to determine if the bug is in the declaration or in the implementation. > In other words, before marking a function as `side-effect-free`, must > one check the function's sub-functions, and those sub-functions' > sub-sub-functions, and so on, all the way down, even if the function > itself does not intentionally have a side effect? It's simply impossible to "check the function's sub-functions ..." (consider `advice-add` if you're not convinced). === Stefan