off-topic

https://github.com/clojurians/community-development/blob/master/Code-of-Conduct.md Clojurians Slack Community Code of Conduct. Searchable message archives are at https://clojurians-log.clojureverse.org/
borkdude 2020-10-17T11:57:20.386800Z

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!

borkdude 2020-10-17T11:58:03.387400Z

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}

orestis 2020-10-17T12:11:16.387800Z

Transport?

borkdude 2020-10-17T12:12:20.388600Z

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

borkdude 2020-10-17T12:12:52.388800Z

(https://nrepl.org/nrepl/design/transports.html)

borkdude 2020-10-17T12:13:56.389Z

I do think that word is more fitting for the mechanism of transport rather than the format of the messages being transported

2020-10-17T12:42:11.390700Z

Transport is both in nrepl, the serialization mechanism is tied to the communication mechanism

orestis 2020-10-17T12:43:56.391800Z

In twisted python, there’s transport (tcp/udp etc) and protocol (http, etc)

borkdude 2020-10-17T12:48:50.392200Z

@hiredman Right, I guess you could have a nREPL transport edn+http or something

jcburley 2020-10-17T13:00:25.392400Z

“encoding”?

borkdude 2020-10-17T13:10:17.392700Z

socket isn't really an encoding I think

borkdude 2020-10-17T13:56:39.392900Z

I'll go with transport

2020-10-17T14:32:45.393600Z

are there any good hacker-news-esque "startup/programming fusion" slack/discord/chat rooms out there?

lread 2020-10-17T18:19:07.394900Z

nothing like doing a little Java programming to make me re-appreciate the pure simplicity of Clojure! :simple_smile:

😱 4
borkdude 2020-10-17T20:28:34.395700Z

Does anyone of you have a case of reify in their code with more than one interface/protocol?

borkdude 2020-10-17T20:29:56.396300Z

Preferably links to public repos.

phronmophobic 2020-10-17T20:31:52.396500Z

I have a few, but this is probably the most straightforward, https://github.com/phronmophobic/membrane/blob/b265d9189a3a1a50e22d5be637ab099556e83673/src/membrane/java2d.clj#L775

borkdude 2020-10-17T20:33:16.396900Z

Nice. Also something non-ui related maybe?

phronmophobic 2020-10-17T20:36:12.397100Z

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

borkdude 2020-10-17T20:38:12.397500Z

thanks!

phronmophobic 2020-10-17T20:39:15.397700Z

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)))

borkdude 2020-10-17T20:39:39.397900Z

that's a nice example

phronmophobic 2020-10-17T20:41:22.398100Z

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..."))

seancorfield 2020-10-17T20:56:30.399100Z

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

borkdude 2020-10-17T21:04:07.399400Z

thanks!