On 25 December 2016 at 10:30, Paulus Esterhazy <pesterh...@gmail.com> wrote:

> The following fn names in clojure.core contain an exclamation mark:
>
> "vswap!" "vreset!" "set-error-mode!" "set-agent-send-executor!"
> "disj!" "conj!" "pop!" "compare-and-set!" "reset-meta!"
> "set-error-handler!" "set-agent-send-off-executor!" "dissoc!" "assoc!"
> "reset!" "alter-meta!" "persistent!" "run!" "set-validator!" "swap!"
> "volatile!" "io!"
>
> What these functions have in common is that they do something
> side-effectful, i.e. they do something over and above returning a
> value.


Well, yes, but they're also unsafe to run in an STM transaction, except
potentially for run!.

I think that's the convention followed by many in the
> community, although it's not a perfect convention -- there are many
> side-effecting functions in core without exclamation marks (print,
> require, ns-unmap).
>

require and ns-unmap are side-effecting, but idempotent, meaning that
they're safe to run in a transaction.

Functions that reference I/O like print or slurp are of course obviously
unsafe, and in those cases maybe an exclamation mark was considered
redundant.

But I guess the answer is that there's no fixed convention for ending a
function with an exclamation mark. The Clojure Style Guide suggests
exclamation marks should be for functions that are unsafe to use in STM
transactions, and I thought that stemmed from their usage in clojure.core,
but maybe the meaning is much looser than that.

- James

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to