I think the 0-arity versions of these functions have been added during the work on reducers, to allow them to serve as reducing functions. Without going into reducers (or transducers, for that matter!), they place a number of requirements on reducing functions, among which that they should be associative and have a neutral element, and that they return that neutral element when called with no argument.
So + and * have been extended with a zero-arity version because they are associative and have a neutral element, while - and / have not, because altough they have a (right-hand only) neutral element, they are not associative. (And I'm pretty sure it does not really count as a neutral element if it only works on one side, though my algebra skills are a bit rusted there.) On Tuesday, 10 February 2015, J David Eisenberg <[email protected]> wrote: > The following work fine in the ClojureScript REPL: > > (+) > (*) > > and yield 0 and 1 as results. However, these: > > (-) > (/) > > throw exceptions, the base cause being wrong number of arguments passed. > > Why this disparity? Not that I'm going to be writing code like that, as it > is terrible programming practice. It's just a matter of "enquiring minds > want to know." > > -- > Note that posts from new members are moderated - please be patient with > your first post. > --- > You received this message because you are subscribed to the Google Groups > "ClojureScript" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] <javascript:;>. > To post to this group, send email to [email protected] > <javascript:;>. > Visit this group at http://groups.google.com/group/clojurescript. > -- Note that posts from new members are moderated - please be patient with your first post. --- You received this message because you are subscribed to the Google Groups "ClojureScript" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/clojurescript.
