This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-01-02
Channels
- # beginners (29)
- # boot (65)
- # cider (12)
- # cljs-dev (8)
- # cljsjs (31)
- # clojars (5)
- # clojure (147)
- # clojure-austin (47)
- # clojure-berlin (1)
- # clojure-brasil (7)
- # clojure-russia (5)
- # clojure-spec (18)
- # clojure-uk (18)
- # clojurescript (113)
- # css (2)
- # cursive (7)
- # datascript (5)
- # datomic (2)
- # dirac (4)
- # events (3)
- # funcool (143)
- # hoplon (287)
- # jobs (2)
- # off-topic (4)
- # om (10)
- # om-next (5)
- # onyx (18)
- # protorepl (1)
- # re-frame (93)
- # reagent (34)
- # rum (41)
- # test-check (51)
- # untangled (15)
- # yada (18)
How does one expose a single namespace for code spread across several files? eg, in python:
types/__init__.py # import public stuff from nested modules, and expose with __all__
types/integer.py
types/boolean.py
types/string.py
…etc...
So I just want a core.types
namespace as part of the public API for my package, not core.types.integer
and so on....
Is there an idiomatic way to do this in Clojure?there isn't an idiomatic way, since the idiom is to keep one file per namespace, but you can always call the (in-ns ...) function from any file, which I believe will let you then def your vars, etc in the namespace you want.
might want to try it out... it's not something i've ever tried to do or have seen anyone do... so not entirely sure if it works.
You can also use (load "file-name-without-extension")
at the end of your files + (in-ns 'namespace)
. Works pretty well for me.
e.g. fancy-pants.clj:
(ns fancy.pants)
(defonce something { :hi "hi" })
(load "fancy-feast")
fancy-feast.clj:
(in-ns 'fancy.pants)
(defonce something-else {:food "sogood"})
@notanon it is probably better not to do this, if it is unusual in clojure, right? it seems to me it must get really unwieldy with large codebases, having a 1-1 relation between namespaces and files? @jgh got it, thanks.
@pwalsh I definitely wouldn't do it. you'll probably find that clojure is so succinct that it would take an absolute boat load of functionality to overwhelm a namespace. but you can always create a wrapper namespace if you're really worried about it. create a bunch of small namespaces like mystuff.mystuff-a, mystuff-b mystuff-c and then create the mystuff namespace and require in mystuff-a/b/c/etc and then expose only the 'publics' you wish to expose. i still find it hard to picture a use case to justify any these options though 🙂 i'd recommend sticking to 1 file/1 namespace, and if you feel it has gotten overwhelming, post the code and let us look at the real example. best of luck.
I can get the KEYS and single data. My question, what is the shorter/ nicer version to get the right format for friend authentication?
so for each element in the "results: " vector above, you need to call singleuser query and get back the details
if i am understanding what you want, then you'd need to map call-to-single over a results-of-all-users call
Is there a way I can concatenate an earlier value in a hashmap in a later one? For example, something like { :baseUrl "
yeah i don’t think you can just reference it like that
you could wrap it in a let binding
(let [base-url “http://test/”] {:base-url base-url :abs-url (str base-url “test2”)})
another option is to pass it through assoc
(-> {:base-url “http://test”} (fn [hash-map] (assoc hash-map :abs-url (str (:base-url hash-map) “test2”))))