Re: Why does "clojure.core/run!" end in an exclamation mark?
doseq is a macro that accepts comprehension clauses like "for", so doseq is a straight translation of for that is eager (but still uses seqs internally) and swallows its body's results. run! is like more like (doall (map f xs)), except it swallows results and uses "reduce" for speed and efficiency (no seq allocations). In general, if I am side-effecting at the end of a ->> threading macro pipeline, I use run!. If I care about speed I use run! Otherwise I use doseq because it looks and feels more "statement-y" to me. On Saturday, December 24, 2016 at 12:16:50 PM UTC-6, Shantanu Kumar wrote: > > I'm curious about `clojure.core/run!` too, but my question is whether it > is meant to be a `reduce` variant of `clojure.core/doseq` or it has some > other purpose. > > Shantanu > > On Saturday, 24 December 2016 21:37:11 UTC+5:30, James Reeves wrote: >> >> My understanding is that the convention used in clojure.core is to put an >> exclamation mark onto the end of any function unsafe to run in a >> transaction. >> >> Does the reasoning differ for "run!" or is it assumed that the function >> passed to "run!" will not usually be idempotent? >> >> - 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.
Re: Why does "clojure.core/run!" end in an exclamation mark?
On 25 December 2016 at 10:30, Paulus Esterhazywrote: > 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.
Re: Why does "clojure.core/run!" end in an exclamation mark?
I'm curious about `clojure.core/run!` too, but my question is whether it is meant to be a `reduce` variant of `clojure.core/doseq` or it has some other purpose. Shantanu On Saturday, 24 December 2016 21:37:11 UTC+5:30, James Reeves wrote: > > My understanding is that the convention used in clojure.core is to put an > exclamation mark onto the end of any function unsafe to run in a > transaction. > > Does the reasoning differ for "run!" or is it assumed that the function > passed to "run!" will not usually be idempotent? > > - 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.
Why does "clojure.core/run!" end in an exclamation mark?
My understanding is that the convention used in clojure.core is to put an exclamation mark onto the end of any function unsafe to run in a transaction. Does the reasoning differ for "run!" or is it assumed that the function passed to "run!" will not usually be idempotent? - 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.