Fork me on GitHub
#clojure
<
2016-10-12
>
escherize06:10:24

Some feedback on this library would be nice if you could spare it 🙂 https://github.com/escherize/tracks

sooheon07:10:04

@escherize That looks really cool, kind of like suggest.el but instead of finding an appropriate function, just creates it for you. No technical feedback yet, but I’ll definitely check it out!

lvpidadiao08:10:43

what am i doing

herbm08:10:10

I love the idea @escherize but I don't even understand the 2nd example: you def must-go-deeper but then seem to call deep-ways -- ???

escherize08:10:49

Oh yeah that is a typo let me fix it. Thanks @herbm -- should be fixed now

baptiste-from-paris09:10:57

hello guys, need community help ^^

baptiste-from-paris09:10:58

I am new to Clojure and I read Clojure For The Brave And True, I can't understand well core.async; anyone has been through that and tell me where to go to find out more ?

baptiste-from-paris11:10:03

clojure or clojurescript specific ?

borkdude11:10:39

it’s in clojurescript, but it teaches you concepts that apply to clojure as well

tomjkidd11:10:55

@baptiste-from-paris After that, Tim Baldridge also does presentations on it, with more focus on internals

baptiste-from-paris11:10:35

great ! tx a lot !

baptiste-from-paris11:10:28

love clojure but there are so many things to learn compared to classical OOP

alexmiller13:10:26

Clojure Applied has a lot of coverage of core.async

idiomancy14:10:17

speaking of core.async, is there a way to print out the name of the current thread? I'm trying to get past the major problem point in async which is the "exception occurred in async-dispatch-thread-n" problem, where your program execution gets squirelled away beyond where your debugger can go.

idiomancy14:10:36

I want to be able to print the name of the current thread "async-dispatch-4" for example

idiomancy14:10:58

so that i can at least see, once the exception raises, if it was spawned by the thread I think it was spawned by

borkdude14:10:51

why does clojure.edn/read-string include an :eof option and can I have an example of it’s usage + output?

joost-diepenmaat14:10:59

@idiomancy (.getName (Thread/currentThread))

joost-diepenmaat14:10:14

I also have some code doing stuff like

joost-diepenmaat14:10:19

`(defn set-thread-name! "Set the name of the current thread to n" [n] (-> (Thread/currentThread) (.setName n)))`

idiomancy14:10:40

huh, thats pretty sweet

idiomancy14:10:51

didnt know you can access the current thread as an object

idiomancy14:10:05

lol, I want more async debugging tips!

jrheard14:10:17

@tomjkidd - late to the party, but i found bhauman’s http://rigsomelight.com/2013/07/18/clojurescript-core-async-todos.html extremely helpful when i was trying to understand core.async

baptiste-from-paris15:10:08

@alexmiller ok, thx, will buy that one then

alexmiller15:10:38

@borkdude that's used to define a custom sentinel indicating eof

alexmiller15:10:22

Usually before calling the reader you create the sentinel, like (Object.)

borkdude15:10:17

Ah, so the only useful case of that would be when reading an empty string?

(let [o (Object.)]
  (= o (edn/read-string {:eof o} ""))) ;;=> true

dadair15:10:37

Is there a way to compose a set of core.match "matchers" from disperate matching exprs? Similar to how in compojure you can build up a routing table by composing several routes def'd with defroutes?

dadair15:10:59

ex: (match [x y] matchers1 matchers2 matchers3 ..) where matchersX might be something that returned [true false] (fn ...) [false false] (fn ..)

samedhi15:10:45

I actually first noticed its existence (s/def :dog/tail? boolean?) in http://clojure.org/guides/spec

samedhi15:10:31

Just thought it a bit odd.

seancorfield15:10:22

The link you gave is the 1.8 docs.

samedhi15:10:28

ahh, got it.

punnie17:10:19

what's with clojure/java http libraries and SSL, honestly

donaldball17:10:44

Managing CAs is neither easy nor simple?

punnie17:10:47

however, I'm trying to get clojure to get along with SNI

punnie17:10:20

so I wish my problem would be as complex as managing a CA and distributing trusted certs 😉

bcbradley17:10:46

do you guys know whether or not httpkit's asynchronous callbacks run in a different thread?

alexmiller18:10:52

@borkdude well the other flag that is relevant is whether to throw on eof - if you want to avoid throwing then you need to receive some value indicating eof, and you want that to be distinguishable from any other value you might have read that was in the data. So passing the sentinenal EOF (made by you) is how that’s done.

tbaldridge18:10:12

@bcbradley no they don't last time I checked, and it's one of the reasons I somewhat dislike http-kit. Not enough documentation/thought put into the async model. For example websocket sends in http-kit are blocking with no option to do async sends.

