Fork me on GitHub
#clojure-europe
<
2020-10-27
>
slipset07:10:42

I've been wondering why core has all these fns like interleave, interpose and other neat sequence functions. To me they seemed, well, neat, but nothing I ever reach for in my day to day work. But then I tried to write a macro, and they made a lot more sense.

slipset07:10:19

Oh, and good morning!

mpenet08:10:53

I used interpose a lot in the past, it's great to generate token (comma, AND, OR etc) separated strings and since it has a transducer arity you can compose with it nicely and "realize" the final thing with a single call to transduce + a string-builder reducing fn

mpenet08:10:21

(ex context clojure dsl -> some string based query language)

mpenet08:10:14

You can do the same with str/join but you loose the ability to do it in a single pass when you need to also work on the values passed to it, think (str/join "," (map tranform xs)) vs (transduce xform string-builder xs), where string-builder and xform can be heavily optimized for what you need to generate

borkdude08:10:28

I needed interleave to process namespace forms and interleave the namespace names with :reload, so you get:

(ns foo (:require [foo :as f] bar)
=>
(ns foo (:require foo :reload bar :reload)

plexus08:10:44

good morning!

slipset14:10:39

Another one of those things that feel ok to discuss in here.

user> (= 1 1 1)
;; => true
user> (= 1 1)
;; => true
user> (= 1)
;; => true
user> (=)
Execution error (ArityException) at user/eval73949683 (form-init4579255747461836344.clj:2764).
Wrong number of args (0) passed to: clojure.core/=

slipset14:10:06

this blows up when you do (apply = xs) and xs is empty

slipset14:10:38

(= nil) => true

borkdude14:10:45

true yes, I've had that exception as well

borkdude14:10:03

maybe this is like (-) because = doesn't have an identity element?

slipset14:10:36

Could be, but it also seems like < and > behaves this way.

slipset14:10:10

I guess this is somewhat violating the principle of least surprise.

slipset14:10:09

I think I'd be happy if = was two-arity, I'm pleasantly surprised by it being multi-arity, but then again, a bit annoyed that it's not zero-arity.

borkdude14:10:20

I'm sure there's a reason it doesn't return true or false by default

borkdude14:10:41

one thing is equal to itself. but zero things...?

borkdude14:10:58

undefined I would say

slipset14:10:19

Am I equal?

slipset14:10:44

user> (< 3)
;; => true
user> 

slipset14:10:53

Don't know if that makes sense?

borkdude14:10:31

(> 3)
true
hmm, 3 is both smaller and greater than... something

slipset14:10:57

user> (= 3)
;; => true
user> 

slipset14:10:11

user> (not= 3)
;; => false
user> 

mpenet14:10:16

(and) the universal truth

slipset14:10:43

This is so disturbing I might have to move on to Haskell or Idris or somehting.

borkdude14:10:14

@slipset We can make a clj-kondo rule that says: don't use varargs comparison: always use reduce + an explicit identity ;)

slipset14:10:28

I guess this is the kind of runtime errors I have a hard time accepting, And why I now always use the three-arity reduce

slipset14:10:32

I can handle (runtime) type-errors as they don't crop up too often, but runtime-lack-of-nil-punning sucks.

slipset14:10:54

Same difference when using clojure.string I guess

plexus16:10:33

still waiting for someone to release a fork of clojure.string that nil-puns

borkdude14:10:18

lack of zero-arity isn't the same as nil-punning though

borkdude14:10:37

I would say an error is better than silently returning true of false here

borkdude14:10:13

(when (seq things) (apply = things)), it's a bit annoying

slipset14:10:33

And Zach thinks (get nil :foo) should be error as well.

borkdude14:10:47

What about (:foo nil)

slipset14:10:16

You could argue that map lookups should always be done with a sentinel-value

(:foo nil :not-found)

borkdude14:10:50

or: (or (:foo nil) (throw (ex-info "up" {}))))))))

borkdude14:10:05

(I didn't know how many closing parens I should type, so I just ensured there were enough)

slipset14:10:11

I guess what Zach argues is that when you to a map-lookup on nil you change the type of nil, if that makes sense.

slipset14:10:44

(:foo nil :not-found) is supported in Clojure BTW

borkdude14:10:44

ok let me know how it goes in Haskell land and see you back in a year or two :)

otfrom15:10:10

< and > aren't less-than or greater-than, they are increasing and decreasing (or at least that is the only way I can remember

3
orestis15:10:10

I just saw an AWS update that Corretto JDK 11 now supports Shenandoah GC, and it turns out it was backported to JDK11. I wonder if someone has used it with Clojure programs and has any experience report?

otfrom15:10:49

I'd certainly be up for any GC/jvm tuning tips

borkdude15:10:09

@otfrom Yeah, the docstring says so. That would explain the behavior or (< 3)

dominicm20:10:17

Totally unrelated, http://mailbox.org looks great

borkdude20:10:45

Yep, I moved to that and I'm pretty happy with that so far

synthomat23:10:52

How accurate is the spam filtering? I suffer from an increasing amount of spam mails in my inbox and now I’m thinking about rolling my own mail setup (again) :white_frowning_face: