-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider combining macros/functions in one namespace #134
Comments
I agree, and this is how it used to be. The split was done for ClojureScript compatibility. |
I have found potemkin's So, potentially you could keep the separate implementation namespaces for Clojurescript users, but Clojure users could access the vars through a com.rpl.specter.core namespace. Main downside of using potemkin is that it contains a lot of other stuff irrelevant to this particular use and the other stuff causes it to be somewhat fragile -- tends to break when new versions of Clojure come out until potemkin is updated. I wish Clojure had a built-in solution for something like import-vars. |
Apparently ClojureScript allows a macros namespace to be the same name as a ClojureScript namespace (not sure if this was added recently or not). That means Specter's namespaces can be merged. |
I also discovered this just a couple weeks ago. I think there are some
subtleties to be aware of, because the namespace file is processed once
looking for only macros, and then again looking for all the non-macros. So
if I understand correctly, this means the macro can't depend on a function
in the same namespace. But since you already have the code factored into
two separate namespaces, I would imagine it wouldn't be too hard to meet
the constraints imposed by this two-pass system.
|
Tried doing this today but ran into a major problem. When I put the macros namespace in specter.clj and keep the functions in specter.cljc, only the specter.clj file is loaded when doing a
Doing |
Yeah, I don't think having both a clj and a cljc file for a given namespace is a supported use case. Couldn't you put the macros into |
Great idea, that worked. This is now implemented for 0.13.0. |
The README demonstrates using specter by "using" both the macros and specter namespaces. But some of the names are common enough that I would prefer to "require" them with an alias. The problem: because the README only demonstrates usage with no namespace qualifications, it is not obvious how to remember which parts of the API are functions and which are macros, and therefore it can be hard to recall which namespace to find which thing in. To some extent, macros vs functions are an implementation detail, and I as a user don't necessarily know which way a given thing is implemented.
Consider combining macros/functions into a unified API of all the core public API functions (it's fine if things like transients remain separate, since that is a conceptual classification that is easy to remember, not an implementation-based classification).
Potemkin is a valuable tool for pulling things from separate implementation namespaces into one API namespace for public consumption.
The text was updated successfully, but these errors were encountered: