3

Usually I have the same structure of my functions:

(defn func-name
  ([] (some actions))
  ([ar] (some actions))
  ([ar aar] (some actions)))

And usually only one of this variant is public. But as You can see from my entry - all my function is public because of using defn instead of defn-. But defn- hide all function, including all overloaded.

Is there any way to 'hide' only part of overloaded function?

For example, I want to hide an func-name with arity of one and two arguments.

Ofcorse I can hide overloaded function inside one defn like this:

(defn awesome[]
  (let [func (fn some-func ([] (some actions))
               ([ar] (some actions)))]
    (func)))

But I think it's a little bit messy and I'm sure there have to be a way to solve it.

Thanks!

4

1 回答 1

3

据我所知,这种可见性是由:privatevar's 中的标志定义的meta。所以这两个表达式是相等的:

(defn ^:private foo [] "bar")
(defn- foo [] "bar")

所以我认为你只能控制一个整体的可见性var

我可以建议为公共和私人空间使用不同的函数名称。即func-name公共和func-name-私人。

于 2015-12-18T23:06:13.663 回答