Fork me on GitHub
#clojure-uk
<
2017-11-30
>
thomas09:11:24

moin moin morning

danm10:11:20

Cycle in this morning was a bit cold

rickmoynihan10:11:25

So I finally booked my tickets to clojureX last night. Is anyone else here going?

dominicm10:11:10

@rickmoynihan pricey time to book

rickmoynihan10:11:00

I’ve had a lot of problems and other things on my mind this year. Thankfully I can expense it.

rickmoynihan11:11:13

Cool. I’ve not actually met many people AFK in the clojure community, so it’d be good to actually meet some of you

yogidevbear11:11:10

Stupid lost voice

yogidevbear11:11:36

If anyone finds my vocal cords, can you please send them back my way

jasonbell11:11:17

@yogidevbear Oh that’s no good, how are you going to heckle?

yogidevbear11:11:22

With sign language troll 🖕

yogidevbear11:11:29

Just kidding 🙂

yogidevbear11:11:02

I must be shouting at my son too much. He struggles with this concept of listening 😉

guy11:11:16

morning!

danm11:11:58

We have met in the past at LambdaLounge

danm11:11:40

I would have liked to go to ClojureX but there's just too much other stuff I've had booked for a while for that week both in and outside work :-S

rickmoynihan11:11:47

Hey @carr0t, yes… Thanks for doing the talk the other month btw… was sorry I couldn’t make it.

danm11:11:03

No worries, was fun 🙂

rickmoynihan11:11:13

did you have a good turn out? I think Hakim said it went well.

rickmoynihan11:11:53

yeah I know the feeling about being overbooked 🙂

danm11:11:31

Well that's relative. There were I think 4 other people apart from myself and Hakim, so not the best turnout we've had but not the worst either 😉 And when you say "I'm going to be talking about Clojure Macros! You don't need to know any Clojure first, honest" anyone who isn't interested in Clojure and doesn't know what macros are might just not feel like turning up anyway

danm11:11:02

But there were some good discussions

danm11:11:51

And a few people who wanted to make it but couldn't. The guy who runs defshef was one of those, asked for the slides afterwards and wondered if I'd like to go over and do it for them sometime next year too

rickmoynihan11:11:12

haha yeah… it kinda goes with lambda lounges territory… Our niche is in running a regular meetup on niche topics that don’t get an audience elsewhere…. so we don’t measure our success on turn out 🙂

rickmoynihan11:11:30

Incidentally I owe you a lambda lounge sticker… I try to give them to everyone who does a talk, but I often forget…

guy11:11:13

@carr0t do you still have slides/video about your talk on clojure macros? I would be interested in seeing / reading them

danm11:11:03

Video, no. Slides, yes. I'm not sure how useful they'd be without the talk though. A lot of it was code on screen that I then talked about, without much on the screen to reiterate what I was saying. I was aiming to avoid text overload 😉

danm12:11:43

I'll hunt them down if you're still interested. Might add some notes so it's more understandable what I was going for 😉

guy12:11:42

sure sure!

guy12:11:51

No rush/hassle though

jamesalmond14:11:37

