What's a good word for the category "socket" vs "stdin/stdout" and another word for the category "edn"/"json"? The latter I would call format. The first one I would call... channel? don't know!
Use case: I have software communicating either via sockets or stdin/stdout and exchanging messages in edn/json, so I need something like this:
{:??? :socket :format :edn}
Transport?
I came across this word in the nREPL docs but it seems they're using transport to describe the format rather than the socket mechanism
I do think that word is more fitting for the mechanism of transport rather than the format of the messages being transported
Transport is both in nrepl, the serialization mechanism is tied to the communication mechanism
In twisted python, there’s transport (tcp/udp etc) and protocol (http, etc)
@hiredman Right, I guess you could have a nREPL transport edn+http or something
“encoding”?
socket isn't really an encoding I think
I'll go with transport
are there any good hacker-news-esque "startup/programming fusion" slack/discord/chat rooms out there?
nothing like doing a little Java programming to make me re-appreciate the pure simplicity of Clojure! :simple_smile:
Does anyone of you have a case of reify in their code with more than one interface/protocol?
Preferably links to public repos.
I have a few, but this is probably the most straightforward, https://github.com/phronmophobic/membrane/blob/b265d9189a3a1a50e22d5be637ab099556e83673/src/membrane/java2d.clj#L775
Nice. Also something non-ui related maybe?
https://github.com/phronmophobic/membrane/blob/09e14e3f152a53f47c257ada592f577f9d0328b7/src/membrane/ui.cljc#L289, it's used with ui code, but the purpose is to be able to memoize functions with potentially infinite lazy sequences as arguments which could be used outside of ui
thanks!
and another example that hasn't been pushed publicly yet: in cljs
(reify
IPending
(-realized? [_]
(not (identical? @atm obj)))
IDeref
(-deref [_]
(let [val @atm]
(assert (not (identical? val obj)))
val)))
that's a nice example
usage: it's meant to mimic a future. there's probably a better way to write it, but basically, I have some clj code I ported to cljc where I want a future that only gets deref'd once some async process is complete.
(let [obj (js/Object.)
atm (atom obj)
p (reify
IPending
(-realized? [_]
(not (identical? @atm obj)))
IDeref
(-deref [_]
(let [val @atm]
(assert (not (identical? val obj)))
val)))]
(async/go
(let [rendered (<! (-render-elems params elems))
error? (= :error elems)]
(when-not error?
(builder-dispatch :set $current-render [elems params rendered]))
(reset! atm elems)))
p)
elsewhere:
(if (realized? p)
@p
(ui/label "loading..."))
https://github.com/schmee/daguerreo/blob/master/src/daguerreo/impl/engine.clj#L336-L354
Eight reify
's in this file. This one is the biggest: https://github.com/seancorfield/next-jdbc/blob/develop/src/next/jdbc/result_set.clj#L483
thanks!