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

I think it would be more valuable to actually define the ! convention, than propose yet another one for side effects.


Not sure why he says the ! is not for side effects, i've always encountered it used in that way (and changing the state is also a side effect)


I can't think off the top of my head where it's been abused. I do know that one question that often arises is "should I end with an ! if my method logs?" I've had this conversation on IRC with the author. The consensus was to only apply such a name when a global was involved.

The trick is trying to telegraph to the consumer that your function logs. They need to know because it brings with it dependencies both by way of code and runtime requirements. Logging may fail for a variety of reasons. These would throw any consumer off. They have to plan for it.


The clojure convention for ! is to use it for functions that are not safe to execute in a transaction - that is, functions that cannot safely be retried. That means that most side-effecting functions should end in !, but not necessarily all: it is possible to have side-effecting yet transaction-safe functions as long as the side-effects are idempotent.

When will functions be called in a transaction? STM ref, agent and atom updates.




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

Search: