#clojure logs

2015-07-31

00:02sdegutisNot off hand sorry.
00:02numberten,(merge {:zero 0 :one 1 :two 2 :three 3 :four 4} {:zero 10 :one 20 :two 30})
00:02clojurebot{:zero 10, :one 20, :two 30, :three 3, :four 4}
00:02sdegutisI've come across them a lot over the years, but then I just rant a little in here and move on.
00:02numberten,(merge [0 1 2 3 4] [10 20 30])
00:02clojurebot[0 1 2 3 4 ...]
00:02TEttingernumberten: maybe you want merge-with ?
00:02numbertenthat doesn't seem right
00:02numbertenif you look at vectors as maps from indices to values..
00:03TEttinger,(merge [1 2] [10 20])
00:03clojurebot[1 2 [10 20]]
00:03sdegutis,(pr (merge [0 1 2 3 4] [10 20 30]))
00:03clojurebot[0 1 2 3 4 ...]
00:03numbertenwouldn't merge return [10 20 30 4]
00:03sdegutis,(pr-str (merge [0 1 2 3 4] [10 20 30]))
00:03clojurebot"[0 1 2 3 4 ...]"
00:03TEttinger,(merge [1 2] 10 20)
00:03numberten[10 20 30 3 4]*
00:03clojurebot[1 2 10 20]
00:03sdegutisugh
00:03TEttinger,(str (merge [0 1 2 3 4] [10 20 30]))
00:03clojurebot"[0 1 2 3 4 ...]"
00:03TEttingerhm
00:03numbertenin lein I get
00:03numberten[0 1 2 3 4 [10 20 30]]
00:04TEttinger,(clojure.string/join " " (merge [0 1 2 3 4] [10 20 30]))
00:04clojurebot"0 1 2 3 4 [10 20 30]"
00:04numbertenas the result
00:04numbertenbut was expecting [10 20 30 3 4]
00:04TEttingernumberten: it looks like merge for vectors expects things as single args to add into the vector. not sure why
00:06TEttinger(doc merge-with)
00:06clojurebot"([f & maps]); Returns a map that consists of the rest of the maps conj-ed onto the first. If a key occurs in more than one map, the mapping(s) from the latter (left-to-right) will be combined with the mapping in the result by calling (f val-in-result val-in-latter)."
00:06TEttingerI don't think it is meant to be called with vectors
00:07TEttingerit's odd that it works at all with them, tbh
00:14TEttinger,(defn overwrite [initial-coll over-coll] (let [init (seq initial-coll) over (seq over-coll) i-len (count init) o-len (count over) longer (max i-len o-len)] (mapv #(if (< % o-len) (get over %) (get init %)) (range longer)))
00:14clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
00:15TEttinger,(defn overwrite [initial-coll over-coll] (let [init (seq initial-coll) over (seq over-coll) i-len (count init) o-len (count over) longer (max i-len o-len)] (mapv #(if (< % o-len) (get over %) (get init %)) (range longer))))
00:15clojurebot#'sandbox/overwrite
00:16TEttinger,(clojure.string/join " " (overwrite [0 1 2 3 4] [10 20 30]))
00:16clojurebot" "
00:16TEttinger,(overwrite [0 1 2 3 4] [10 20 30])
00:16clojurebot[nil nil nil nil nil]
00:16TEttingerhm
00:16TEttingeroh.
00:16TEttinger,(defn overwrite [initial-coll over-coll] (let [init (vec initial-coll) over (vec over-coll) i-len (count init) o-len (count over) longer (max i-len o-len)] (mapv #(if (< % o-len) (get over %) (get init %)) (range longer))))
00:16clojurebot#'sandbox/overwrite
00:16TEttinger,(overwrite [0 1 2 3 4] [10 20 30])
00:16clojurebot[10 20 30 3 4]
00:16numbertennice
00:17TEttingeryay clojure
00:17TEttingertesting!
00:17TEttinger,(overwrite [10 20 30] [0 1 2 3 4])
00:17clojurebot[0 1 2 3 4]
00:17TEttingergood...
00:17TEttingerit will overwrite with nils if present in the over-coll.
00:17TEttingerthat may be undesirable
00:18numberteni need to add line breaks to your code before I can fully understand it
00:18numbertenmoment ;)
00:19gfredericksso this time goog.math.Integer cannot serialize 10^309
00:20gfredericksmore precisely it cannot divide 10^309 by 1000000
00:20gfredericksit gets into a infinite loop
00:21gfrederickstest.check finds some crazy stuff.
00:24TEttingernumberten, yeah the meat of it is actually pretty simple. map over a list of indexes, generated by range. if the current index passed to the anon fn is less than the length of the overwriter collection, use the value to overwrite in the final vector. if not, use the initial collection's value at the same index
00:27numberteni like it
00:27numbertenthis also works: (second (reduce #(-> [(inc (first %1)) (assoc (second %1) (first %1) %2)]) [0 v1] v2))
00:27numbertenwhere v2 is the one you overwrite v1 with
00:28numbertenI think I might prefer that because it doesn't inspect lengths... but pairing the accumulator with your index into v2 as you go is kinda ugly
00:28numbertenbundling and unbundling tuples :\
00:28gfredericks,Double/MAX_VALUE
00:28clojurebot1.7976931348623157E308
00:28gfredericksI bet that's why
00:30TEttingernumberten, yeah I do it sometimes too. that's a good solution
00:30numberten(reduce #(assoc %1 (second %2) (first %2)) v1 (map vector v2 (range)))
00:30numbertenis a little cleaner?
00:30numbertenzipping v2 with it's indices
00:30numberteninstead of making the accumulator carry more data
00:37TEttingernice
00:54slestersay I have a function (check-end-game) that detects whether or not the game is over. It can end at any step in the game. I'd like to thread the state through several functions on each turn. How do I stop execution if a step ends the game?
01:04TEttingeryou probably don't want to stop entirely, slester
01:04TEttingeryou may want to display a message but no longer respond to game input
01:04TEttingergame loop should keep running if you have one
01:05justin_smithslester: (take-while (complement check-end-game) (iterate run-turn initial-state))
01:05justin_smiththen check the last item to see how it ended
01:06slesterright, but I guess I mean that "run-turn" (composed of a bunch of functions, draw-card, play-card, etc) can end at any of the intermediate steps
01:08slesterI don't want the person who just got out when he drew a card to play a card
01:09slesterso actually it's this: how do go on to the next iteration of run-turn from one of its member functions without executing the rest?
01:10justin_smithslester: you could break run-turn into the individual operations that could potentially trigger an end game, and only run one of those per iteration
01:10justin_smithall it takes is passing a value representing which sub-item of a turn you are in
01:11justin_smithand dispatching on that of course
01:11justin_smithessentially an immutable state machine
01:12slesterso much to catch up on/try to remember from college! haha. thanks for your time, justin_smith / TEttinger / gfredericks et al
01:13slesterI'll try to read up on those words.
02:11Marina91Start Making Profit Today -> http://bit.ly/1I6gxYU
02:18Marina91Start Making Profit Today -> http://bit.ly/1I6gxYU
02:24johannbestowrousthanks marina
02:28TEttingeryeah I love profit
02:28TEttinger~flatten
02:28clojurebotflatten is rarely the right answer. Suppose you need to use a list as your "base type", for example. Usually you only want to flatten a single level, and in that case you're better off with concat. Or, better still, use mapcat to produce a sequence that's shaped right to begin with.
03:41kwladykawhich library will be the best for performance tests? minimum i need time, super extra will be counting how many times functions was called
03:43Uakhkwladyka have you tried profiling software ?
03:44kwladykaUakh, i want something more in code. I have some idea to test and i want write the same in a few different ways and check performance.
03:44kwladykai want run some function to show me idea-A 10s, idea-B 5 min, etc.
03:45Uakhhttps://clojuredocs.org/clojure.core/time
03:45kwladykaUakh, not really, it should be run a few times to get right time
03:45kwladykaetc.
03:45kwladykai need more complex solution
03:46kwladykagarbage collector can change result and lie to me about time performance
03:47kwladykai just want run something and don't have to think about how to measure this in right way
03:47kwladykafor now i found https://github.com/clojure/test.benchmark https://github.com/hugoduncan/criterium https://github.com/ptaoussanis/timbre
03:49Uakhjust make another time macro, loop x times the algorithm you want to test collecting time each run, then print average/max/min/variance ?
03:50Uakhthat should work alright if you're concerned about jvm warmup
03:53Uakhhttps://github.com/clojure/clojure/blob/clojure-1.7.0/src/clj/clojure/core.clj#L3730
03:53Uakhmaybe I'm not understanding exactly what you're looking for
06:43kwladykais it possible to set https://github.com/ptaoussanis/timbre to profile everything in app?
06:43kwladykanot only what i mark to profile
06:44kwladykaoh maybe ns-whitelist... hmm
06:48kwladykaech it doesn't work in this way
08:42xificurCI'm using a clojure library in my project and need to change the definition of 1 function. What would be the simplest way to do that?
08:44slhsenxificurC, what kind of change?
08:46snowellxificurC: Just define your own fn in your ns and call that instead of the one from the library?
08:48MasseR(defn foo [x] (other/foo (+ x 1)))
08:48MasseROr something like that
08:48xificurCthis one: https://github.com/dakrone/itsy/blob/master/src/itsy/core.clj#L32
08:49xificurCthe library uses the function in others and I'd need to tweak it a bit
08:49justin_smithxificurC: for some simple modifications, you can use robert.hooke to replace or augment a function in some other lib's code
08:50justin_smithxificurC: that would be a good cantidate actually, since it is big enough not to get inlined you should be able to replace it
08:50clojurebotIn Ordnung
08:59xificurCjustin_smith: thanks that looks like it might work
09:04slhsenxificurC: If it's a general use case I guess a better way would be the forking the library, changing the code so that the behaviour you want becomes and option and then submiting a pull request :)
09:05xificurCslhsen: yeah I might do that eventually. The crawler only allows limiting on the hosts, I'd like to be able to limit on path as well. So that I can crawl example.com/this-path-only/
09:11xificurCjustin_smith: that function I'm trying to hooke is calling another one (enqueue*) which is hidden (defn-) and I want to call it too from my handler
09:11xificurCs/handler/hook/
09:31xificurCforked it in the end, now to find out how to use a local project in another one
09:47sdegutisWhen you use vanilla ring-jetty, is each request handler run on its own thread?
10:15justin_smithsdegutis_: yes, jetty serves each request with exactly one thread
10:15justin_smithsdegutis_: while http-kit and aleph are more fine grained
10:21sdegutisOkay.
10:26sdegutisSo if I have (def *foo* (ref nil)), then each thread (and thus each request) gets its own *foo* right?
10:26sdegutisI don't know how to explain what I'm trying to do. I hope you can see it from that example code.
10:27sdegutisOh wait I think I'm actually wanting alter-var-root, since I want each thread to have its own value of some thing.
10:28schmirsdegutis: I think you want dynamic vars
10:29sdegutisPerhaps.
10:32gfredericksdoes anyone (dnolen?) know the best way to manage a cljs-targeted JS lib?
10:32gfredericksin particular a fork of goog.math.Integer
10:32gfredericksby "cljs-targeted" I just mean that it only needs to be used from a leiningen cljs library
10:32justin_smithsdegutis: you want dynamic vars - refs and alter-var-root are not what gives vars per-thread bindings
10:33sdegutisSo (def ^:dynamic *foo*) is good enough?
10:34justin_smithnot only is it good enough, it's the only way to do it
10:34gfredericksdnolen: ^ (in case my earlier mentioning syntax didn't work)
10:34sdegutisjustin_smith: But then do I use binding, with-redefs, or alter-var-root?
10:34justin_smithbinding
10:35justin_smithsdegutis: but are you really sure you need a dynamic var for a per-request binding? a middleware can easily attach a value to the request map that will be unique for that request, and present for the rest of the request lifecycle...
10:35gfredericksI like ^that approach for component-style codebases
10:36sdegutisjustin_smith: I've got an immutable database value that literally is the first argument and first return value in every single function of mine. I'm trying to determine whether it's feasible to hide that in a per-request mutable variable.
10:37justin_smithsdegutis: if it's immutable and everything uses it, why not a var?
10:37justin_smithI mean a normal one
10:38gfredericksI don't think that's what he meant by immutable
10:38gfredericksi.e., he didn't mean static/constant
10:39sdegutisjustin_smith: it's immutable in the sense that its internals are... but the value itself changes, hence my returning a new database value from each function (currently)
10:40sdegutisSo I get a database value as an argument, and I return a "possibly-altered" database value as a return value.
10:40gfredericksthe state monad
10:40sdegutisIt gets old, very *very* quickly.
10:40sdegutisHence I want to hide it in a dynamic var.
10:40gfredericksit sounds like what you would get if rails and datomic got married
10:41justin_smithsdegutis: but with a dynamic var you can't pass a new binding from a nested scope up to a containing one
10:41sdegutisRight, which is why I wanted something like ref or alter-var-root
10:41sdegutisBut on a per-thread basis.
10:41gfredericksyou can!
10:41gfrederickswhen set!
10:41gfrederickswith*
10:41sdegutisgfredericks: +1
10:41gfredericksfun fact about dynamic vars
10:42gfredericksI'm not saying it's a great idea, but you can do it
10:42gfredericks,(def ^:dynamic *foo* nil)
10:42clojurebot#'sandbox/*foo*
10:42dnolengfredericks: if you want zero config, just make your Google Closure style JS follow classpath conventions
10:42gfredericks,(defn inc-foo [] (set! *foo* (inc *foo*)))
10:42clojurebot#'sandbox/inc-foo
10:43dnolenClojureScript does not actually care if a require is JS or CLJS as long as it follows the classpath
10:43dnolenthis is how transit-js + transit-cljs works
10:43gfredericksdnolen: so make a jar with a .js in the right place?
10:43dnolenthat's right
10:43dnolenand a goog.provide that follows the classpath convention
10:43gfredericks,(binding [*foo* 12] (inc-foo) (inc-foo) *foo*)
10:43clojurebot14
10:43gfrederickssdegutis: justin_smith: ^
10:44justin_smith,*foo*
10:44clojurebotnil
10:44dnolengoog.math.Long does not follow these rules but in your case I don't think it matters for testing purposes at all
10:44gfredericksdnolen: okay cool that sounds totally doable; sounds like I don't even need lein-cljsbuild for that
10:44dnolengfredericks: fundamental feature of ClojureScript
10:44justin_smithgfredericks: TIL, and to be honest I am slightly disgusted
10:45gfredericksdnolen: I mean for the packaging part -- I can just throw a .js file in my /src and lein will package it up correctly
10:45gfredericksjustin_smith: I know! it's great!
10:46gfredericksdnolen: to be clear my problems have been with goog.math.Integer, which is different from goog.math.Long; as far as I know Long is solid
10:48dnolengfredericks: ah sorry misread, but points still apply
10:56c-qjv0xfiI have a question regarding Parkour.
10:56c-qjv0xfi*damballa/parkour
10:58c-qjv0xfiIs the uberjar supposed to be run with `hadoop jar`? It seems to be failing when I try to access the hdfs.
10:58c-qjv0xfiWith the word-count tutorial specifically.
10:58c-qjv0xfiAnd then `Don't know how to create ISeq from: clojure.core.reducers$folder$reify__3959` Is the error message I get.
10:58c-qjv0xfiBut it's not telling me a lot...
10:59c-qjv0xfihttps://github.com/damballa/parkour/blob/master/examples/parkour/example/word_count.clj
11:00noncomwow, since when did we get that require syntax with lists for hierarchical requires ?
11:01noncomc-qjv0xfi: could you also please the full stack trace of the exception?
11:01c-qjv0xfinomcom: The requires seemed a little strange to me. ha
11:01c-qjv0xfinomcom: http://pastebin.com/ah7UGk6Y
11:02justin_smithnoncom: it exists, but it's not very popular
11:03gfredericksdnolen: thanks again
11:04nhllI want to get started with Clojure programming. Can anyone recommend a book or online resource that teaches you Clojure by walking you through the development of an actual small to mid sized project, rather than having you code the usual toy examples that have nothing to do with each other? I already read some articles and watched some talks on Clojure and functional programming but I've never actually developed a system in a purely fu
11:06gfredericks,(run! inc (range 5))
11:06clojurebotnil
11:06gfredericks,*clojure-version*
11:06clojurebot{:major 1, :minor 8, :incremental 0, :qualifier "alpha2"}
11:06gfredericks&(run! inc (range 5))
11:06lazybot⇒ 5
11:08noncompc-qjv0xfi: it says that error is in parkour.graph/fexecute - it gets something other than it expects, something that cannot be treated as ISeq
11:09noncomc-qjv0xfi: namely, the call on line 22 in https://github.com/damballa/parkour/blob/master/examples/parkour/example/word_count.clj gets the wrong argument
11:09noncomc-qjv0xfi: i would first try to see what you have by then that you pass to pg/fexecute...
11:09noncommaybe wrap the intermediate result into a (let) and print it before passing to pg/fexecute
11:12noncomnhll: yeah, there are some tutorials online.. depends on what kind of apps you like moar
11:18nhllnoncom: It doesn't really matter to me, of what kind the app is - at least for now. Where can I find the tutorials you mentioned?
11:22noncomnhll: well, you could start with something simple like http://briancarper.net/blog/520/making-an-rpg-in-clojure-part-one-of-many or http://www.youtube.com/watch?v=9ilUe7Re-RA or http://stevelosh.com/blog/2012/07/caves-of-clojure-01/
11:23noncomOR http://www.slideshare.net/alexkehayias/how-to-13988334
11:23noncomOR http://kendru.github.io/restful-clojure/2014/02/16/writing-a-restful-web-service-in-clojure-part-1-setup/
11:23noncomand lots and lots and lots of them...
11:23noncomclojure people seem to make a particular fan of making web apps with clojure
11:24noncomand database-backed apps
11:24noncomfor there are lots of frameworks, tutorials and examples...
11:24nhllnoncom: sweet, thanks! I'll check those out
11:24noncomnhll: also: https://github.com/oakes/play-clj and https://github.com/oakes/play-clj-examples
12:04sdegutisgfredericks, justin_smith: thanks, I will use ^:dynamic and set!
12:10sdegutisWait I have another idea.
12:10sdegutisIs it possible to use a ref and with-redefs, or something like it, for the purpose of changing the value of a thing per with-redefs regardless of what thread it's called on?
12:12justin_smithwith-redefs only effects the value until the with-redefs block exits, and only effects values inside its scope
12:16Bronsajustin_smith: set! on a thread-local var is actually quite useful from time to time
12:16BronsaI use it internally in some t.a.jvm passes
12:48sdegutisjustin_smith: so I can do with-redefs per request handler in order to create an isolated variable that functions can act on iff it exists?
12:48sdegutisAlthough with-redefs doesn't allow callees to change the value for callers...
12:48sdegutisThat's what I need.
12:49Bronsawith-redefs is not a cood idea in production
12:49Bronsagood*
12:49sdegutisWhy?
12:49clojurebotsdegutis: because you can't handle the truth!
12:50sdegutisclojurebot: try me
12:50clojurebotHuh?
12:50sdegutisclojurebot: short memory eh?
12:50clojurebotGabh mo leithscéal?
12:50sdegutisclojurebot: long term memory loss including lingustic eh?
12:50clojurebotGabh mo leithscéal?
12:50sdegutisclojurebot: seizures eh?
12:50clojurebotCool story bro.
12:50sdegutisclojurebot: master troll eh?
12:50clojurebotPardon?
12:51sdegutisclojurebot: nvm
12:51Bronsastop it
12:51sdegutisShe started it.
13:30c-qjv0xfiIs there a way to mutate a type? Implementing something along the lines of `setFoo` in a deftype
13:30justin_smithc-qjv0xfi: you can make mutable fields, if you check out the doc for deftype
13:31justin_smithc-qjv0xfi: or do you mean mutate the definition of the type itself and not a field of an instance?
13:32justin_smithc-qjv0xfi: setFoo would be a method on some interface or protocol the type implements - otherwise you would use set!
13:32justin_smith(and the implementation of that method would use set! internally)
13:33c-qjv0xfijustin_smith: Thanks.
13:47amalloyjustin_smith: note that if you declare a mutable field you can only mutate it from inside of a method implementation in the type itself - external clients can't
13:57dnolenhttp://swannodette.github.io/2015/07/29/clojurescript-17/
13:57dnolenClojureScript now optional self-hosts
14:02justin_smithamalloy: yeah, that's what I was trying to point to, thanks
14:06keymoneanybody familiar with httpkit?
14:07Jaooddnolen: Is there going to be a standalone nodejs CLJS compiler released?
14:09dnolenJaood: nope
14:09dnolenwe're not spending any more effort than maintaining the cljs.js namespace
14:09dnolenpeople sort all the other problems themselves
14:09dnolens/sort/can sort out
14:15johannbestowrous@dnolen: woohoo thanks to all the contributors in here! <3 <3
14:23drorbemetHi, have you experience with slamhound beeing unstable? Running (slam.hound/-main "file.clj") I am getting stackoverflow errors involving concat and crashing lein-repl process. I would be glad to be able to integrate slamhound into my workflow.I have a Java import (imagej) in the file.
14:23drorbemet even if slamhound edits the file successfully the repl process crashes ... how can I debug this?
14:30Jaooddnolen: got it
14:41jaohmmm, the update to clojurescript 1.7.x just broke cljc tests execution with cljsbuild for me
14:45jaooh, nm, my fault. sorry for the noise
15:04sdegutisIs it very inefficient on memory and/or CPU to store functions in a map to act as an ad-hoc "object"?
15:05sdegutisFor example (let [person {:name (fn [] ...return name somehow...) ...}] ...) ...
15:12amalloydrorbemet: slamhound is pretty old. it wants clojure 1.4, and probably it does run on 1.7 but maybe it can't analyze code that wasn't valid in 1.4? i'm no expert on this but honestly i wouldn't expect it to work
15:24bourbonException in thread "main" java.lang.IllegalArgumentException: No matching field found: split for class java.lang.String
15:24bourbonwhat does that mean, and how do I make it stop doing that?
15:25pbxbourbon, what code throws it?
15:26bourbon (.split (slurp (io/resource "sql/postgres_init.sql")))
15:26bourbonoh - possibly a missing param
15:26mattfromratingsit sounds like a missing param
15:27bourbonyup
15:27bourbonstill getting the hand of the error messages from clojure
15:27bourbonthat was it
15:28drorbemetok, thanks, I will use clj-refactor then if possible
15:53lellishi all
15:53lellisanyone using jenkins to run tests ??
15:53lazybotlellis: Uh, no. Why would you even ask?
15:54lellisi have success runing uberjar from jenkins but not test
15:58sdegutisIs the creation of 10,000 maps with mostly functions as values slow?
16:22sdegutisWow it's insanely fast.
16:23sdegutis,(take 3 (map (partial hash-map :i) (take 100000 (range))))
16:23clojurebot({:i 0} {:i 1} {:i 2})
16:23sdegutis,(take 3 (map (partial hash-map :i) (take 10000 (range))))
16:23clojurebot({:i 0} {:i 1} {:i 2})
16:23TEttingerwell it's only calculating 3 items
16:23TEttingermap is lazy
16:23sdegutisOh right.
16:24TEttinger,(take 3 (mapv (partial hash-map :i) (take 10000 (range))))
16:24clojurebot({:i 0} {:i 1} {:i 2})
16:24TEttingerhm, I have no idea how take works
16:24TEttinger,(nth (mapv (partial hash-map :i) (take 10000 (range))) 900)
16:24clojurebot{:i 900}
16:24TEttingerok yes it is fast :P
16:25TEttingeroutput is the main slow thing on the evalbots
16:25TEttingerit has to go over IRC, etc.
16:25sdegutis,(->> (range) (take 10000) (map (partial hash-map :i)) (map count) (reduce +))
16:25clojurebot10000
16:25sdegutisThis should create all the maps.
16:26TEttingerindeed it does
16:26sdegutisStill fast as lightning.
16:27TEttingeryeah, I'm surprised. I think Java 8 changed the hashing for a lot of internal stuff to be much faster, and clojure changed its hash functions at least once as well
16:27TEttingerI think it's only hashing :i once due to it being a symbol, so it's interned
16:28sdegutisHow do you tell the Java version from a Clojure repl?
16:30wasamasafrom the greeting?
16:30tmtwdis there an equivalent of this: rake db:create_migration NAME=add_messages
16:30tmtwd in migratus?
16:32sdegutiswasamasa: didn't see it due to ad-blindness
16:33sdegutisI like using maps. Very fast.
16:33sdegutisAnd very dynamic.
16:37TEttingermaps are great. I remember someone in here had a really nice project that allows java code to describe data with clojure's syntax instead of, uh... HashMap<String, List<String>> hm = new HashMap<>(); ArrayList blech = new ArrayList(); blech.add("wow."); hm.put("ugh", blech);
16:37OlajydCan somebosdy advice how I can get learn clojure the fast way
16:38Olajydlike a quick guide
16:38justin_smithalready knowing scheme is a huge head start
16:39TEttingerOlajyd: braveclojure seems to cover a lot of ground in good detail
16:40sdegutisOlajyd: no
16:40TEttingersdegutis: https://github.com/rschmitt/dynamic-object was the project.
16:40sdegutisTEttinger: nice
16:41TEttingerbut yeah learning something fast is a great way to learn it poorly. you can get a fundamental basis quickly but you really need to spend some time writing clojure to start noticing patterns in your code and how to improve them
16:41sdegutisTEttinger: neat!
16:41sdegutisCheating, but still neat.
16:42TEttingersdegutis, yeah that rschmitt seems to be quite good with this
16:42TEttingerhttps://github.com/rschmitt/collider
16:42sdegutisYou know, I waver between preferring Haskell and JavaScript. I guess Clojure is a nice middle-ground.
16:42TEttingerCollider has all of clojure's data structures wrapped in a strictly typed form, I think
16:43TEttingeryeah, clojure's a very practical language
16:43sdegutisBut man, some days I just want things to be very simple and use JS.
16:43sdegutisClojure is nice but man oh man, it's.. oh man.
16:43TEttingeryep. those days I usually write java.
16:43sdegutisHuh I didn't even consider that as an option.
16:43sdegutisOh wait yeah I did. I remember. It was a few months ago. Nope, Java still sucks.
16:48TEttingerif you're doing JVM clojure, and you're having a "stupid day," might as well use a language that assumes the person using it might have an IQ on par with ##(reduce * [3 4 (+ 3 4)]), and should be accordingly simplistic even if that person is working with a team of brighter-shining light bulbs.
16:48lazybot⇒ 84
16:51TEttingerwhen java was oak, it was designed for programmers who were average. that probably didn't cover below-average intelligence in the general population when that was termed, because in the early 90s I don't think they let you near a computer if you were just going to break it, those things were expensive :)
16:53TEttingerI think oak's average programmer would be today's relatively competent programmer, but then again, the last time I was in ##java someone asked me to cheat on their homework for them. it was practically the first message I got.
16:54wasamasalol
16:56TEttingerI do think java's getting better as a language, in large part due to "evolutionary pressure" caused by other JVM languages
16:56TEttingerhell, you can actually build OpenJDK 9 with modern tools now, at least that's what they say...
16:57sdegutisSure, all that sounds right.
16:57sdegutisToday I am going to pretend Clojure is JavaScript and just make it work.
17:00TEttingerOpenJDK 7 was a nightmare to even attempt to build on windows, requiring a DirectX download from microsoft that no longer exists, an antiquated microsoft compiler setup, AND Gnu Make.
17:04justin_smithTEttinger: don't forget the live chicken and candles
17:06TEttingerjustin_smith: yeah, OpenJDK 9 now only needs a live housefly and an Oracle-branded lighter
17:31gfredericksdoes anybody have any idea how difficult it would be to get cider to better-support names like foo' ?
17:32justin_smithgfredericks: that's more a clojure-mode thing right? or is there a cider specific issue?
17:32gfredericksI'm not sure that's a lot of what my question is about
17:32gfredericksapparently M-. doesn't work
17:32gfrederickshttps://github.com/gfredericks/test.chuck/issues/13
17:42justin_smithgfredericks: I suspect the fix would be in the regex clojure-mode uses for identifying valid clojure symbols - one moment I'm taking a quick look I know I have read this code before
17:45Bronsacouldnt' clojure-mode just use the same regex LispReader.java uses?
17:48justin_smithgfredericks: Bronsa: here is one of the regexes that would need fixing, you would think there was a proper re-used symbol regex... https://github.com/clojure-emacs/clojure-mode/blob/master/clojure-mode.el#L1053
17:50amalloyjustin_smith: i think you can just edit the syntax table for clojure-mode and leave the regex the same
17:51amalloysince it's using \\sw
17:52justin_smithhmm, there is no entry for symbols - I guess you owuld have to look up the emacs-lisp-mode-syntax-table and modify that
17:52justin_smith(I mean make a modified version for clojure, of course)
17:53amalloyit already inherits that
17:55justin_smithamalloy: what I mean is the definition is inherited from there, so you need to look at the definition it inherits and fix that
17:55amalloyi don't think that's true. you can just tell it that ' is a valid word/symbol constituent
17:56justin_smithbecause a' is not valid elisp
17:56amalloyright, but you're using a modified version of the elisp syntax table already. you just need to add one more modification
17:56justin_smithamalloy: right, and my next step is looking up how symbol is defined right now, that's all I am saying
17:57amalloythe simplest thing is just (modify-syntax-entry ?\' "w" table)
17:57justin_smithdoesn't that break 'a
17:57amalloyafter that M- will work on +', but i don't guarantee that it doesn't break something like 'a
17:58amalloy(modify-syntax-entry ?\' "'_" (syntax-table)) looks like it keeps both working
17:58justin_smithfascinating
17:59amalloysaying you'd prefer it to be an expression prefix but it can be a symbol constituent too
17:59justin_smithyeah, that part of elisp is still black magic to me - very cool that we found a fix
17:59amalloyjustin_smith: i just looked at http://emacswiki.org/emacs/EmacsSyntaxTable
17:59justin_smithgfredericks: ^ I think we can just add that entry to clojure-mode's syntax table
18:00justin_smithamalloy: oh, cool. I got stuck trying to use emacs built in help to find similar info, I should have jumped to the wiki
18:02amalloywell uh, looking at the output of C-h s suggests that my syntax entry doesn't mean what i think it does, so i would not be quite so hasty
18:03justin_smithoh, OK then
18:03amalloyit seems to *work*, but...
19:26ed-gsql supports the concept of +infinity and -infinity for times. Does java/clojure have a similar concept?
19:26amalloy,(/ 1.0 0)
19:27clojurebotInfinity
19:27amalloy,(/ -1.0 0)
19:27clojurebot-Infinity
19:29ed-gI don't see a constructor in https://docs.oracle.com/javase/7/docs/api/java/sql/Timestamp.html that allows those?
19:33amalloyfor sql timestamps? you asked if java has a concept of infinity, not how the sql library handles timestamps
19:33amalloyfrom that constructor it looks like you can't do what you are asking, indeed
19:36ed-gright I was unclear, I meant the concept of a time after or before all others, as opposed to a numeric value
19:41ed-gstrings to the rescue. "-infinity" works so long as I cast it in Postgres.
19:55sdegutisDo binding or with-redefs change the variable per-thread or globally?
19:55sdegutisI see that with-redefs changes it per all-threads.
19:57sdegutisAlso don't let-bindings and similar use {} instead of [] given they act like a map and need to have an even number of elements?
19:57Bronsamaps are unordered
19:58Bronsaand don't allow duplicate keys
19:58Bronsa,(let [a 1 a (inc a)] a)
19:58sdegutisOh right, good point.
19:58clojurebot2
19:58sdegutisAre changes made by binding visible on all threads?
19:58Bronsano
19:59sdegutisJust the calling thread?
19:59sdegutisBeautiful.
19:59sdegutisIs binding or accessing ^:dynamic slow?
19:59Bronsaslower than non ^:dynamic vars
19:59sdegutis:'(
19:59sdegutisDo you prefer to avoid ^:dynamic?
20:00BronsaI use it when I need it
20:00sdegutisWhen do you usually use it?
20:01Bronsausually when I need internal thread-local state or for public library extension points
20:03sdegutisOh okay.
20:03sdegutisI'm determined to hide this database argument.
20:03Bronsathread-local is probably the wrong word
20:04sdegutisThread-visible?
20:04Bronsascope delimited state?
20:08sdegutisSure but not only limited to scope but also thread.
20:09Bronsayes, I'm saying I don't typically use binding for the multi-thread implications
20:14sdegutisI see.
20:16sdegutisIs deref on an atom slow on account of its safety?
20:41justin_smithnot really, but swap! can be expensive especially when retries come into play
20:43sdegutisHmm I wonder.
20:50sdegutisI'll just use an atom to store the database.
20:50scriptor /j #pharen
20:50scriptorgoddamn space
20:52gfredericksjustin_smith: so a pull request to clojure-mode is what's needed?
20:52justin_smithgfredericks: I'd try out that change to clojure-mode locally - I think it will do the trick
20:53justin_smithgfredericks: amalloy came up with it mostly, and he wasn't sure it was correct (but it seemed to work)
20:54gfredericksjustin_smith: oh I see you already commented on the issue; that's about all I was going to do :)