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!

Roman Makhlin
  • 973
  • 1
  • 11
  • 27

1 Answers1

3

As I know this visibility is defined by :private flag in var's meta. So this two expressions are equal:

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

So I think you can control a visibility only of a whole var.

I can suggest to use different function names for public and private spaces. I.e func-name for public one and func-name- for private.

fl00r
  • 82,987
  • 33
  • 217
  • 237
  • It doesn't work - the function in that way I did called fine. May be I used meto info not in a right way? Look at my UPD1. – Roman Makhlin Dec 18 '15 at 23:19
  • 1
    You didn't get me right :). My point was that you *can't* do it. Not adding meta to your expressions – fl00r Dec 18 '15 at 23:26