This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-11-13
Channels
- # announcements (1)
- # babashka (21)
- # beginners (39)
- # calva (10)
- # cljsrn (4)
- # clojure (133)
- # clojure-europe (27)
- # clojure-nl (2)
- # clojure-uk (1)
- # clojurescript (10)
- # code-reviews (19)
- # cursive (1)
- # data-science (1)
- # deps-new (2)
- # emacs (8)
- # events (4)
- # exercism (3)
- # fulcro (14)
- # introduce-yourself (2)
- # lsp (7)
- # malli (2)
- # meander (2)
- # missionary (6)
- # pathom (6)
- # pedestal (1)
- # releases (1)
- # remote-jobs (1)
- # sci (18)
- # tools-build (2)
@seancorfield I remember some time ago we talked about the best way to mix components which we would want to implement protocols without a lot of boilerplate. My idea was to work with a component which still satisfied some framework protocols (like reitit's router) without change to the semantics. Came up with this, what do you think? https://gist.github.com/bsless/db15d79f4ec9acac92e18db8fba27135
Should the second opts
in line 17 be opts+specs
? Otherwise that argument doesn't seem to be used?
My personal feeling is that this is too much "magic" and it makes it very hard to just look at code and figure out what it actually does. I mean, how often do you really need a record to implement an arbitrary list of protocols -- and what are those implementations actually doing in this case?
OK, so macroexpand-1
seems to indicate this is just adding delegation of those protocols via the first field of the record -- but I don't understand why. What's the motivation for this (the discussion was some time ago)?
Also, if we're talking about Component, we're tending to implement Lifecycle
via metadata a lot these days at work -- not records.
(although, unfortunately, IKVReduce doesn't support extension via metadata)
Let's say I want to bring in something like a malli registry or reitit router as a component
I can extend them via metadata, or I can just stick them as a "state" in a component and delegate their methods to them
They just have a list of "here are all the protocols (and interfaces?) I delegate to"
When I settle on how I want to do interfaces, too, I get a convenient way of delegating over java objects, too, which I can't extend via metadata
But take next.jdbc as another example, I can just specify a list of protocols on a record and it can "automagically" participate in them
What next.jdbc
protocols would you want to delegate to? That's not a compelling argument to me. next.jdbc.connection/component
already exists for making a Component that wraps a pooled datasource. What other things would you want to do?
This is just not a problem I've run into, so maybe it's specific to a couple of the libraries you're using that sort of expect you to implement a bunch of protocols with boilerplate?
I can give several examples
• with next.jdbc I might not want to use the component
wrapper, just due to preference
• https://github.com/metosin/reitit/blob/master/modules/reitit-core/src/reitit/core.cljc#L38
• https://github.com/metosin/malli/blob/master/src/malli/registry.cljc#L8