Fork me on GitHub
#clojure
<
2021-12-11
>
Drew Verlee06:12:46

Do you a graphic (see picture) would improve the https://clojure.org/reference/refs on clojure ref? I find it very hard to read linear text and imagine time. When time becomes another variable on a graph, its easier. In fact, likely calling time something else in explaining a concept the first time would help ease the mind. mostly unrelated question, what would be the use of a dosync block without a ref being referenced in it? https://clojure.github.io/clojure/clojure.core-api.html#clojure.core/dosync oddly makes no mention of refs in its docs, only of "transactions" but where else can you store transaction outcomes beyond a ref? I think the only thing i could suggest is that in the docs "Ref" be a blue link to draw attention to my overloaded mind. Cider-docs on emacs does this luckely.

Ben Sless06:12:28

A graphic always improves understanding for some people, myself included

Ben Sless06:12:14

Might want to make it version controlled by using dotlang :thinking_face:

Drew Verlee06:12:59

err. I'll be struggling to just understand the ideas well enough to draw them on paper for one or two examples. off to bed with me.

Ben Sless06:12:24

Before you run away, do you remember the name of this type diagram you drew?

hiredman07:12:26

If you haven't seen https://youtu.be/E4RarTAZ2AY it includes rhickey talking about clojure's model of time

pavlosmelissinos07:12:01

Looks like a sequence diagram.

hiredman07:12:53

Yeah, a message sequence chart, just with the timelines running horizontal instead of vertical

Ben Sless07:12:21

That's the name I was missing, thank you

Drew Verlee07:12:10

@U3T9E4R0A those drawings are from here martin kleepmans work. I believe he draws them himself.

Drew Verlee07:12:38

@U0NCTKEV8 ill watch it tomorrow ty.

cddr12:12:25

> I believe he draws them himself. Actually I think the confluent folks use something called "paper" "concepts" https://rmoff.net/2019/07/11/so-how-do-you-make-those-cool-diagrams-july-2019-update/

👍 1
rmxm13:12:11

While setting up a project with next-jdbc there is a lot of effort to convert from underscore to kebab. Well, additional work at least. Question do you find value in having kebab vs underscore, or its just a visual preference? (Followin general intuitions that less stuff like converting than better)

Ben Sless13:12:41

IMO kebab is more convenient and readable. It's also friendlier to my pinky. If I can set some conversion up at the edges I prefer it

2
rmxm13:12:51

Thanks for info. By at edges you mean _explicit_ in code? (btw for your pinky, why not use left shift for _ ? sorry, im into keyboards and it seems really unergonomic to press right shift + -) :slightly_smiling_face:

p-himik13:12:07

I'd say implicit. Best case scenario - you never see snake-case at all when working with e.g. DB. Or anywhere. And I do use left shift for _ - it's still noticeably more cumbersome than just -. Especially when you have to type it 3 times in a single identifier.

Ben Sless13:12:07

Both shifts are inconvenient for me, but by the edges I mean implicit (or once explicit) and handled when you set up the interface with the edge. For example with next-jdbc you can pass a row builder which handles all that for you

Ivan Fedorov15:12:11

Were there any guides on how to investigate / reproduce the latest log4j CVE in your own Clojure app? https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-44228 Also, are there any guides for friends and family?

Ivan Fedorov16:12:17

More specifically – is there an easy way to understand what logging backend was chosen by clojure.tools.logging? For those who didn’t set it explicitly

ghadi16:12:50

Examine your dependencies @iw.romanof579

Ivan Fedorov17:12:01

A place to start, thanks! Not sure if it guarantees anything though 🙂

Ivan Fedorov21:12:54

@U050ECB92 found it!

