Hi, On Feb 22, 2010, at 2:20 AM, Meikel Brandmeyer wrote:
> First some fixes: > > (defmacro #^{:private true} use-private > [ns sym] > `(def ~(with-meta sym {:private true}) @(ns-resolve '~ns '~sym))) Awesome! >> This, however, doesn't work. The first ~sym macroexpands to (quote sym), >> which cannot be passed as a name to def. An exception is thrown saying that >> the first argument must be a symbol, and this is because, I assume, that the >> quote form is a form. So... > > This only expands to (quote sym) because you put in (quote sym). You > haven't shown the invocation of your macro, but that's most likely the > cause. You're absolutely right. I use 'ns and 'sym because that's what all of the ns- functions use. I realize now that this is a macro, not a fn... :) I would like to make the fact that this is a macro transparent, so that it only accepts symbol arguments. The caller shouldn't have to know that this is a macro. >> Is there a better way the community has found to test private functions? >> Is there a way to reference private functions from a test- namespace? Is >> there some proposal floating around to allow this? >> Is there a better approach than my ghetto macro, outside of extending the >> core language and libraries? >> In my ghetto macro, how do I get the sym arg to macroexpand to just the sym >> and not a quote form? > > Use @#'foo.bar/private-fn. Or... Thanks! > My approach to this is to get rid of private function entirely. > Everything is public. Put "private" functions of the namespace foo.bar > in the namespace foo.bar.internal. Then simply :use the internal > namespace in foo.bar. Make it clear that users using foo.bar.internal > have to face eternal doom in the hottest corners of hell. That's what I figured, since the few library implementations I've read seem to do that. I assume there's a way to remove these namespaces from generated docs, so there's at least some obfuscation? Thanks, Johnny -- 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