bcbradley18:10:40

i'm reworking my model after looking into it

bcbradley18:10:58

do you have a suggestion for a good lightweight high throughput http library for clojure?

tbaldridge18:10:06

Why yes I do 😉

bcbradley18:10:40

i'm working on client side

tbaldridge18:10:59

Oh a HTTP client library, sorry that wasn't clear.

bcbradley18:10:29

basically i'm trying to make a library for interfacing with the discord api in clojure

bcbradley18:10:54

i'm hiding the server behind an async chan so i can control how many requests are issued per second

piyush18:10:01

hi if I have a simple question regarding aero is this the right place to ask ? apologies if not. I am new to the community but loving clojure.

bcbradley18:10:03

and so i can enable plug and play caching

bcbradley18:10:43

chans are many to many (in my case i only care about many to one)

bcbradley18:10:51

but i want efficiency

tbaldridge18:10:02

@bcbradley I've used the Apache HTTP Async library on more than one occasion. It's fairly light and quite easy to implement: http://hc.apache.org/httpcomponents-client-ga/httpclient/examples/org/apache/http/examples/client/ClientWithResponseHandler.java

bcbradley18:10:50

looks pretty nice

bcbradley18:10:58

i don't mean to be picky

bcbradley18:10:04

but i'd prefer to stay in clojure if possible

tbaldridge18:10:12

So if we back up to http-kit though (as it's probably simpler) I would suggest just putting the data into a channel with a large buffer

tbaldridge18:10:51

I've used the apache library with Clojure before, you just pull in 2 java classes, then use reify to extend a single interface, but I understand interop can be tricky.

tbaldridge18:10:16

But if you have http-kit dump into a channel with a large buffer you can pull from that channel in a different thread and do your processing

bcbradley18:10:23

yeah i've got my hands full with this as is, i'm new to clojure and github

bcbradley18:10:40

so i'd prefer to handle interop on another battelfield

tbaldridge18:10:47

understandable

bcbradley18:10:10

pulling from that chan in a different thread

bcbradley18:10:21

should i just use "thread-call" in coreasync?

bcbradley18:10:30

like an infinite loop or something?

tbaldridge18:10:18

yeah that's one way to do it. If you have processing steps that fit in common clojure functions you can also look at async/pipeline-blocking : https://clojure.github.io/core.async/#clojure.core.async/pipeline. This allows you to do something like (async/pipeline-blocking 4 to (map inc) from)

tbaldridge18:10:38

^^ that will increment all the values taken from from put them in to and use 4 threads to do the processing.

bcbradley18:10:59

i recall reading about that when i was working on something else

bcbradley18:10:50

i don't think it will work in my case

bcbradley18:10:03

because the output is not a chan

bcbradley18:10:08

its a server call

bcbradley18:10:11

through http

tbaldridge19:10:34

Sure, then just use a loop to take from the channel, inside async/thread and take with async/<!!

flyboarder21:10:12

Any suggestions for helping fund clojure open source software?

lwhorton21:10:57

hey guys, I’m confused about protocols within clojurescript vs clojure. If I wanted to extend-type String in java it would be java.lang.String, but in cljs is js/String the “right” way to handle this?

kenny21:10:37

@lwhorton No. You need to use string in cljs with extend-type

lwhorton21:10:07

thanks @kenny . is there somewhere I can find the type definitions? for example if I wanted to do the same to map, it surely cannot be map (a function).

kenny21:10:23

@lwhorton Not sure if it documented anywhere.

kenny21:10:27

Map is PersistentHashMap

lwhorton21:10:03

i've tried peeking at the source many a time, but it’s still pretty foreign to me, what with my unfamiliarity with records, deftype, and the other few ‘more advanced’ language features

lwhorton21:10:15

bummer. thanks for letting me know anyways though

lwhorton22:10:40

just a head’s up @kenny, it seems to be PersistentArrayMap (not Hash).

lwhorton22:10:07

(def a {})
(def b [])
;; compiles to
cljs.user.a = cljs.core.PersistentArrayMap.EMPTY;
cljs.user.b = cljs.core.PersistentVector.EMPTY;

bfabry22:10:15

@lwhorton @kenny when you construct a map it is created as either an ArrayMap or a HashMap depending on the size

lwhorton22:10:00

Rut roh. Does that mean I have to extend-type of both to guarantee no problems? or is there something more clever?

bfabry22:10:24

uhhhh, I don't know? in clj I would extend IPersistentMap does that exist in cljs?

lwhorton22:10:41

good question, ill peek around

lwhorton22:10:25

oh neat, it looks like clojurescript’s types are clojure types, and clojure types are java types

lwhorton22:10:29

+1 for cljs 🙂