Fork me on GitHub
#beginners
<
2015-06-24
>
meow16:06:44

So, I just noticed that there is a defn and defn- but def does not have a matching def-, but there is (def ^:private

akiva16:06:32

Yep. defn is a macro around def which just returns a fn.

meow17:06:15

@akiva: would it be possible to have a macro for def- that just added the :private true metadata?

akiva17:06:03

Sure, you could but why would you want to? Only reason I can see why is to achieve symmetry between the two calls.

meow17:06:16

less typing

meow17:06:51

also just curious why it isn't already there

meow17:06:31

why is defn- more deserving than def-

akiva17:06:05

I think it’s just syntactic sugar. We tend to define functions far more often than we define global private vars.

meow17:06:32

@akiva: True

ska18:06:18

@meow: this was discussed on the mailing list a few times already. Yes, defn- is there, but actually it shouldn't according to today's opinions of the maintainers of clojure.core.

andrew18:06:15

" it pollutes the language core to provide convenience APIs that are combinatorial in nature." ..... "I would rather see defn- removed, than add any more foo- functions. If there are any more function "attributes" we want to tag things with (say, automatically memoized?) that would be 2^N new "convenient" definition forms, in an already-packed clojure.core namespace. And it's not hard at all to (let [foo-const 1] (defn foofn [x] ...) (defn more-foo [y z] ...)), or use ^:private if you really want a private global. "

andrew18:06:44

@meow: see above

meow19:06:06

@andrew: and @ska: cool, thanks. I was just curious if there was some technical reason that I wasn't getting. I completely understand not wanting to pollute a namespace.

andrew21:06:50

does 'every?' stop as soon as it knows it will return false?

andrew22:06:25

@alejandro: thanks. I should be less shy about looking at the source

alejandro23:06:15

@andrew no worries, it helps if your doc viewer embeds a link to the source simple_smile