This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-02-08
Channels
- # announcements (14)
- # babashka (12)
- # beginners (140)
- # calva (2)
- # cider (22)
- # clj-commons (14)
- # clj-kondo (49)
- # cljdoc (34)
- # clojure (92)
- # clojure-europe (41)
- # clojure-france (2)
- # clojure-new-zealand (2)
- # clojure-nl (2)
- # clojure-norway (60)
- # clojure-uk (17)
- # clojured (2)
- # clojurescript (7)
- # community-development (3)
- # conjure (2)
- # cryogen (13)
- # cursive (4)
- # data-oriented-programming (2)
- # datahike (5)
- # datomic (12)
- # defnpodcast (10)
- # events (2)
- # fulcro (20)
- # gratitude (3)
- # honeysql (4)
- # introduce-yourself (3)
- # jobs (10)
- # lsp (58)
- # malli (12)
- # missionary (19)
- # off-topic (8)
- # pathom (18)
- # podcasts (1)
- # polylith (41)
- # releases (1)
- # remote-jobs (3)
- # shadow-cljs (52)
- # spacemacs (1)
- # sql (37)
- # xtdb (19)
Hmm, ok those are some definite upsides. So I've been wondering protocol
or multimethod
, I previously used protocols, the only problem is I need to define behaviour on a per instance basis, which makes me think multimethods are the right way to do this.
I was wondering if I should reach for :extend-via-metadata
instead, that way I could default to a noop if the record in question is missing the key of interest for the function, but otherwise it should work?
As long as your protocol has a default implementation (for Object
) that is a no-op, I think that should work...
@folcon Yeah, it works:
dev=> (defprotocol Basic :extend-via-metadata true (do-it [_]))
Basic
dev=> (extend-protocol Basic Object (do-it [_] (println "Object!")))
nil
dev=> (do-it {:a 1})
Object!
nil
dev=> (do-it (with-meta {:a 1} {`do-it (fn [_] (println "Special!"))}))
Special!
nil
mรฅning
Awesome @seancorfield ๐... I'll have to try that approach and see if it's workable ๐...
I wish I could hear how people read the code they write, it would be much easier to understand
Interesting thought ๐... I wonder if reading aloud the code I write would improve readability, similar to what I sometimes do when blog writing...
although, if you read i
or idx
as Index
then it might not work ๐ I just realized because our frontend is full of buttons that are called btns
I definitely read idx
as index, i
/ j
as index keys I'd recognise, but it would not be reading, more recalling ๐
Ok, I've still not really used datafy
and nav
, I'm starting to work with really messy complex datastructures, is REBL still being used, or has something supplanted it?
EDIT: Trying out https://github.com/djblue/portal/