This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-09-30
Channels
- # announcements (41)
- # aws (2)
- # aws-lambda (1)
- # babashka (51)
- # babashka-sci-dev (15)
- # beginners (56)
- # calva (15)
- # cider (8)
- # clojars (6)
- # clojure (107)
- # clojure-dev (6)
- # clojure-europe (33)
- # clojure-france (3)
- # clojure-nl (4)
- # clojure-sg (2)
- # clojure-uk (8)
- # clojurescript (16)
- # cursive (11)
- # data-oriented-programming (1)
- # datomic (4)
- # events (11)
- # fulcro (15)
- # graphql (6)
- # helix (17)
- # holy-lambda (1)
- # improve-getting-started (14)
- # integrant (39)
- # jobs (14)
- # lsp (36)
- # malli (3)
- # nrepl (8)
- # off-topic (26)
- # other-languages (1)
- # polylith (21)
- # portal (7)
- # practicalli (17)
- # re-frame (7)
- # react (4)
- # reitit (1)
- # remote-jobs (6)
- # sci (1)
- # shadow-cljs (45)
- # spacemacs (12)
- # tools-deps (5)
- # xtdb (26)
Moved https://github.com/borkdude/sci/issues/378 an inch (or maybe just a centimeter!) forward, confirming that the priority order of searching for a protocol method implementation is wrong.
I was hoping to start leveraging extend-with-metadata for data. We’re using a Stuart Sierra component-like system to express resource dependencies, and we don’t really need records for the data the resources: maps would be fine . (But that’s what we’re doing now as that’s what we to do given the current limitation.)
@U0EHU1800 So the issue is that the metadata is prioritized while it shouldn't right?
(foo (with-meta (->Dude) {`foo (fn [this] :meta)}))
This should not return :meta
if the record implements the protocol already right?I see that's a different case that doesn't work. Here SCI incorrectly prioritizes the metadata it seems
I think what you're seeing above is that the metadata about the record implementing the protocol got replaced by the with-meta
. If you use vary-meta
to just update the existing metadata, you'll see that it prioritizes the direct implementation over the meta-data implementation.
(def fooer-vary-meta (vary-meta (->Fooer) assoc `foo (fn [_] {:impl :with-meta})))
(foo fooer-vary-meta);; => {:impl :defrecord}
(meta fooer-vary-meta)
;; => {:sci.impl/record true,
;; :type user/Fooer,
;; user/foo
;; #object[sci.impl.fns$fun$arity_1__1208 0x27dc294a "sci.impl.fns$fun$arity_1__1208@27dc294a"]}
(def fooer-with-meta (with-meta (->Fooer) {`foo (fn [_] {:impl :with-meta})}))
(foo fooer-with-meta);; => {:impl :extend-protocol}
(meta fooer-with-meta)
;; => {user/foo
;; #object[sci.impl.fns$fun$arity_1__1208 0x437834e1 "sci.impl.fns$fun$arity_1__1208@437834e1"]}