This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-08-13
Channels
- # aleph (6)
- # architecture (29)
- # beginners (175)
- # cider (22)
- # clara (5)
- # cljdoc (5)
- # cljs-dev (28)
- # cljsrn (6)
- # clojure (62)
- # clojure-finland (7)
- # clojure-italy (7)
- # clojure-nl (2)
- # clojure-spec (23)
- # clojure-uk (194)
- # clojurescript (90)
- # core-async (2)
- # cursive (23)
- # datomic (41)
- # defnpodcast (2)
- # editors (4)
- # emacs (1)
- # figwheel-main (41)
- # fulcro (53)
- # hoplon (15)
- # hyperfiddle (4)
- # immutant (1)
- # jobs (7)
- # jobs-discuss (103)
- # lein-figwheel (9)
- # off-topic (34)
- # onyx (3)
- # parinfer (1)
- # portkey (1)
- # re-frame (7)
- # reagent (2)
- # remote-jobs (2)
- # rum (1)
- # shadow-cljs (148)
- # sql (54)
- # tools-deps (3)
- # vim (7)
so I’ve got a few namespaces - each one responsible for managing the contents of particular type of map. Is there a convention in clojure for what to call your “constructer” method? Do you name it after the type of the type of object you’re going to create (already in the namespace?) or use a word like create
or construct
?
@triss I think this is a better discussion for #clojure , but I try and elide create
or make
whenever possible
I see what you’re saying though. If i had a particular namespace, like my-app.job
and in there were all functions that work on the job
entity type, then I would probably just have a create
fn
it’s probably better to hide the fact that all you’re doing is s/conform
in case you ever want to do more?
Is it necessary to forward-declare specs that are referenced from other specs in a case such as mutually recursive specs? Contrived example:
(s/def ::a
(s/map-of keyword? (s/or :b ::b :str string?))
(s/def ::b
(s/map-of keyword? ::a))
I believe, at least in some circumstances, that the forward-use of a spec isn’t resolved until later anyways, so the forward declaration isn’t needed (maybe I’m wrong)
and looking at how the references are used in a various impl’s I checked in clojure.spec.alpha
it seemed like it was ok
but I haven’t seen any direct discussions on it really. I’ve seen at least one posts in the wild that did something like
;; Forward-declaration, replaced later
(s/def ::b any?)
(s/def ::a
(s/map-of keyword? (s/or :b ::b :str string?))
(s/def ::b
(s/map-of keyword? ::a))
but that doesn’t seem necessary