clojure-europe

For people in Europe... or elsewhere... UGT https://indieweb.org/Universal_Greeting_Time
kardan 2020-09-21T05:15:02.064Z

Good morning

plexus 2020-09-21T05:28:31.064200Z

Good morning!

2020-09-21T05:59:43.064500Z

Buenos dias

jasonbell 2020-09-21T06:15:48.064700Z

Morning

orestis 2020-09-21T06:26:31.064900Z

Καλημέρα

slipset 2020-09-21T06:27:49.065100Z

Kalimera! God morgen!

ordnungswidrig 2020-09-21T06:58:48.065400Z

Guten Morgen!

2020-09-21T08:19:19.065700Z

bonjour !

raymcdermott 2020-09-21T08:21:19.065900Z

morning

2020-09-21T08:29:29.066100Z

Bon jour

raymcdermott 2020-09-21T08:38:11.072100Z

a small question of style for you... when I see the update-last from @otfrom I can grok the if and the else cos it's a snappy bit of code

(defn update-last [v f & args]
    (if (seq v)
      (conj
       (pop v)
       (apply f (peek v) args))
      v))
but I am always a little concerned with Clojure that too many forms between an if and the else can allow the else to get a bit lost and can (has been for me) the cause of silly bugs so I think this one here is definitely within bounds ... so do you feel the same and if so when would you break out the cond or something like this
(defn update-last [v f & args]
  (cond
    (seq v) (conj
              (pop v)
              (apply f (peek v) args))
    :else v))
like I say, over the top for this case but for me, 2 or three more lines of the true side of the if and I would break out the cond or do an if-not
(defn update-last [v f & args]
  (if-not (seq v)
    v
    (conj
      (pop v)
      (apply f (peek v) args))))
thoughts?

2020-09-21T09:19:58.072700Z

Maybe (if (empty? v)....

2020-09-21T09:20:19.073200Z

I also like to put the easy flow at the beginning

1
thomas 2020-09-21T09:56:24.075300Z

Morning

orestis 2020-09-21T12:53:30.076Z

Agree with the easy flow at the beggining, and with using cond when things become hairy.

2020-09-21T13:05:21.076800Z

for me if either leg of the if became too long I'd prefer to factor it into another funciton and keep the if short

2020-09-21T13:05:32.077100Z

and only use cond if there are more than 2 choices

2020-09-21T13:05:37.077300Z

1 or nil -> when

2020-09-21T13:05:45.077500Z

2 -> if

2020-09-21T13:05:57.077900Z

more than 2 -> cond

2020-09-21T13:06:26.078500Z

complex and more than 2, then possibly core.match or multimethods

2020-09-21T13:07:15.079100Z

I quite like multimethods for quite complex things, it makes each path quite clear

raymcdermott 2020-09-21T13:33:13.079400Z

nice rules of thumb so :thumbsup::skin-tone-3:

2020-09-21T13:39:21.080800Z

I usually write out the function all in one and then factor out the legs. Testing in a rich comment block as I go

ordnungswidrig 2020-09-21T14:01:16.081500Z

I, too, love multimethods but they get in my way so easily with code reload, or when abused as a “plugin system”.

ordnungswidrig 2020-09-21T14:01:54.082600Z

Maybe it’s just bad coding habits on my side. I like cond and potentially calling individually named functions which help understanding what’s going on

2020-09-21T14:02:12.083100Z

@ordnungswidrig yeah, I find that too. I usually do them b/c I know things are going to have complicated bodies or refactring a cond

2020-09-21T14:02:42.083600Z

individually named functions are good. multimethods means that I can worry slightly less about names

2020-09-21T14:03:08.084100Z

I've never really taken much advantage of them being open before, but I have worked with libraries that do like dali

plexus 2020-09-21T14:37:06.084900Z

Kaocha leverages them for plugins and that works quite nicely

raymcdermott 2020-09-21T14:55:29.085700Z

we use them for mapping protocol messages so yeah, the openness is a delight

raymcdermott 2020-09-21T20:16:15.086300Z

Goodnight

👍 1
❤️ 1