(.name clojure.tools.logging/*logger-factory*) ;; get your current logging implementation name

dpsutton17:12:02

It can change when adding new dependencies. It just looks for classes in a certain order and the first found is your logger.

emccue17:12:26

Running into an interesting error expanding a macro. Body and error in thread

emccue17:12:31

(do
 (do
  (clojure.core/defprotocol
   PApple
   (color
    [this__10047__auto__]
    [this__10047__auto__ new-value__10048__auto__])
   (size
    [this__10047__auto__]
    [this__10047__auto__ new-value__10048__auto__])
   (shape
    [this__10047__auto__]
    [this__10047__auto__ new-value__10048__auto__]
    "The shape of the apple"))
  (clojure.core/defn
   apple?
   [o__10049__auto__]
   (clojure.core/satisfies? PApple o__10049__auto__)))
 (clojure.core/defrecord
  Apple
  [color size shape]
  PApple
  (color [this__10070__auto__] color)
  (color
   [this__10071__auto__ new-value__10072__auto__]
   (clojure.core/assoc
    this__10071__auto__
    :color
    new-value__10072__auto__))
  (size [this__10070__auto__] size)
  (size
   [this__10071__auto__ new-value__10072__auto__]
   (clojure.core/assoc
    this__10071__auto__
    :size
    new-value__10072__auto__))
  (shape [this__10070__auto__] shape)
  (shape
   [this__10071__auto__ new-value__10072__auto__]
   (clojure.core/assoc
    this__10071__auto__
 
   :shape
    new-value__10072__auto__)))
 (clojure.core/defn
  apple
  [args__10095__auto__]
  (clojure.core/when-let
   [error-info__10093__auto__
    (clojure.core/some->
     (malli.core/explain [:map [:size pos-int?]] args__10094__auto__)
     (malli.error/humanize))]
   (throw
    (clojure.core/ex-info
     (clojure.core/str error-info__10093__auto__)
     error-info__10093__auto__)))
  (map->Apple args__10095__auto__)))

emccue17:12:00

; Syntax error (ClassFormatError) compiling deftype* at (src/dev/mccue/demo.clj:135:1).
; Duplicate method name "size" with signature "()Ljava.lang.Object;" in class file dev/mccue/demo/Apple

emccue17:12:29

If i comment out the single arity size i get

(clojure.core/defrecord
 Apple
 [color size shape]
  PApple
  (color [this__10070__auto__] color)
  (color
    [this__10071__auto__ new-value__10072__auto__]
    (clojure.core/assoc
     this__10071__auto__
     :color
     new-value__10072__auto__))
  #_(size [this__10070__auto__] size)
  (size
   [this__10071__auto__ new-value__10072__auto__]
   (clojure.core/assoc
    this__10071__auto__
    :size
    new-value__10072__auto__))
  (shape [this__10070__auto__] shape)
  (shape
    [this__10071__auto__ new-value__10072__auto__]
    (clojure.core/assoc
     this__10071__auto__
     
     :shape
     new-value__10072__auto__)))
; Syntax error (VerifyError) compiling new at (.calva/output-window/output.calva-repl:198:1).
; Bad type on operand stack
Exception Details:
  Location:
    dev/mccue/demo/Apple.size()I @6: ireturn
  Reason:
    Type 'java/lang/Object' (current frame, stack[0]) is not assignable to integer
  Current Frame:
    bci: @6
    flags: { }
    locals: { 'dev/mccue/demo/Apple' }
    stack: { 'java/lang/Object' }
  Bytecode:
    0000000: 2ab9 018f 0100 ac   

emccue17:12:39

which is not my favorite error of all time

emccue17:12:53

ignore me - running into that wierd thing where defrecords are also maps and thus have a .size

rmxm22:12:31

hey, i'm trying something odd, feel like macro territory?

(let [args [1 2 3]]
  (-> []
      (conj 1)
      (conj 2)
      (conj 3)
      ;conj by adding individually, sort of like in loop)

dpsutton22:12:05

not sure if your usecase is as simple as your demonstration here, but (conj [] 1 2 3 4). And even if it is more complicated, I don't see any reason to reach for a macro when you could use functions

rmxm22:12:00

conj is used more or less as example, I am aware I can pass multiple params, or even use something like (apply conj args) , its more about programatic composition inside threading macro, to give different example

(let [fns [f1 f2 f3]]
  (-> _
      (f1...
      (f2...

phronmophobic22:12:34

it's not really clear why apply doesn't apply here. another alternative is:

(reduce #(%2 %1) initial-value [f1 f2 f3)
eg:
> (reduce #(%2 %1) 0 [inc inc inc dec inc])
3

👍 1
didibus22:12:15

Bet people using Timbre are pretty happy right now 😝

bmo 2
potetm22:12:01

#logback4lyfe

👌 4