Afternoon. I have a ticket to Clojure eXchange next week but can't make it any more 😞. Assuming it's ok to transfer the ticket somehow (I haven't checked) does anyone want it or know someone who wants to go?

dominicm14:11:14

it is okay to transfer tickets afaik.

dominicm14:11:32

Someone transferred me their tickets a couple years ago

dominicm14:11:42

and it was done via official channels

jamesalmond14:11:19

thanks @dominicm. it's short notice so I'm amenable to offers or just giving it away!

practicalli-johnny14:11:17

@jamesalmond to transfer a ClojureX ticket can just email SkillsMatter ( info at skillsmatter dot com ) with your name and the persons name & email you are transferring the ticket too. You may want to send a message about the ticket on offer to https://groups.google.com/forum/#!forum/london-clojurians as they get snapped up pretty quick

jamesalmond14:11:15

aha! thanks @jr0cket. I'll add a message there.

practicalli-johnny14:11:11

Sorry you cant make it, hope to see you at the next one.

Rachel Westmacott15:11:36

has anyone seen this before:

Error updating class definitions:
NullPointerException   java.util.concurrent.ConcurrentHashMap.get (ConcurrentHashMap.java:936)

Rachel Westmacott15:11:53

I sometimes get them at the REPL

bronsa15:11:36

do you have a full stacktrace?

Rachel Westmacott15:11:00

That gets printed, and *e is nil

Rachel Westmacott15:11:28

I guess it’s from some other thread - is there a cunning way to obtain such exceptions?

guy15:11:52

This is just clutching at straws, but i remember a (i think) stuart sierra blogpost about having a global exception handler

guy15:11:56

Maybe that would work?

Rachel Westmacott15:11:13

yes maybe - It’s worth a try, as I have the code to hand

guy15:11:38

>https://stuartsierra.com/2015/05/27/clojure-uncaught-exceptions

guy15:11:40

i think its that

guy15:11:57

So at a minimum, I recommend always including this snippet of code somewhere in the start-up procedure of your application:

Rachel Westmacott15:11:58

yes - I have it in my production code

guy15:11:01

ok sorry

Rachel Westmacott15:11:04

but it’s not always loaded in my REPL

guy15:11:24

nps! Good luck finding the bug!

yogidevbear15:11:24

Seriously?! I just walked into the same glass sliding door again!

Rachel Westmacott16:11:18

There was a monk at my school (it was not a normal school) who once walked through one of those full height glass panels. He just went straight through it. He was rather shocked afterwards but I don’t think he was badly hurt. I think it used to happen quite a lot, but now they tend to print some kind of pattern on the glass to help people notice them.

yogidevbear16:11:53

I've never done this type of stuff before. Clearly... The glass has been cleaned too well 😆

otfrom16:11:11

or similar?

bronsa16:11:02

@otfrom I wouldn't use that lines-reducible, it's wrong with regards to reduced handling

bronsa16:11:41

@ghadi has these two awesome functions https://gist.github.com/ghadishayban/902373e247e920855139902912d237f0 , they've been sufficient to me when I've wanted to produce custom reducibles

otfrom16:11:48

I was wondering that. I'm getting an exception when I try to do a take on it

otfrom16:11:59

(tho mine is a bit different as I'm reading records)

otfrom16:11:27

I'd just need to figure out where to put the finally to close the resource

dominicm16:11:45

So, I've seen people use lazy seqs to do CLJ-1906. I suspect that's wrong, but haven't been able to formulate why.

otfrom16:11:15

;; Shamelessly stolen from 
(defn baldr-reducible [^InputStream is]
  (reify clojure.lang.IReduceInit
    (reduce [this f init]
      (try
        (loop [state init]
          (if (reduced? state)
            @state
            (if-let [record (baldr/read-record is)]
              (recur (f state record))
              state)))
        (finally (.close is))))))

otfrom16:11:27

changing state to @state seemed to make it work

bronsa16:11:12

that's correct but I still wouldn't use that reducible

bronsa16:11:21

if you don't consume the whole thing you're never going to close the input stream

bronsa16:11:47

as opposed to ghadi's supply which allows you to control when and how your resource is closed

reborg18:11:09

not very different from baldr-reducible if I (.close is) anytime below after the call. I do like more supply tho, just don't see a big difference

bronsa16:11:47

@dominicm because resourse management with lazy seqs is hard/wrong(ish)

dominicm16:11:33

Why wrong, where are the difficulties?

bronsa16:11:30

if you've ever used clojure.java.jdbc I'm sure it's happened at least once that you got resultset closed while trying to consume a query result set

bronsa16:11:06

there's your perfect example of why resoure management using lazy seqs is easy to get wrong

bronsa16:11:17

even when you get it right, you still need to make sure you're consuming it correctly

rickmoynihan16:11:18

@dominicm: as someone who’s done it (and regretted it)… the difficulties are mainly around the resource lifetime being different from the sequences lifetime.

bronsa16:11:26

yes, exactly that

rickmoynihan16:11:19

lazy sequences escape contexts (it’s what we like about them) but when tying them to stateful things you need to control the underlying resource/socket etc, and that control can’t flow through your program to whichever callsite is responsible for actually consuming the sequence, as the sequence abstraction has no mechanism for controlling resources. Also handling errors can be awkward.

mccraigmccraig16:11:34

if you are talking of network or other slow resources then manifold/stream makes resource control easy with its on-closed and on-drained callbacks. probably not so great for tight compute-bound loops though

rickmoynihan16:11:09

This reminds me I really need to return to my (trans|re)ducible-io side project…

otfrom16:11:41

@rickmoynihan I'd love some of that. 🙂

dominicm16:11:56

Is there any concern about lazy seqs doing chunking as well?

dominicm16:11:17

So consumption = hard for resources with lifetimes.

rickmoynihan16:11:46

@otfrom: same… can’t recall quite how far I got… I can’t be sure without checking again but IIRC it didn’t have the issue @bronsa highlighted with reducible-lines… but doubtless has lots of others 😉

rickmoynihan16:11:27

at the bottom there were basically reducers which were essentially just loop/`recur`s on bytebuffers/arrays etc then you’d stack more reducers on top… Will need to tidy it up a bit and get it on github for validation. I’m sure @bronsa would pick some holes in it 🙂

reborg21:11:04

I was tinkering with the following. Can it be any useful? Assuming I understand what you want to achieve, @otfrom, it should be possible to formulate a baldr-seq like a line-seq.

(import '[ BufferedReader StringReader])
(def br (BufferedReader. (StringReader. s)))
(def s "hey\nyou\nhow are you\nSunny\ntoday")

(let [br (BufferedReader. (StringReader. s))
      lines (line-seq br)]
    (transduce
      (comp
        (remove empty?)
        (mapcat #(clojure.string/split % #"\s+")))
      (completing
        #(assoc! %1 %2 (inc (get %1 %2 0)))
        #(do (.close br) (persistent! %)))
      (transient {})
      lines))