Fork me on GitHub
Clément Ronzon00:03:47

Hey gals and guys, Is there a library out there that would provide this kind of switch control (same behavior as a checkbox)?


If you're using React: I'm sure there are many more other libraries that provide such an input.

Clément Ronzon14:03:16

Thank you guys, I'll look into that!

Joe Littlejohn17:03:07

I’m doing some work that involves introspection on ClojureScript constructs (vars, namespaces, etc). I’ve noticed that namespace docstrings do not appear to be available in ClojureScript-land in any way. The Namespace record includes a name and an internal ns object containing public vars, but there is no doc. Vars do have docs available to ClojureScript e.g. (-> myvar meta :doc). Anyone got any thoughts about why this is? Or maybe someone has a way to access these docstrings that I’m missing? I guess they’re simply not there because namespace docstrings are not expected to be needed by the deployed application and are expected to only be relevant during development or at the REPL. Would a PR to make these docstrings available be reasonable?


@joelittlejohn Clojure and ClojureScript are different in that CLJS does not reify vars and namespaces at runtime in your deployed application.


this information instead lives in the ClojureScript compiler


your intuition is correct in that the reason for this is to ensure that your app is slim and fast; emitting JavaScript code that added all of the namespace, var machinery and metadata would be at the least very costly in bundle size


the var macro is an explicit mark that reads the var metadata at compile time and emits it into your code


are you analyzing code on disk, or trying to build a live CLJS application that introspects itself?

Joe Littlejohn17:03:20

More the latter. I want to introspect on some cljs namespaces in my cljs app. It’s interesting that the var metadata is emitted but not the namespace metadata. So I can use ns-publics to get var info (and all metadata, including :doc), and I can use find-ns to get namespace info, it’s just that no doc field is present.

Joe Littlejohn17:03:19

I implemented a hack by creating my own macro to look up ns docstrings, and when the macro is compiled it emits all the relevant docstrings into its own source so they can be looked up later.


it looks like find-ns is bootstrap only:


so it's quite different than var and ns-publics which are macros that emit data from the analyzer


I think your approach is correct: create a macro that looks up the ns info at compile time and emit it

👌 3
Joe Littlejohn17:03:36

I suppose my next question would be: could we have a function, e.g. ns-meta that does exactly the same thing? (just like ns-publics, ns-imports, ns-interns)

Joe Littlejohn17:03:18

Well, I suppose we’re unlikely to start adding new cljs-specific introspection functions to the core for this.


yeah it might worth asking in #cljs-dev what the best way to do this is

👍 3