#clojure logs

2014-08-20

00:07lpvbwindow down
00:08munderwoHi all. Im trying to get a random jar into my clojure project. Im not sure what im doing wrong.
00:08munderwohttps://www.refheap.com/89290
00:29sm0ke,(System/currentTimeMillis)
00:29clojurebot1408508973210
00:30sm0ke,(Runtime/freeMemory)
00:30clojurebot#<CompilerException java.lang.SecurityException: Reference To Runtime is not allowed, compiling:(NO_SOURCE_PATH:0:0)>
00:30sm0keok whatever clojurebot, but clojure treats freeMemory as a field?
00:31amalloysm0ke: uhhhhh, no? you're trying to access it as if it were static, but it is not
00:32sm0keugh its not static
00:32amalloy,(.freeMemory (Runtime/getRuntime))
00:32clojurebot#<CompilerException java.lang.SecurityException: Reference To Runtime is not allowed, compiling:(NO_SOURCE_PATH:0:0)>
00:32sm0kecrap getRuntime has to be used
00:32amalloy&(.freeMemory (Runtime/getRuntime))
00:32lazybot⇒ 10343936
00:32amalloyi bet lazybot should be blocking that
00:33sm0ke&(.totalMemory (Runtime/getRuntime))
00:33lazybot⇒ 61341696
00:33sm0kewow so poor
00:34amalloylazybot is run with a reasonably-sized heap. giving multiple gigs to tiny little processes just makes them run worse
00:34sm0kei think i has a moment
00:34sm0keamalloy: how can it make things worse
00:34sm0keits just misuse
00:35amalloyif you let garbage pile up for minutes at a time before cleaning it up, the gc process is long and pointlessly slow
00:35amalloywith a small heap that fills up reasonably quickly, gc is more frequent but much faster
00:36amalloythat's the main issue, but there are probably others
00:36sm0kegc sucks
00:36sm0kei think ruby has far better gc than jvm
00:36amalloythat's possibly the worst language you could have picked. the jvm's gc is excellent compared to like every other language that exists, and ruby has one of the worst
00:36sm0kei remember java user agreement used to have a clause for not using java in nuclear reactors and stuff
00:37sm0kemission critical i.e.
00:37mdeboardtrollin'
00:37amalloy$google java is not for nuclear reactors
00:37lazybot[Java is no good for nuclear power plants - Everything2.com] http://everything2.com/title/Java+is+no+good+for+nuclear+power+plants
00:37sm0kemdeboard: no its a fact
00:37sm0kelook it up
00:37mdeboard:P
00:37amalloythat part's actually true
00:37danielcomptonwhat's the difference between & and , for clojurebot?
00:37amalloyeverything else you've said is pretty misinformed
00:38amalloydanielcompton: try them both, compare what happens, and see if you can figure it out
00:38danielcompton&(+ 1 1)
00:38mdeboardDefinitely a troll. Join the channel right to throwing bombs :P
00:38sm0keamalloy: really is ruby that bad
00:38lazybot⇒ 2
00:38danielcompton(,+ 1 1)
00:38mdeboardBut hey, enjoy
00:38amalloymdeboard: he always does that
00:38danielcompton,(+ 1 1)
00:38clojurebot2
00:38sm0kei think they made huge improvements lately to their gc
00:38mdeboard"Clojure reminds me of hte XBox 360. You take one look at it, do a 360 then walk away"
00:39amalloythat's what i hear too, re ruby's gc. i haven't tried the new one
00:39Claricewhere there's sm0ke there's fire
00:39mdeboard"*awaits comments about how 360 is a full circle*"
00:39mdeboardmaybe i spend too much time on the internet
00:39sm0keClarice: its true look it up
00:39Claricenobody cares.
00:39danielcompton ,(.freeMemory (Runtime/getRuntime))
00:39clojurebot#<CompilerException java.lang.SecurityException: Reference To Runtime is not allowed, compiling:(NO_SOURCE_PATH:0:0)>
00:40danielcompton&(.freeMemory (Runtime/getRuntime))
00:40lazybot⇒ 26988248
00:40ClariceSpeaking of garbage collectors, I've been reading about Azul. Really cool technology.
00:41sm0kei rather buy a 5$ ram than a 1000$ tech
00:41lpvbruby runs on the jvm too
00:42sm0keand your pointis?
00:43Clarice,(kick sm0ke)
00:43clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: kick in this context, compiling:(NO_SOURCE_PATH:0:0)>
00:43Clarice:'(
00:43amalloydanielcompton: have you figured it out yet? if not, here's a hint. pay more attention to who's responding to your eval requests
00:43sm0ketry inc Clarice
00:43danielcomptonamalloy: dur, got it
00:44danielcomptonI can only run my bitcoin miner on lazybot
00:44sm0kereally are people still mining?!
00:45lpvbif people weren't mining, bitcoin would cease to operate
00:45sm0kei heard that bitcoins actually was a product from silk market
00:45sm0kethose people made it for illegal transactions and now all of sudden its legal everywhere
00:46amalloydanielcompton: naw, both bots have plenty of backdoors into eval
00:46amalloybut i bet clojurebot has more free memory for you to mine with
00:46lpvbI'm sorry this is off-topic, I won't discuss this with you further.
00:46joshuafcoleIs there a way to "splat" a list into multiple arg slots of a fn?
00:47joshuafcoleI could do the opposite, apply
00:47sm0keis it? lets make a miner in clojure
00:47sm0ke:D
00:47danielcompton(inc amalloy)
00:47lazybot⇒ 161
00:47joshuafcolebut the function has 4 params and conjing a bunch of unrelated stuff feels less readable to me
00:48sm0keseems like there already is one https://github.com/pelle/bitcljoin
00:48sm0keterrible name though
00:48amalloyi don't understand the question, joshuafcole
00:48sm0kebitcljoin :D
00:49joshuafcoleI have a function which has a rest param. It calls another function with several fixed params and then a rest param. I'd like to just tack the first rest param into the last fn. In Python, a list can be "splatted" into multiple fn parameters
00:49joshuafcoleKind of like call-side destructuring
00:50joshuafcoleI don't know of an analog in clojure, but I figure there's probably something I don't know the right terminology to find.
00:50Clariceyou mean like let [a, b, c] = thatListOrWhatever in f(a,b,c)?
00:50sm0keapply should do that
00:51amalloyi think you probably just want apply. if you can't figure out how to use apply for this, then please paste a more specific function definition so you can get concrete advice
00:51joshuafcoleI could use apply, but there are 3 fixed params before I want to tack the rest param on
00:51amalloy(apply f x y z rest)
00:51joshuafcoleYeah, it's not that I couldn't, just that it doesn't look readable
00:51joshuafcoleOh wait
00:51joshuafcoleapply let's you specify fixed params before the rest?
00:52ClariceNo, but the act of supplying those arguments to f does that.
00:52lpvbjoshuafcole: yes
00:52joshuafcole*checks docs*
00:52amalloyeven if it didn't (it does), it's not hard to use a baby version of apply
00:52joshuafcoleWhoops, now I feel silly
00:52sm0ke,(apply + 1 2 3 (range 10))
00:52clojurebot51
00:52amalloy(apply f (concat [x y z] rest))
00:52joshuafcoleexactly what I wanted built in
00:52joshuafcoleThanks
00:53sm0keseems like clojure has a function for everything
00:54sm0kehey does clojure has a function for finding is a element belongs to a seq ? :P
00:54sm0keheh flame wars
00:58lpvb,(some (partial = 3) (range 1 10))
00:58clojurebottrue
01:00sm0ke,(#{1 2 3 4} 4)
01:00clojurebot4
01:00sm0kedoesnt mean anything
01:01lpvbsm0ke: what doesn't mean anything?
01:02sm0kesince everything in clojure is internally a tree..i think finding an element in a vector can be much more efficient than what you showed
01:03sm0kelpvb: the fact that you cooked up a naive method to do so or i used set's property to find an element
01:03lpvb,(seq? #{1 2 3 4})
01:03clojurebotfalse
01:04sm0ke,(sequential? #{1 2 3})
01:04clojurebotfalse
01:05sm0ke,(instance? ISeq #{1 2 3})
01:05clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: ISeq in this context, compiling:(NO_SOURCE_PATH:0:0)>
01:05sm0ke,(instance? clojure.lang.ISeq #{1 2 3})
01:05clojurebotfalse
01:05sm0keugh
01:08sm0ke,(seq #{1 2 3})
01:08clojurebot(1 3 2)
01:08sm0keevery function which works for seq like conj, cons, works with set
01:09sm0keits amazing that clojure didnt provide a contains? which is also unified across data structures
01:10sm0keoh wait there is a contains but of different sematics
01:10sm0ke,(doc contains?)
01:10clojurebot"([coll key]); Returns true if key is present in the given collection, otherwise returns false. Note that for numerically indexed collections like vectors and Java arrays, this tests if the numeric key is within the range of indexes. 'contains?' operates constant or logarithmic time; it will not perform a linear search for a value. See also 'some'."
01:29joshuafcoleI'm getting an illegal state exception when I try to :use clojure.core.matrix.operators (it's complaining that it's trying to overwrite already bound things like ==, which is the idea)
01:30joshuafcoleHow do I handle that exception?
01:32sm0kedont use it
01:32sm0kei mean require it as something
01:34joshuafcoleWell. Yeah, I could not use it.
01:34joshuafcoleBut I'd rather use it
01:34joshuafcoleIt'd be nice to be able to write (* 10 [1 3 5])
01:34joshuafcolethan having to map and do other silly things for simple vector maths
01:34sm0kethen exclude the those from clojure.core
01:34joshuafcoleI could rename it
01:35joshuafcolebut that's also not quite as nice.
01:35joshuafcoleOh? I'll look into that, but I imagine it's probably a goodly number of operators
01:35joshuafcolethere's really no way to suppress the exception?
01:36joshuafcoleIt really feels more like a warning situation than an exception one in the first place
01:37joshuafcoleLooks like it's only 4 operators in core.matrix, so I'll work with excludes for now. Thanks sm0ke
02:36justin_smithjoshnz: you can (:refer-clojure :exclude [== ...])
02:36justin_smithn/m
02:36joshnzwrong josh :)
02:36justin_smithyeah, I caught that
02:36justin_smithand someone already mentioned what I said anyway
02:58mskoudHi
02:58mskoudShould Compojure routes look like this fx: (GET "/" {{user-email :user-email} :session flash :flash} (home user-email flash)) or am I missing something?
02:59justin_smithit uses standard destructuring, so that looks fine
03:00mskoudIf i need many parameters it is difficult read, but i guess its just to practice...
03:00justin_smithyou can also use keys
03:01mskoudAs far as i can see, keys does not get fx session values.
03:01justin_smith,(let [{:keys [a b c]} {:a 0 :b 1 :c 2}] (+ a b c))
03:01clojurebot3
03:01justin_smithI mean :keys like that
03:01justin_smithlike I said, it's normal destructuring
03:02justin_smithbut no, that wouldn't work in your case since you are digging deeper into session anyway
03:02mskoudok, but thanks.
03:02justin_smith(it would work for getting user-email though, and may be worth it if you needed other keys out of the session too)
03:07sm0kein core.async i can use merge to take from multiple channel, is there something similar to put to multiple channels?
03:12sm0kesomething like a router which can simly do round robin
03:15kitallisanyone had success in running lein-daemon on heroku?
03:26justin_smithdoesn't heroku do its own process management stuff for you?
03:28sm0kesomething just opposite to http://clojure.github.io/core.async/#clojure.core.async.lab/broadcast
03:29sm0keheck, i will do it myself, but that is a plus to have
03:34kitallisjustin_smith, yeah, I was trying to setup a lein-daemon as a separate worker process on heroku
04:11winkhmm, how do I create an ArraySeq easiest?
04:13winknevermind, stupid unrelated error
04:57rafalbudahi,
04:58rafalbudadoes anyone have problems with ClojureScript "auto" compiling option and Sublime Text 3?
04:59rafalbudaI mean, when I issue a "lein cljsbuild auto <name>" command and trying to save (and compile) file I'm working on, I get an error saying that "cannot proceed, another thread is using this file"
04:59mskoudim using sublime 3 (mac) without issues.
05:00mskoudnot using any repl integration though.
05:00rafalbudabut it only happens with ST3 - if I edit in other editor (even notepad, by Total Commander), it works
07:54spradnyeshthe clojure idiomatic way to do A a = new A(); a.foo("foo"); a.bar("bar"); is (doto (A.) (.foo "foo") (.bar "bar"))
07:54spradnyeshwhat is the idiomatic way to do A a = new A(); a.foo("foo"); a.bar("bar"); a.c.cat("cat"); a.c.dog("dog");
07:55llasramWell, public field access isn't that common :-) But:
07:55spradnyesh// assuming that a.c gets created inside A()
07:55llasram(doto (A.) (-> .-c (.cat "cat")))
07:56spradnyeshllasram: that looks correct; let me try that
07:58RandomanI heard this channel is good for programming questions ?
07:58RandomanOr something
07:58llasramWell, Clojure programming questions.
07:58Bronsaif related to clojure, yes
07:58hyPiRionIt's good for Clojure-related questions
07:58spradnyeshllasram: how about a.c().cat("cat") ?
07:58llasramNot good for trolling though
07:59llasramspradnyesh: Pretty much the same thing: (doto (A.) (-> .c (.cat "cat")))
07:59spradnyeshwould (doto (A.) (-> .-(.c) (.cat "cat"))) work?
07:59Bronsaspradnyesh: also (.. a c (cat "cat"))
07:59spradnyeshno no, notice that c is a function that returns an object
07:59llasramNo. The .- is the "new" field-access syntax
07:59llasramspradnyesh: Yes. (.c a) will call the `c()` method of `a`
07:59spradnyeshBronsa: i need to apply multiple functions on the object, so would want to try doto before going to ..
08:00llasramspradnyesh: (.-c a) accesses the `c` field of `a`
08:01llasramAlso I'd recommend against `..` myself. IMHO it's kind of a redundant wart at this point, confusing the language with multiple ways of doing something
08:01spradnyeshllasram: let me repeat my (previously wrong) question
08:01spradnyeshA a = new A(); a.foo("foo"); a.bar("bar"); a.c().cat("cat"); a.c().dog("dog");
08:01spradnyeshnotice that c is a function (w/o any arguments) that returns an object on which i want to call cat("cat") and dog("dog")
08:02Bronsallasram: there's no reason to prefer (-> a .b .c .d) over (.. a b c d)
08:02llasramspradnyesh: Sure. Because `a.c()` becomes `(.c a)`, you can do: `(doto (A.) (-> .c (.cat "cat")))`
08:02Bronsa.. is perfectly fine if all you need to do is chain a bunch of interop forms
08:02llasramspradnyesh: Or `(doto (A.) (-> (.c) (.cat "cat")))` if you prefered
08:03llasramBronsa: I said IHMO :-). It just feels redundant to me.
08:03spradnyeshllasram: isn't (.a c) c.a() ? not a.c() right?
08:03llasramspradnyesh: Correct, but that doesn't appear anywhere in what I suggested
08:04spradnyeshllasram: you said "Because `a.c()` becomes `(.c a)`" above
08:04llasramYes?
08:06spradnyeshanyways, my trouble is not taking the cat("cat") individually; rather it's the whole thingy => calling foo and bar on a, but cat and dog on a.c()
08:06spradnyeshhow can i do this in a single "doto"?
08:07srenatushi there. somehow, neither (use 'mine.core :reload) nor using tools.namespace's (reload) seems to pick up my changed function... pebcak?
08:07spradnyeshi'm not sure if (doto (A.) (.foo "foo") (.bar "bar") (-> (.c) (.cat "cat") (.dog "dog"))) will work correctly
08:07Bronsaspradnyesh: this should work (doto (a.) (.foo "foo") (.bar "bar") (-> .c (doto (.cat "cat") (.dog "dog"))))
08:07Bronsabut I honestly wouldn't write it this way, it's really hard to parse.
08:08spradnyeshthat's why i'm asking what would be an idiomatic way to do this
08:08llasramYeah, you can just call `.c` twice, like in your example. Although w/ proper indentation I think Bronsa's suggestino would actually be okay
08:09BronsaI would (let [a (a.)] (doto a (.foo "foo") (.bar "bar")) (doto (.c a) (.cat "cat") (.dog "dog")))
08:09spradnyeshBronsa: that looks better i think; i'll try that
08:12spradnyeshthat seemed to work; thanks :)
08:12Bronsallasram: I never particularly liked nesting -> and doto more than one level TBH
08:13llasramYeah, it is a little hard to read
08:13llasramBut point-free, man!
08:13Bronsaheh
08:14Bronsauhm, is it really point-free if it uses macro transformations rather than function composition?
08:15llasramNo. So thanks for ruining my "humor"
08:17llasramclojurebot: Bronsa |ruins| *everything*
08:17clojurebotAck. Ack.
08:18Bronsallasram: my pleasure
08:21martinklepschjustin_smith: I'm trying to get your clj-aws-s3 fork working but upload-part (that's used in write-multipart-stream) still contains references to File objects https://github.com/caribou/clj-aws-s3/blob/master/src/aws/sdk/s3.clj#L237 — am I overseeing something?
09:30clgvBronsa?
09:30clojurebotBronsa ruins *everything*
09:31clgv:P
09:39clgvjust for understanding: assume I have a deftype T implementing a protocol P inline. at a call site of a method of protocol P Clojure can insert a direct call to the method the interface corresponding to protocol P provided there is a correct typehint on the first parameter of the call form, right?
09:44llasramclgv: When you say "method of protocol P" do you mean direct invocation of the JVM method in the protocol's corresponding interface, or do you mean calling a function in the protocol via its var?
09:44otfromis clj-webdriver the best things for scripting the testing of sites in clojure or is there something else people would recommend?
09:45Bronsaclgv: kinda sorta; the protofn will always be routed through a Var call
09:46Bronsaclgv: it gets compiled to something like this: (defn proto-fn [this arg] (if (instance? ProtoInterface this) (.proto_fn ^ProtoInterface this arg) (internal-poly-f this arg)))
09:46clgvBronsa: to be more specific, I saw in a Decompiler that a call to the corresponding interface is added, when the correct typehint is used
09:47clgvBronsa: I just wanted a confirmation that this is usually the case
09:47clgvs/usually/always/
09:47Bronsaclgv: clojure will *never* automatically transform (proto-f this) into (.proto_f this)
09:48clgvBronsa: ok let me check if I have an interop call in the discussed code
09:48Bronsaif youre curious, here's the actual bytecode that will be emitted for a protocol function https://github.com/clojure/tools.emitter.jvm/blob/master/src/main/clojure/clojure/tools/emitter/jvm/emit.clj#L565-L597
09:49Bronsait corresponds roughly to the clojure code I gave you a few lines ago, modulo a callsite cache
09:50llasramBronsa: does t.e.j's intermediate Clojure-data representation of JVM bytecode allow subsequent further optimization, or is it just nicer to work with/more abstracted than the raw ASM API?
09:50clgvBronsa: ah right, the pattern you gave is surrounding the direct call
09:51Bronsallasram: there's no infrastructure in place right now for pluggable optimizations on the bytecode representation, but that will happen
09:51llasramcool
09:52Bronsallasram: peephole optimizations are really low priority ATM though, so I can't tell you when that capability will be added
09:52clgvI'd vote for nicer to work with, since it is declarative and you dont need all those ASM visitors in "application code"
09:53clgvthe jvm analyzer used by eastwood still does not like my project although it compiles cleanly ;)
09:54clgv+version
09:54Bronsallasram: I mean, if one really wanted, with-redefs https://github.com/clojure/tools.emitter.jvm/blob/master/src/main/clojure/clojure/tools/emitter/jvm.clj#L22 and you can intercept the bytecode before it gets compiled
09:54llasramhah!
09:54Bronsaclgv: how does it fail?
09:55llasramI was just curious :-). Bringing the compilation times down to those of Hickey's implementation probably should come first...
09:56llasramI am v excited about the project. Wish I had time to contribute, but know my limits
09:56Bronsallasram: yeah definitely, and there's a long way to go until that happens
09:56llasram(inc Bronsa)
09:56lazybot⇒ 43
09:56clgvBronsa: NPE and in a different exception it states that it couldnt resolve a variable which is actually a protocol method
09:56justin_smithmartinklepsch: odd - I wonder if that is from a bad merge from upstream
09:57justin_smithmartinklepsch: is that preventing the upload of the stream?
09:57clgvllasram: damn you ruined the 42
09:58Bronsaclgv: well, eastwood still uses t.a.jvm 0.2.x, I'll upgrade it to 0.5.3 next week, a bunch of bugs have been fixed, hopefully that too
09:58justin_smithmartinklepsch: OK, I am looking at my last merge, and that is an error - you should be able to downgrade to my previous release
09:58clgvBronsa: ha great, I'll wait for the ML announcement ;)
09:59justin_smithmartinklepsch: try switching from 0.3.9 to 0.3.7, sorry for the mistake
10:12martinklepschjustin_smith: thanks, will give it a spin in a bit :)
10:13clgvdid anyone work on a test library that executes the tests in parallel, yet?
10:14Bronsaclgv: I believe test.generative does to some extent
10:16clgvBronsa: I am using test.check lately and it always feels safer to have a lot of runs.
10:31martinklepschjustin_smith: ok, works when using 6226621
10:31martinklepschjustin_smith: would be great to have a more actively maintained s3 lib for clojure
10:39justin_smithmartinklepsch: yeah, I will try to fix that bad merge, it was a messy divergence between my fork and the original
10:40justin_smithcome to think of it, that's likely why the PR was not accepted
10:42martinklepschjustin_smith: I sent a quick mail to james earlier, maybe he's open to other people taking over some of the maintainance work :)
10:47lvhI want to do something else dpeending on whether x is a map, vector or set (it is an arbitrarily nested data structure)
10:48lvh(condp apply the-thing map? (whatever) vector? (whatever)) looks weird
10:48lvhis that how you spell it, or is there a better spelling?
10:48justin_smithis this when we argue about multimethods versus protocols?
10:49justin_smithlvh: clojure has a couple of different ways to nicely express different code running depending on the type of the argument
10:50lvhjustin_smith: Yes, I remember a couple; I'm trying to figure out what's best here :)
10:50lvhjustin_smith: so, the data structure represents a bunch of requests
10:50lvhsometimes, it's a simple e.g. single http request; that's a map (with the request details)
10:50lvhsometimes it's an ordered collection of requests that have to be done in a specific order (vector)
10:50lvhyou can probably guess what a set is :)
10:51justin_smithI'd think for the vector and set, you can just use one case: call seq on either and the result should be fine
10:51Glenjaminset would be parallel
10:51justin_smithcould be, sure
10:51lvhjustin_smith: eh, yeah, so ideally I would do the set in parallel :)
10:51lvhhi oubiwann :)
10:52oubiwann-fnlvh: hello!
10:52oubiwann-fnfunny seeing you here ;-)
10:52oubiwann-fn(not really)
10:53oubiwann-fnlvh: for our last hack day, I taught Clojure to a team of folks, and they spend the whole weekend working on problems
10:53oubiwann-fnthey are *loving* it
10:53oubiwann-fnthey want to migrate Python services to http-kit, etc.
10:53lvhoubiwann-fn: awesome :)
10:54lvhoubiwann-fn: what is the difference between oubiwann-fn and without -fn
10:54Glenjaminone is a macro.
10:54oubiwann-fnGlenjamin: haha
10:54oubiwann-fnwell-said
10:54oubiwann-fn-fn is my work machine (I'm in the office right now); the other is my home machine
10:54oubiwann-fn(no bouncer set up yet)
11:16jlongsterhey guys, I was reading over the core.async announcement, and saw this sentence about (timeout): " A nice aspect of this is that timeouts can be shared between threads of control, e.g. in order to have a set of activities share a bound."
11:17jlongsterbut only one thread can `take` the value, right? so how is it shared?
11:17Glenjaminjlongster: you can use (alts) with multiple actions including a timeout to get that effect
11:17Glenjamins/actions/channels/
11:18jlongsterGlenjamin: right, but that sentence led me to believe I can pass a single timeout channel to multiple threads, which all do the alt thing
11:18dnolen_jlongster: there's a timeout queue
11:18jlongster(obviously that's wrong)
11:18dnolen_"threads of control" doesn't mean real threads
11:18jlongsteryeah, I meant threads in the abstract sense
11:19jlongsterdnolen_: explain the timeout queue a little more?
11:19dnolen_jlongster: yes if the delta of a timeout channel is within a certain bound it will be bound up with another timeout about to dispatch
11:19dnolen_currently hardcoded to 10ms
11:19dnolen_so if you (timeout 1) and there's a pending (timeout 10), you will dispatch with that one
11:21jlongsterdnolen_: interesting, thanks.
11:22dnolen_jlongster: the code is relatively straightforward https://github.com/clojure/core.async/blob/master/src/main/clojure/clojure/core/async/impl/timers.clj#L43
11:22dnolen_the CLJS version looks more or less the same 'cept I had to write a SkipList from scratch
11:22jlongsternice!
11:22jlongsterit's CSP code, of course it's straightforward
11:23jlongsterdnolen_: I don't think that's what the original sentence was refering to, but now you have me interested
11:23jlongsteris this just an optimization or does it solve a problem?
11:24dnolen_jlongster: the sentence describes exactly what this code does
11:24dnolen_two different threads of control will share a timeout dispatch
11:24dnolen_jlongster: optimization
11:25jlongsterdnolen_: ah I get it now
11:25jlongsterthis makes sure that they are coalesced into the same dispatch
11:25dnolen_jlongster: yep
11:26dnolen_jlongster: now that you're on the JS-CSP thing you should convince them to support transducers ;)
11:26jlongsterbut each of them still has separate timeout channels
11:26dnolen_jlongster: yes
11:26jlongsterdnolen_: oh I want to, one step at a time though :)
11:26jlongsterhaven't studied transducers (or even reducers, but I get them abstractly)
11:27jlongsterI'll probably start writing some small projects in Clojure honestly, I'm so close
11:27dnolen_jlongster: it's pretty awesome, no extra async blocks just to get sequence like behavior
11:27dnolen_so you can map/filter/take/partition etc. a channel w/ a go block for each step
11:28dnolen_w/ -> without
11:28jlongsterdnolen_: that's awesome. I was noticing those problems with js-csp right when transducers was released
11:28jlongsterso definitely going to look at them
11:29dnolen_jlongster: yeah it's huge IMO.
11:29dnolen_you can have huge event processing pipelines w/ no overhead
11:30jlongsterdefinitely need to study it, I don't understand yet but it's fun to learn
11:30jlongsterso many iteration libs in JS and they all embrace raw generators/promies/etc and it's all so messy. we need to get on the right track.
11:31jlongsterit's like people don't even look around at other languages
11:32dnolen_jlongster: yep, anyways transducers are language agnostic will work anywhere you have first class functions - look forward to see people use them over lazy seqs (immutable-js looking at you)
11:33jlongsterdnolen_: cool! gozala has already ported reducers, but I haven't looked at it yet: https://github.com/Gozala/reducers
11:33jlongsterdoes seem like a ton of extra function allocations, but need to study
11:33dnolen_jlongster: yeah transducers really subsume reducers and are more generally applicable
11:33dnolen_jlongster: can't use reducers w/ channels
11:35jlongsterI thought transducers took a `reducer -> reducer` function? or is `reducer` just a more abstract name
11:36dnolen_jlongster: nothing to do w/ reducers directly - just an abstract name
11:36jlongsteroh, that's great then
11:36jlongsterdnolen_: can you use them with the lazy seqs in mori?
11:36jlongster(out of the box support, I mean)
11:36dnolen_jlongster: haven't exported them yet, but yes planning on that - should just work
11:37jlongsterwoo, cool. I think one of my future posts is going to be the mori+react stuff. people have been dancing around it but nobody's really done it.
11:37jlongsterdnolen_: did I tell you at JSConf that I'm pitching a rewrite of the Firefox debugger to use React?
11:37dnolen_jlongster: transducers work with everything and more, in fact you can finally use the standard lib on primitive arrays
11:38jlongstercool!
11:38dnolen_(transduce (comp (map inc) (filter even?)) #(do (aset %1 %2) %1) #js [] #js [1 2 3 4]) -> [2 4]
11:38dnolen_no intermediate seqs
11:39jlongsterwow, neat
11:41dnolen_(chan 1 (comp (map inc) (filter even?))
11:41dnolen_also just works, and channel that increments it input and drops even numbers
11:41dnolen_s/and/a
11:42jlongsteryeah, I definitely want that
11:42jlongstergot a few more things to research first :)
11:54jlongsterdnolen_: sorry to ask again, but looking at the code it looks like the timeout stuff does all happen on a single channel; here it gets the existing channel https://github.com/clojure/core.async/blob/master/src/main/clojure/clojure/core/async/impl/timers.clj#L49
11:54jlongsterbut multiple threads of control can't take from the same channel, right?
11:54jlongsterI thought only one of them would get the value if that happened
11:55bbloom_jlongster: read the doc string "will close after msecs"
11:55bbloom_jlongster: and https://github.com/clojure/core.async/blob/master/src/main/clojure/clojure/core/async.clj#L97-L99
11:55jlongsterbbloom_: ooh so it works by closing, duh, thanks
11:55bbloom_"will return nil if closed"
11:55jlongsteryeah, thanks
11:56jlongstermakes sense
12:11clojerWith core.async can Clojure scale horizontally as easily as Erlang, ie. just add boxes to cluster and PIDs indistinguishable whether local or remote?
12:11martinklepschI want to run something each time I start a repl to setup logging — I tried with :injections but I don't think they're the right thing
12:13rweirclojer, core.async isn't that high level
12:15mdrogalisclojer: No, different use case.
12:15dnolen_jlongster: that's awesome re: dev tools!
12:16dnolen_jlongster: I don't think you said that, but Nick Fitzgerald was asking me curious questions about the Mori license
12:17jlongsterdnolen_: we'll see how it goes, but it's a mess of tangled DOM stuff right now. and others on the team have started looking at it
12:17jlongsterI think fitzgen was actually thinking about something with the memory profiler regarding mori
12:18jlongsternot sure about the licensing stuff
12:18lvhI'm playing with core.async in the repl; is there a way to stop (<! c) from blocking if you know it'll never return due to a bug?
12:19lvh(other than "write a convenience function that alts! over a timeout & that)
12:19Glenjaminis take! suitable?
12:19lvhthat returns nil, right?
12:20lvhI guess I could do (take! c prn)?
12:22clojermdrogalis: In what sense? Which use case?
12:23mdrogalisclojer: core.async is for async event handling on a single box, it doesn't make any attempt to work over a network.
12:23mdrogalisYou can use it in combination with something like websockets, queues, or ZooKeeper though.
12:23clojerrweir: I thought core.async was based on Go's CSP implementation, similar to Erlang's green threads?
12:23mdrogalisBut it's not going to be as "fluid" as what Erlang gives you for actors.
12:24mdrogalisclojer: Correct. It's strictly a local mechanism in this case, though.
12:24rweirclojer, that doesn't get you a network-transparent process model
12:24rweirclojer, it gets you a very nice way to write async code
12:24clojermdrogalis: Does Clojure have another library suited to the kind of thing Erlang is good at?
12:24clojer.. ie. horizontal scaling.
12:25mdrogalisclojer: Nothing out of the box, but you might try something like Storm or Cascalog.
12:26clojermdrogalis: Sounds like a Clojure on BEAM would therefore be interesting.
12:26lvhclojer: LFE is close already :)
12:27technomancyLFE is not close
12:27technomancyjoxa is close
12:27clojerlvh: LFE seems different.
12:27technomancyLFE is a lisp-2, so not very good for FP
12:27mdrogalisHaha
12:27Jaoodclojer: check out pulsar
12:27clojertechnomancy> joxa is close
12:28clojertechnomancy: Has a look at Joxa but you can't even use core functions with 'require' ing core and then prefixing everything joxa.core/
12:28technomancyit's also not under active development
12:29clojertechnomancy: Yes, much smaller community than LFE
12:29mdrogalistldr stick with Erlang for those kinds of problems IMO
12:29technomancywell, you have to at least start with Erlang
12:29clojertechnomancy: Shame really as the creator had the right idea.
12:30technomancyonce you're an erlang pro, playing with joxa etc, would make more sense
12:30technomancybut if you don't understand the context from which it comes you won't get far
12:30clojertechnomancy: Decent size community with libs matters so Joxa won't probably cut it for me.
12:30technomancywell
12:30technomancycommunity is one thing, libs is another
12:31technomancyI feel like you could get really far just using erlang libs
12:31technomancybut full ack on the community angle
12:32clojerJaood: Have you used Pulsar? I heard it was similar to Erlang's green threads.
12:33Glenjaminit's still within a jvm afaik
12:36Jaoodclojer: no, started with core.async instead since I can reuse it in cljs
12:37Jaoodbut yeah, their description is Erlang-like actors for Clojure
12:38clojerJaood: Yes, it has the same stack-per-process model. Excellent.
12:39clojerJaood: Still seems to be going strong. I thought it had been supplanted by core.async but I now learn they're different.
12:39technomancyany system that is described as erlang-like is a long way away from erlang
12:40clojerJaood: So I can have my Erlang cake and eat it in Clojure :)
12:40technomancyunless they describe it as OTP-like, and even then I'd be extremely skeptical
12:40mdrogalisI wonder what Erlang cake tastes like.
12:43justin_smithmdrogalis: clearly it is distributed among many guests
12:50mdrogalisjustin_smith: Heh
12:58lvhhow do you spell "take everything from this channel and dump it in a vec"?
12:59lvh(<!! (into [] ch)) ?
12:59hiredmanI dunno, but I doubt that is a good idea, what are you actually trying to do?
12:59bbloom_lvh: into operates on reducables, which channels are not, also <!! operates on channels, which a vector (the return value of into []) is not
12:59lvhbbloom_: Sorry, I mean core.async's into
13:00lvhbbloom_: (which returns a channel and works on a vec and a chan)
13:00lvherr, col and a chan
13:00bbloom_lvh: heh, i had no idea that was there
13:00lvhhiredman: repl debug my core.async using code to see what its putting on this channel
13:00bbloom_i guess i haven't been keeping up with core async's changes
13:02hiredmanlvh: channels aren't really collections in the normal sense, they are synchronization primitives (you can sort of view them as collections smeared out over time kind of), but treating them as a mutable collection that you can just pour in to another collection seems questionable
13:03lvhhiredman: well, sure, but I want to see what my code is putting on this collection
13:03lvherr, channel
13:03lvhthat sounds like a reasonable test question?
13:04technomancyspeaking of smearing something over time, I was just thinking of this yesterday as I was falling asleep
13:04technomancywhat if you had a record type that was aware of all other versions of it that existed in the past and knew how to translate between them?
13:05technomancyyou could keep separate subtrees of dependencies that had old versions of your type and could interop with other versions of itself, and you could easily support hot-upgrades in-place even better than erlang
13:06hiredmanlvh: sure, you can just spin out a thread that grabs a value from the channel and prints it
13:06technomancyyou could also make records that could be reloaded and still have their instances be equal to other instantiations with the same definition from a previous reload, which is one of the biggest wtfs with records currently
13:06ahoenigmannhow to a reload/restart cider in emacs?
13:06technomancyahoenigmann: M-x apropos cider.*restart
13:07lvhif I ran a blocking take! in a cider repl that will probably never finish, can I cancel it, or do I have to restart cider?
13:07justin_smithtry C-c C-c
13:07justin_smith(in the repl buffer)
13:08lvhjustin_smith: thanks! of course Ir ead that after I axe the process...
13:08lvhwill try next time I screw up
13:09ahoenigmannwhen I press space the command buffer inserts a dash “-“
13:09ahoenigmannbetweeen apropos and cider
13:09justin_smithapropos <return> cider.*restart
13:10justin_smithto leave out the <return> is a common emacs shorthand when describing an interactive command
13:10justin_smith(commands cannot have spaces in them)
13:10justin_smithand don't take arguments in that way
13:11Jaoodcider-restart has never worked for me
13:12technomancyJaood: iiuc it behaves differently depending on the current dir
13:13Jaoodtechnomancy: oh really, I always get connection refused
13:29PigDudeoh 300-line stacktraces, how i love to scroll thee. another day in paradise
14:31ahoenigmannHow do i jump to a function definition? (running cider)
14:32amalloyM-.
15:04fifosineI have a vector with keywords to values. Is there a function that will return the value associated with a key similar to using get with a map?
15:05gfredericksfifosine: why do you have such a thing? it sounds like you want a map.
15:06gfredericksit's also not clear if you mean [:foo 1 :bar 2] or [[:foo 1] [:bar 2]]
15:06mdeboardI thought you could use get with vectors
15:06justin_smithget by index
15:06mdeboardoh right
15:06justin_smithmaybe you want a sorted-map
15:06justin_smithor sorted-map-by
15:06fifosinegfredericks: It's what's returned to me from instaparse lib
15:06amalloy(or possibly something else altogether, gfredericks: "a vector with keywords to values" is super-vague)
15:07fifosinelooks like this: [:S
15:07fifosine [:AB [:A "a" "a" "a" "a" "a"] [:B "b" "b" "b"]]
15:07fifosine [:AB [:A "a" "a" "a" "a"] [:B "b" "b"]]]
15:07gfredericksfifosine: instaparse supports transforming things, so I suggest you use that feature to make the data look how you want
15:07fifosineok
15:07gfredericksamalloy: yeah looks like it is something else :)
15:08amalloyfifosine: suppose you had a function f, which acted like (f '[:AB [:A x] [:B y]]) => '[:A x]
15:08amalloythat function would not be generally useful, because what does it do with (f '[:AAB [:A x] [:A y] [:B z]])?
15:09amalloyyou have to be able to ask a more specific question than "what is the value at :A", because there can be more than one
15:30sdegutisWhat's the name behind the story of the "ring" library?
15:31mdeboard?
15:31mdeboardYou mean story behind the name?
15:31amalloymdeboard: the name behind the story is the lord of the rings
15:32mdeboardweird
15:32mdeboard"name behind the story" makes my head hurt
15:32mdeboarditching behind my eyes
15:32amalloywell, mostly because it doesn't make sense
15:33sdegutisThanks in advance.
15:34fifosineCan I perform destructuring in a function definition like so: (fn [[a b] [c d]] …)?
15:35bbloom_fifosine: why don't you try it?
15:35bbloom_you've got a repl, right? :-)
15:35sdegutisDoes anyone know.
15:36sdegutisIs it related to "Rack" that exists for Rails. Thank you?
15:39sdegutis!guards
15:40sdegutis~guards
15:40clojurebotSEIZE HIM!
15:40sdegutisAh, clojurebot.
15:42cespareI can get around private by using #'ns/var but how can I emit this from a macro?
15:42sdegutis,(def a #'if)
15:42clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve var: if in this context, compiling:(NO_SOURCE_PATH:0:0)>
15:42arrdemcespare: resolve can get you the backing var from a fully qualified symbol.
15:42mdeboardsdegutis: It is an homage to the black plague that rampaged through Europe in the dark ages. its hallmark was a rosey, ring-shaped rash.
15:43mdeboardRich Hickey lost many close friends & relatives in the Black Death and so he vowed that his programming language would have a network adapter library to stand as eternal testament to their memory
15:43mdeboardAnd now you know... the rest of the story.
15:43arrdemI KNEW Rich was an Ancient... no mere mortal...
15:44mdeboardHe's a highlander
15:44sdegutismdeboard: Thank for you providing me the story behind the full name.
15:44mdeboardHe had to behead Don Knuth
15:44arrdemmdeboard: lol
15:44mdeboardsdegutis: np
15:44mdeboardI know what you're thinking... "But Don Knuth is alive!" Well, that's what they WANT you to think.
15:45sdegutisThanks in advance.
15:45arrdemmdeboard: so... will The Art of Computer Programming ever be released in full? :P
15:46raekcespare: you could also generate (var ns/var) or (const 'var (symbol the-ns the-var)) from the macro
15:47mdeboardit already has, hidden in plain sight, spread throughout the world's grandest libraries, guarded by an ancient order of warriors sworn to its protection.
15:47raekclojurebot ,(read-string "#'ns/var")
15:48raeker.
15:48raek,(read-string "#'ns/var")
15:48clojurebot(var ns/var)
15:48raekthe #' stuff is just syntactic sugar
15:48amalloyraek: there's never any need to write (read-string "#'ns/var") to demonstrate syntactic sugar. just write '#'ns/var; the reader gets applied
15:49sdegutismdeboard: You are a fine bard.
15:50sdegutismdeboard: Blease change your nick to mdebard.
15:50mdeboardWell, since you said Blease
15:53amalloy,(let [v 'test] `(foo #'~v))
15:53clojurebot(sandbox/foo (var test))
15:54amalloy(point being, cespare, that you can just write what you'd write anyway, with the ~ in exactly the place you'd expect to put it, and it emits what you expect)
15:54cespareamalloy: yep, i realize my problem is that I don't understand how to refer to a private atom
15:54cespareonly a private fn
15:55amalloycespare: well, the easy way would be to not make it private to begin with, if you're having to write macros that refer to it anyway
15:55amalloyprivate is not all it's cracked up to be
15:55sdegutismdeboard: Thanks in advance.
15:55mdeboardsdegutis: np
15:55cespareamalloy: the macros are not for that purpose
15:55sdegutis:)
15:55devnif this hasn't made the rounds: https://github.com/Dobiasd/programming-language-subreddits-and-their-choice-of-words
15:55devnspecifically this: https://github.com/Dobiasd/programming-language-subreddits-and-their-choice-of-words/raw/master/img/happy.png
15:55cespareamalloy: it's incidental
15:56amalloyinteresting, devn
15:56sdegutiscespare: Check out the book Mastering Clojure Macros, it's a great way to master macros in Clojure.
15:56cesparehere, i'll write up what I'm trying to accomplish and I'm sure someone can explain a better way
15:58amalloyit looks like visualbasic (or maybe objectivec?) has a higher helpful/volume ratio than any other sub. i wonder why
15:58sdegutiscespare: I can't recommend the book Mastering Clojure Macros enough if you're dealing with macros.
15:58mdeboardshared misery builds close relationshits
15:58mdeboardships*
15:58sdegutiscespare: http://pragprog.com/book/cjclojure/mastering-clojure-macros
16:05SegFaultAXHaha relationshits.
16:05SegFaultAXThat's fun to say: relationshits.
16:06cespareok, question: https://gist.github.com/cespare/6f966059a1b49f3f437c
16:07mdeboardthat's not a question
16:07mdeboardthat's a hyperlink
16:07mdeboardthere are embedded questions
16:07cesparemdeboard: did you manage to figure it out anyway?
16:08mdeboardcespare: Looks like a protocol might be better fight
16:08mdeboards/fight/fit
16:08cesparemdeboard: type is e.g. a record type, not an actual instance of that type
16:08cespareso I didn't see how a record applied
16:09cespare unless I wanted to change the API so the caller creates a dummy instance and passes that in
16:09mdeboardI see
16:09cesparemdeboard: fwiw the opposite operation (serialize type -> bytes) is implemented as extending a protocol
16:09mdeboardDoes this really allow arbitrary types?
16:10cesparemdeboard: no, just a small list
16:10cesparedefined by the user though
16:10mdeboardAh
16:11amalloycespare: i mean, the most minimal change is to emit @#'ns/var
16:12amalloyi'm with mdeboard, though, you want a Parser protocol, so that someone just hands you a Parser object
16:12cespareamalloy: i don't follow
16:12cesparethe user doesn't have a parser object
16:13mdeboardIt seems like the internals of the macro would basically have to be a protocol
16:13mdeboardright?
16:14amalloythey have a "type". instead of passing you this "type" thing which exists only to be a key in some mutable map, they pass you an instance of the Parser protocol for the type they want to parse
16:14cespareamalloy: it absolutely doesn't exist to be a key in the map
16:15cespareit's like (defrecord Foo [...]) (gen-parsers Foo) and now you round-trip with (parse Foo (serialize (->Foo ...)))
16:17amalloyso why do you say (parse Foo ...) instead of (parse foo-parser), where foo-parser is (FooParser.), either inlined or defined ahead of time
16:17cesparewhy should the user know about FooParser
16:17amalloybecause they are asking you to parse a foo
16:17amalloyseems pretty reasonable
16:18sdegutisCan someone recommend a good book for Clojure macros please.
16:18sdegutisThanks.
16:18cespareyou can apply that argument to expose any internals you want
16:18arrdemsdegutis: besides the one you were spamming ten minutes ago?
16:18sdegutisarrdem: Oh I thought you had me in permanent-ignore.
16:18arrdemsdegutis: well you're headed back there rather fast..
16:19mdeboardlol
16:19mdeboardsuch drama
16:19amalloycespare: defining a private mutable map and then creating macros that modify it is much grosser and internal than asking for a foo-parser to parse a foo
16:19mdeboardNow now, he said I was a good bard
16:19cespareamalloy: meh, i think the API is nicer.
16:20mdeboardMaybe but your code to maintain that API is going to be really... tough to maintain
16:20amalloyi mean, you're entitled to think so. i already said how to solve the problem in your existing API, so if you don't like my proposed API why are you still arguing with it?
16:20cespareit's an interesting discussion?
16:21cesparethanks for the solution :)
16:21llasramcespare: How is parse-from-bytes not literally a multimethod?
16:21mgaarecespare: it seems like your original was a re-implementation of protocols
16:21mdeboardwow, I said something right?
16:21mdeboardnice.
16:21cesparellasram: because you give it the type you want it to create, not an instance of that type
16:21cesparemaybe i'm misunderstanding though
16:22mdeboardcespare: How does it create the type?
16:22amalloyyes, good point, llasram. it's exactly a multimethod
16:22amalloy(not a protocol)
16:22mdeboardI almost said multimethod so I'm still counting this as a win
16:22mgaareoh, right, I was reading it backwards
16:22llasramcespare: multimethods can dispatch on anything. You can call it with a class, and use that class as the dispatch value
16:22amalloyi still argue it would be reasonable for it to be a protocol instead, but as-is it's a multimethod
16:22mdeboardmultimethods are protocols anyway in the general meaning of the word :)
16:23cesparellasram: ah yup, I think a multimethod works
16:23cesparethanks
16:23virmundiHello. I've got a question about how ^dynamic works when compiled/transformed into Java. Then rebound, it a threadlocal modified?
16:24hiredmanwhat do you mean by rebound?
16:24hiredmanif bound using binding it creates a threadlocal binding
16:24hiredmanbut only using binding
16:25virmundiOk. So how does one reset the threadlocal?
16:25hiredmanwith-redefs, def, declare, alter-var-root, etc are all not thread local and operate on the var root
16:25amalloyhiredman: it's not a real java.lang.ThreadLocal, is it? that might have been the question virmundi was asking
16:26hiredmanvirmundi: binddings established with binding obey a stack discipline and are popped when you leave the dynamic scope of the binding
16:26hiredman,(def ^:dynamic x 1)
16:26clojurebot#'sandbox/x
16:26virmundiI'm starting to see. What I'm worried about is the code here
16:26virmundihttps://github.com/edlich/clarango/blob/master/src/clarango/core.clj
16:26hiredman,[(binding [x 2] x) x]
16:26clojurebot[2 1]
16:27Bronsaamalloy_: it uses a ThreadLocal to store the current Frame
16:27hiredmanvirmundi: looks terrible
16:28hiredmanvirmundi: def inside a function body is always a red flag
16:28virmundiQuick side question, would a more Clojure-eque way be to take the connection map with each call?
16:28virmundiThat's what the JDBC api does.
16:28hiredmanyes
16:29virmundiI might try making my own ArangoDB drive to learn clojure. The dynamic there scared me. It really scares me since I want to move from ring.adapter.jetty to the new Comsat adapter once parallel universe comes out.
16:30virmundiBut, hiredman, I appreciate your help. I like to understand what's going on under the covers. Thanks.
16:31hiredmanvirmundi: are you actually experiencing a performance problem with jetty?
16:32stuartsierrahttps://github.com/edlich/clarango/blob/67b0745290f18b119b1f04b9a80d0d6ab6c90bba/src/clarango/core.clj#L9 is a mis-use of `def` that has a global, not thread-local, effect.
16:34Jaoodhiredman: you know why the jetty version hasn't been bump up in the jetty adapter?
16:46reiAre there any articles or examples of defmulti/defmethod? Particularly with more than one argument. All examples I see online are either one argument or a map.
16:55SagiCZ1i have this question which concerns all dynamically typed languages.. in java if i have method foo(Type1 t1, Type2 t2) there is no way i can call it with bad parameter types.. but lets say i have clojure function (foo [m l] ...) and i expect "m" to be map and "l" to be list and treat them as such.. how can i force the caller of this function to use correct types when calling it? this can be a source of very hard to find bugs.. especia
16:56arrdemSagiCZ1: you can't force the caller to do anything... but you can use preconditions to check your arguments either manually or with Schema or something.
16:56SagiCZ1arrdem: so that would be somewhere in "require:" ? can i check the parameter types there?
16:57SagiCZ1,(fn? (fn [] 5))
16:57clojurebottrue
16:57puredangerrei: here's a couple in tools.analyzer https://github.com/clojure/tools.analyzer/blob/master/src/main/clojure/clojure/tools/analyzer/ast.clj#L44
16:57SagiCZ1,(list? '(1 2 5))
16:57clojurebottrue
16:57llasramrei: There's no real magic... The `defmulti` dispatch function just needs to have all the arities you want to support and return a dispatch value. The implementations just accept the appropriate arities as wel
16:57arrdemSagiCZ1: in your namespace form you can't do typechecking if that's what you're asking...
16:57mgaareSagiCZ1: there's an example here: http://onclojure.com/2010/03/05/pre-and-post-conditions-a-quest-for-a-nicer-syntax/
16:57SagiCZ1arrdem: but why doesnt clojure do this automatically?
16:58arrdemSagiCZ1: because Rich is a believer that types should truly be optional and for performance only
16:58postpunkjustinSagiCZ1: because it's dynamically typed?
16:58arrdempostpunkjustin: dynamically checked, statically typed.
16:58mgaareSagiCZ1: you can also use clojure.core.typed if you have a lot of time on your hands
16:58arrdemif typed at all..
16:59lpvbSagiCZ1: if you want a very strongly typed functional language look at haskell
17:00mgaareSagiCZ1: using preconditions will give you run-time checking. clojure.core.typed will give you compile-time checking
17:00SagiCZ1i am not trying to go against clojure philosophy or Rich's ideas and i am not trying to find another language.. but i dont understand how can i reduce the bugs that come from calling a function with parameters in bad type or order
17:01SagiCZ1mgaare: run type checking is fine.. i guess i will look into preconditions then
17:01mgaareyou can also use assertions wherever you want
17:01SagiCZ1whats the difference between precondition and assertion?
17:01Bronsapreconditions are syntactic sugars over assertions
17:01Bronsasugar*
17:03SagiCZ1alright and if i wanted to hear some personal experience with them? do you guys use preconditions everywhere or nowhere? do you get bugs from wrong parameters passed into functions?
17:03mgaarefor me, almost nowhere, and yes I do :D
17:03SagiCZ1:D
17:04BronsaSagiCZ1: honestly I use plain assertions over preconditions, because with preconditions you have no control over the thrown message
17:04SagiCZ1i guess i will get something like "Long cant be cast to IFn" ......... thanks Rich........
17:04postpunkjustinSagiCZ1: I use preconditions a lot, especially if I know I'm going to be doing some heavy refactoring or if I have weird bugs.
17:04SagiCZ1Bronsa: so it throws messages? does it stop the execution?
17:04SagiCZ1postpunkjustin: thanks for input
17:04BronsaSagiCZ1: yes it throws an exception
17:05arrdemSagiCZ1: I tend to write a comment including a type signature before I write a function body... depending on my exhaustion level and the context of the code I may or may not build preconditions.
17:05SagiCZ1Bronsa: runtime right? clojure always throws runtime IIRC
17:05Bronsayes, runtime
17:05reipuredanger: Thanks!
17:05SagiCZ1(doc assert)
17:05clojurebot"([x] [x message]); Evaluates expr and throws an exception if it does not evaluate to logical true."
17:05BronsaSagiCZ1: as somebody already said, use core.typed if you want compile time type safety
17:05reillasram: Yeah, that's what I thought, but I can't get my code to work despite that.
17:05SagiCZ1Bronsa: runtime type safety is enough for me
17:06SagiCZ1,(assert "my fail message" true)
17:06clojurebotnil
17:06SagiCZ1see what i did there?
17:06llasramcute
17:06SagiCZ1,(assert true "my fail message")
17:06clojurebotnil
17:06SagiCZ1 ,(assert false "my fail message")
17:06clojurebot#<AssertionError java.lang.AssertionError: Assert failed: my fail message\nfalse>
17:07BronsaSagiCZ1: honestly I don't even use `c.c/assert`, I manually (if condition (throw (ex-info ..))), that way I can attach info on the exception that I can inspect
17:07amalloy_yeah, assert is just not useful
17:07SagiCZ1amalloy: hi.. how come?
17:07llasramIt's okay for debugging sometimes
17:07SagiCZ1Bronsa: isn't that a bit tedious? :(
17:08puredangerassert states documentation of developer intentions in the form of a runtime check
17:08hiredmanI do use assert, a lot
17:08SagiCZ1puredanger: sounds good to me
17:08puredangerit's a bad way to communicate to a user though
17:08BronsaSagiCZ1: (assert (vector? x) "arg x is not a vector") doesn't let me inspect what x was
17:08SagiCZ1Bronsa: I see the problem now
17:08Bronsa(if-not (vector? x) (throw (ex-info "arg x is not a vector" {:arg x}))) does
17:09hiredmanI tend to drop (assert nil) at the end of conds and ifs as I building something out if I haven't built that side of the conditional yet
17:09amalloyBronsa: to be truly counter-culture: (clojure.test/is (vector? x))
17:09hiredmanas I am
17:09SagiCZ1Bronsa: can you not attach the "x" to the assert message?
17:09BronsaSagiCZ1: it forces you to attach it as a string
17:09hiredmanthere is a jira issue about making assert carry the lexical environment around
17:09Bronsawhat if it's a deeply nested map that I need to inspect to understand what's going wrong?
17:10lpvbIs there really a point to checking the arg types? For a language like clojure I think the arg types should be specified in documentation
17:10Bronsaamalloy: ew
17:10SagiCZ1Bronsa: i see.. i cant imagine how would i inspect that anyways though
17:10hiredmanwhich is an interesting idea, but can lead to bugs, slingshot did/does that and you can end up holding on the head of seqs that way
17:10BronsaSagiCZ1: ex-data
17:10amalloyhiredman: ughhhhh, really? that's a really dangerous thing that causes problems in slingshot
17:10hiredmanamalloy: right
17:10SagiCZ1lpvb: even if they are specified what if the caller makes a mistake?
17:10amalloybecause you end up closing over infinite sequences and then trying to print them
17:10amalloyoh, i see you said that too
17:10amalloywell done, us
17:10lpvbSagiCZ1: then the caller should read the documentation and fix it, it's not hard to re-run the function in the repl
17:11hiredmango team venture
17:11SagiCZ1lpvb: i know but it could even run fine just with weird results..
17:11Bronsahiredman: I've started placing exceptions on not-finished code paths too lately, it's a good way to make sure you don't forget to implement something
17:12SagiCZ1i need like a twitch stream of you guys developing so i can see how its done :D
17:12amalloyBronsa: only works if that code path is actually exercised, though
17:13hiredmanit is a sort of walking skeleton approach
17:14mgaareis there a good resource for clojure livecoding videos?
17:14hiredmanyou get something that compiles and runs, but if you anything it explodes
17:14hiredmando
17:14Bronsaamalloy: I can always throw an exception at the top-level for extra safety
17:14Bronsa(ns foo ..) (assert nil "FIXME you dumbass")
17:14amalloymgaare: not really. record a video of yourself coding, so that the next guy who asked that question will get a "yes" answer
17:15mgaareI've seen a handful here and there
17:15amalloyBronsa: when i want to do that i just embed illegal code in the middle, so that it doesn't even compile. (cond x y, a b, TODO fix this what now)
17:15hiredman:(
17:15amalloybut obviously that has its own issues
17:16technomancywhen I did rubby I would just add `raise Hell`
17:16technomancy(which was not defined)
17:17mdrogalisHa
17:22mdeboardIf I was going to create an impl of the nrepl protocol for a separate language and separate set of tools (i.e. no intention of talking to clojure/java/jvm at all), would it still be an nrepl project?
17:23mdeboardI can't sort out where the delineation is between the nrepl protocol and nrepl the whole thing
17:23mdeboardspaceballs: the movie
17:24technomancyclojure has a proud history of being implementation-defined =)
17:27mdeboardtechnomancy: I don't know what that means :(
17:27mdeboardI feel like a jok ejust went over my head
17:27TimMctechnomancy: Don't smile when you say that...
17:30TimMcBronsa: ... is idiomatic in Racket, I think
17:30BronsaTimMc: if you scroll back, I said that I actually throw ex-info rather than assert, binding *assert* won't save you.
17:31BronsaTimMc: what is idiomatic?
17:31TimMchmm, OK
17:31TimMcthree dots in a row, an ellipsis
17:32TimMcI seem to recall it from HtDP.
17:32reillasram: I got defmethod to work all along...it was just a issue between my editor and the repl.
17:32technomancyiirc it's a syntax-rules thing?
17:32TimMcI guess you want to make sure other code paths through the same fn won't run either, though.
17:32TimMctechnomancy: That too.
17:33cespareI just put ~'_ insde a macro (inside a `(...) form) so I could get _ as a function param without it being resolved
17:33cespareis that normal?
17:34TimMcIt's perfectly normal.
17:35TimMccespare: Or... hmm, why not _# instead>
17:36TimMcIn an ideal world, _ won't collide meaningfully with anything, but if this to get a lexical binding you should use the gensym# form instead.
17:37TimMc~'foo would be used if you needed a specific non-resolved symbol such as when building a macro to emit a reify (and you need to specify method names)
17:37clojurebotTitim gan éirí ort.
17:37Bronsajeez, what's that word that describes a macro that binds something to the lexical environment? the opposite of hygienic somewhat
17:37puredangeranaphoric
17:37Bronsathanks
17:46puredangerI usually try to write euphoric macros instead
17:49Bronsapuredanger: (defmacro euphoric [code] (clojure.walk/prewalk (fn [x] (if (symbol? x) (symbol (str (clojure.string/upper-case (str x)) "!!!")) x)) code)) ?
17:50Bronsa,(defmacro euphoric [code] (clojure.walk/prewalk (fn [x] (if (symbol? x) (symbol (str (clojure.string/upper-case (str x)) "!!!")) x)) code))
17:50clojurebot#<CompilerException java.lang.ClassNotFoundException: clojure.walk, compiling:(NO_SOURCE_PATH:0:0)>
17:50Bronsa,(require 'clojure.walk)
17:50clojurebot#<SecurityException java.lang.SecurityException: denied>
17:50Bronsa:<
17:50puredangeryou put a lot more thought into that then I did :)
18:04Bronsapuredanger: is there any plan to add a fold compatible with transducers?
18:05puredangertricky question :)
18:05puredangerthis is an area of some discussion right now so take nothing I say here as final
18:06puredangerbut I think current plan is to essentially leave clojure.core.reducers as is
18:06puredangerbut we add a parallel transduce path in core (say "produce") that would leverage some of the fold infrastructure
18:06puredangerha, auto-complete you kill me
18:06puredangerpreduce
18:07puredangernot produce :)
18:08Bronsapuredanger: once/if core has a fj-based transduce, what would reducers have to offer more? am I right in thinking that they could be deprecated at that point?
18:08mdrogalispuredanger: What's the justification behind that path?
18:11puredangerBronsa: it's really a different way of rendering the same idea. the intention there was to retain a more similar shape to nested transformations. transducers have gone in a different direction that emphasizes separating algorithm from application. they are not in conflict, just different paths. But I suspect transducers will get future attention, not reducers.
18:11puredangergotta run ...
18:12Bronsapuredanger: got it, thanks a lot
18:12mdrogalisHm
18:30danielcomptonIs there a way to cycle through emacs minibuffer lists without using the arrow keys?
18:30technomancydanielcompton: C-s / C-r would do it
18:30technomancyalso try ido-vertical; it's neat
18:31danielcomptontechnomancy: thanks!
18:31technomancyit sounds terrible but grows on you once you give it a try
18:32danielcomptonDoes it make the minibuffer that size all the time?
18:33technomancyyeah
18:33technomancybut it goes away when you press enter, so it doesn't really bug me
18:34danielcomptonI'll give it a go, I'm not a big fan of windows changing size but it still sounds interesting
18:37danielcomptontechnomancy: Have the emacs starter kit functions like esk-cleanup-buffer been moved to new projects?
18:37danielcomptonI was thinking about creating some if they weren't already
18:38technomancydanielcompton: I think the tiny ones like that don't have a home
18:38amalloytechnomancy: can confirm, ido-vertical sounds terrible but might grow on me
18:39amalloyit's like a ton of wasted space, right? if you're going to use up eight whole lines, why not a grid like ls uses?
18:39danielcomptontechnomancy: I may look at making new homes for them, but at that point I'm just about remaking emacs-starter-kit anyway
18:39technomancyamalloy: it's easier to scan
18:40blunteHi folks. I'm stumped (and still rather new to Clojure). I'm trying to write a function that will return the index of the first occurrence of a value found in a list.
18:40blunte(find-first-index ("a" "b" "c") "b") should return 1
18:41amalloy(first (keep-indexed __ coll)) - try to fill in the blank, blunte
18:45blunte,(def ar2 ["pkey" "pkey" "" "" ""])
18:45clojurebot#'sandbox/ar2
18:45blunte,(keep-indexed #(= "pkey" %) ar2)
18:45clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (2) passed to: sandbox/eval48/fn--49>
18:47amalloyblunte: you're on the right track, but look more at the docstring for keep-indexed. what arguments does it pass your function?
18:48blunteamalloy: ahh, I think...
18:49blunte,(keep-indexed #(if (= "pkey" %2) %1) ar2)
18:49clojurebot(0 1)
18:49blunteamalloy: awesome, thanks
19:03llasramblunte: ##(.indexOf [:a :b :c :d :e] :c)
19:03lazybot⇒ 2
19:03llasramblunte: If you're trying to write your own, great, but if not... :-)
19:04amalloyllasram: meh
19:04bluntellasram: haha, no it was not my intent to reinvent something as wonderfully simple as that. Thanks :P
19:04bluntebut it's good now that I know of keep-indexed as well
19:04amalloy.indexOf is not great really. it works if you're looking for a specific element, but most of the time you have a predicate
19:04amalloyplus working in terms of list indices is usually an indication you're doing something wrong *anyway*
19:05bluntemy need for index is valid in this case, and I'll spare you some gory meta meta business spreadsheet reader explanation
19:06llasramamalloy: I like to use it to turn O(1) algorithms into O(n) or O(n^2) versions
19:06llasramIt's a hobby of mine
19:07pmonks‘(inc llasram)
19:07pmonks#selffail
19:07amalloyllasram: another advantage is it's horizontally scalable. you can turn n^2 into n^3 just as easily
19:08llasram:-)
19:15numbertenis there a defn- (private) equivalent for def?
19:15fifosineIs there a good library for building an interactive cli using clojure?
19:15mdeboardfifosine: What would such a library have in it?
19:16technomancyjline2 I guess
19:16technomancynecessary but not sufficient
19:17fifosinemdeboard: I don't know, I'm more looking to explore. I'm looking for a library with helper functions to allow me to create a program that when run allows the user to enter an interactive mini-shell
19:17fifosinefor doing whatever
19:17mdeboardOh, you probably want to write an nrepl client
19:17mdeboardright? someone smarter than me?
19:18technomancyfifosine: for clojure programmers, or general use?
19:19fifosinetechnomancy: The library? For general programmers. The program I'm writing, for general use
19:19Jaoodnumberten: (def ^:private
19:20numbertenJaood: alright thanks :)
19:22Jaoodnumberten: defn- just adds the ^:private metadata for you
19:22numbertenyeah
19:23numberteni wasn't sure if there was a def- or something defined
19:23numbertenguess I could always write a macro for it though
19:23fifosinetechnomancy: Does what I'm asking for make sense?
19:24technomancyfifosine: I was just trying to see if it'd be appropriate to embed a repl or if you want your own mini-language
19:24fifosineoh, mini-language definitely
19:24technomancyso probably jline2+instaparse?
19:24technomancyor mapping input to command vars more directly if you need extensibility
19:25technomancy(the latter is kind of what mire does, but over the network)
19:26technomancyhttps://github.com/technomancy/mire
19:30caspercI am having a wierd problem that I am wondering if anyone can help me solve or diagnose
19:30TEttingercasperc, ask away
19:31caspercbasicly we have a project that uses clojure.java.jdbc which is working fine. My problem is that every query takes around 5 s, no matter what
19:31caspercThis has suddenly started happening and is only on my machine
19:32amalloyhave you tried turning it off and on again?
19:32casperci have :)
19:33casperci am running OSX maricks and I have a similar machine with the same setup that does not have the problem
19:33caspercand it is only me, now the other members of my team
19:33mdeboardare you sure your db server is running and accepting connections
19:33mdeboardif everything is terminating after 5 seconds that sounds like a client timeout
19:34caspercno the query goes through just fine, it just takes 5 seconds when it should be taking about 100 ms tops
19:34mdeboardOh, "every query takes around 5s", implying they're succeeding?
19:34mdeboardi see
19:34amalloyi would say whatever is wrong is related, not to clojure, but to something else on your machine
19:34mdeboardya
19:34mdeboardAre you using a connection pooler
19:34casperci agree, but I can't just figure out what
19:34mdeboardhave you tried turning it off and back on?
19:34llasramMy guess would be DNS / nsswitch config
19:34justin_smithmdeboard: regarding some scrollback, I just got out of a bad relationshit, and appreciate this new word you have invented
19:35mdeboardjustin_smith: Oh I didn't invent it, I heard it long ago
19:35justin_smith(inc mdeboard)
19:35lazybot⇒ 7
19:35justin_smithoh, OK
19:35mdeboardBut, sure, I'll take credit
19:35mdeboardReaping those sweet lazybot points
19:35caspercllasram: would that not affect other connections? I am not seeing any problems when surfing the net or creating other connections from the program
19:36amalloyjustin_smith, mdeboard: have you guys read cryptonomicon? i remember the chapter where bobby shaftoe is on a ship of some kind, and everyone decides they don't like the ship so they start replacing "ship" with "shit" in every word that has it
19:36justin_smithamalloy: I barely started it, I am sure I should read it
19:37justin_smith(ages ago that is)
19:37amalloyit's an excellent book. i've read it about three times
19:37llasramcasperc: Can depend on how the various name services handle the particular name. Is the DB on localhost or resolved by an actual host name (even if on your same system)? If the latter, what happens if you try to `host` that name?
19:37mdeboardamalloy: No I avoid Neil Stephenson's books
19:37mdeboardI don't have the temperament for them
19:38mdeboardtoo many diversions/tangents/hyperfocus on minutiae idgaf about
19:38caspercllasram: It is not localhost, it is by hostname i'll give it a go
19:38amalloymdeboard: sounds like you should not read his books, yeah. those were my favorite part
19:38mdeboardJust my opinion obv, people I respect really like his writing
19:38caspercit is several (different environments) this is going on for though
19:38mdeboarddiff'rent strokes etc
19:38technomancythe only way I got through cryptonomicon was because I had a job that involved sitting around doing nothing for hours on end in school
19:38llasramcasperc: Hmm
19:38mdeboardcasperc: Sounds like a misconfig in your db server then IMO. Or bad disk maybe, or some such.
19:39mdeboardI assume you're tailing logs on the db server and see nothing incriminating.
19:39caspercmdeboard: but when connecting from a similar machine it doesn't happen, so I don't think that can be the case
19:39technomancytape drive maybe?
19:40mdeboardcasperc: But you said it's happening from diff environments right? Are all these environs using the same network conn to get to the db ?
19:40mdeboardif it's happening across multiple environs on different networks then something's fucky with your db server config
19:40mdeboardOh
19:40caspercmdeboard: There are several versions of the DB it is happening for: dev, test, prod dbs
19:40mdeboardHow much working memory do you have configured
19:41caspercit is only happening FROM one machine
19:41mdeboardI see
19:41caspercon the repl?
19:42mdeboardDo you have enough RAM for the query plan computation & query execution computation to be held in RAM? Or is the server having to swap to disk
19:42mdeboardThat would cause a significant slowdown... speaking of, have you inspected the query plan to see what it says?
19:42mdeboardexplain select etc.
19:42{blake}I'm having laziness troubles. Also, problems with my Clojure code. (Heyo!)
19:42mdeboard{blake}: bazinga
19:42llasram(inc {blake})
19:43caspercmdeboard: it can't be the db server itself because it doesn't happen from other clients.
19:43mdeboardhaha
19:43mdeboardOh, you said "now my coworkers machines"... I guess you meant not your coworkers
19:43technomancyhave you made any sysadmin enemies recently?
19:43mdeboardcasperc: TCP windowing?
19:43caspercthe query itself doesn't make a difference. "select 1 from dual" takes 5 seconds for instance
19:43TEttingerfirewall stuff, port stuff...
19:43{blake}Specifically, I've got this structure when I do a "get-in" it returns the value for that key, but if I do a "str (get-in...)" I'm getting back "clojure.lang.lazySeq".
19:44llasram{blake}: Try `pr-str`
19:44caspercmdeboard: dunno
19:44{blake}I'm having trouble duplicating this in a small scale. llasram, 'k, thx.
19:44llasram,(str (range 10))
19:44clojurebot"clojure.lang.LazySeq@9ebadac6"
19:44llasram,(pr-str (range 10))
19:44clojurebot"(0 1 2 3 4 ...)"
19:44mdeboardcasperc: start netstat then run your query again.
19:44caspercalso this happens both when being on the same network as the db and remotely via vpn
19:45caspercmdeboard: could be an idea
19:45mdeboardcasperc: better yet, install dstat if you can, then run that while your query executes
19:45{blake}llasram, OK, so that works. Cool. I don't really get what's going on, though. I assume "pr-str" realizes the seq. But I did try prefacing with "doall" and that got a lazySeq.
19:46fifosinetechnomancy: Is the type of program that fits my description called a "line editor"?
19:46mdeboardsee what, i fanything, goes weird
19:46hiredmana forced lazyseq doesn't change its type
19:46llasram{blake}: Do you know Python? It's kiiiind of like the difference between `str()` and `repr()`
19:46mdeboarda tiger doesn't change its stripes
19:46hiredmanit just means all the values have been realized and cached in the lazy seq
19:48{blake}llasram, Yeah. Oh, so pr-str is more like python's str (human-readable), and repr is more like python's str?
19:48llasram{blake}: Other way around :-)
19:48llasramBuuut I can see why that's confusing here
19:49caspercmdeboard: I am not sure how to use either of those tbh, but i'll give it a go. Currently I am installing mavericks in a fresh virtual machine to see if that has the same trouble
19:49{blake}llasram, Right. Wait. So "str" = "str", essentially? Maybe the analogy won't work for me.
19:50{blake}hiredman, mdeboard Good point. Maybe need to dig into the source a little.
19:50mdeboardcasperc: The beauty of dstat is you don't need to know how to do much of anything other than type "dstat"
19:50fifosinetechnomancy: I've found an equivalent library in Python: https://docs.python.org/2/library/cmd.html
19:50mdeboard{blake}: Oh I was just rhyming with what he said with a semantically similar metaphor
19:50mdeboardwhich also now that I think about it has the same meaning.
19:50llasram{blake}: `str` -> JVM .toString, which is for generically turning an object into a string, such as for formatted display to end-users. `pr-str` is for a (Clojure) printed/ideally-`read`able representation of the data.
19:50llasram,(str "some string")
19:50clojurebot"some string"
19:50llasram,(pr-str "some string")
19:50clojurebot"\"some string\""
19:50llasramIf that helps
19:51TEttinger,(str {:some :string})
19:51clojurebot"{:some :string}"
19:51llasramThere isn't really sensible end-user thing to display for a data-structure like a lazy sequence, so it just punts
19:51TEttinger,(pr-str {:some :string})
19:51clojurebot"{:some :string}"
19:51TEttingerhm
19:51llasramTEttinger: thanks for muddying the waters :-p
19:51llasramIMHO that's a wart
19:51TEttinger,(str (map inc [1 2 3]))
19:51clojurebot"clojure.lang.LazySeq@7c42"
19:52TEttinger,(pr-str (map inc [1 2 3]))
19:52clojurebot"(2 3 4)"
19:52llasramYeah, so it doesn't help that some data structures do print as their stucture, but with weird results:
19:52llasram,(str ["some" "vector" "of" "strings"])
19:52clojurebot"[\"some\" \"vector\" \"of\" \"strings\"]"
19:52llasramHmm
19:52llasram,(str (seq ["some" "vector" "of" "strings"]))
19:52clojurebot"(\"some\" \"vector\" \"of\" \"strings\")"
19:52llasramOk, somewhere in here is the weirdness I wanted :-)
19:53{blake}OK, I'm actually somewhat comforted that this is a little...imponderable.
19:53TEttingerI think the str on (map inc [1 2 3]) is pretty illuminating
19:54TEttingersince map is so common, that's a frequent source of "LazeSeq@blah" prints
19:55amalloy{blake}: doall does realize the input sequence, but it doesn't change its type (and thus, its printed representation). you get a "lazy sequence" with five realized elements, but it still prints like a lazy seq (ie, illegibly)
19:56amalloyi wonder whether it'd be crazy for (doall xs) to act like (apply list xs), so that what you get back *isn't* a lazy seq anymore. it sure seems to confuse a lot of newcomers that you get back a lazy seq, even though it's entirely reasonable
19:56{blake}amalloy, Right. The thing I'm not getting (in this case) is why it's even a lazy sequence. It's a PersistentHashMap inside a PersistentArrayMap, but it all seems to be realized.
19:57{blake}amalloy, You may have just restated my confusion, yes.
19:57amalloy{blake}: no, you're wrong. if it prints like LazySeq@..., then it's a lazy sequence
19:57amalloyit is not a hashmap inside an arrayman
19:57amalloy*map
19:57llasramAH!
19:57amalloy(new superman villain: ArrayMan)
19:57llasram,(pr-str (java.util.ArrayList. ["foo" "bar" "baz"]))
19:57clojurebot"[\"foo\" \"bar\" \"baz\"]"
19:57llasram,(str (java.util.ArrayList. ["foo" "bar" "baz"]))
19:58clojurebot"[foo, bar, baz]"
19:58llasramThere we go
19:58fifosineDoes anyone know of a library that allows the creation of an interactive command interpreter? Something that's analogous to the cmd module in Python https://docs.python.org/dev/library/cmd.html
19:58llasramThat's what I was trying to remember, which either explains things or leaves them hopelessly muddled forever
19:59{blake}*regrouping*
19:59llasramOTOH, why don't LazySeq's just toString as their realized portion?
20:00TEttingerllasram, because it could be infinite?
20:00llasram#<LazySeq (1 2 3 4 ...)>
20:00TEttinger,(str (repeat :infinite))
20:00clojurebot#<OutOfMemoryError java.lang.OutOfMemoryError: Java heap space>
20:00TEttingeruh ok
20:00amalloyTEttinger: as you've just discovered, that's a problem anyway
20:01amalloybecause the @foo part is the object's hashCode, and the hash of a lazy seq depends on all of its elements
20:01TEttinger,(pr-str (repeat :infinite))
20:01clojurebot"(:infinite :infinite :infinite :infinite :infinite ...)"
20:01TEttingerhaha
20:02{blake}amalloy, Well, here's what I'm seeing: https://www.refheap.com/89324
20:03{blake}I haven't been able to recreate the complex structure and get the same results, so there's something I'm missing, obviously. "get-in" shouldn't create a lazy sequence (though I guess it could return one?)
20:03amalloyget-in will return whatever is there inside the map
20:03amalloyyou are storing lazy sequences in your map
20:04danielcomptonIs it expected behaviour that leiningen will overwrite a "Main-Class" specified in :manifest with clojure.core if :main isn't specified?
20:04amalloywhich is a totally fine thing to do, of course
20:05technomancydanielcompton: not sure what you mean by "overwrite"
20:05danielcomptontechnomancy: replace
20:05technomancyit shouldn't replace anything
20:05llasramSounds like an explicit "Main-Class" :manifest entry?
20:06danielcomptonllasram: I've got an explicit "Main-Class" entry without a :main, and it's being replaced with clojure.core
20:06{blake}amalloy, I can't see the lazySeq. In the repl it looks like ":_sub {:name :_sub, :value ({:b 1, :c 1, :a 2})".
20:06danielcomptonIs https://github.com/technomancy/leiningen/commit/0f5905449726926760e1a6454286ad2e693f4cc0 relevant?
20:06technomancydanielcompton: oh, I see. yeah, it will check :main but not :manifest. there is a way to disable that though
20:06amalloy{blake}: ({:b 1, :c 1, :a 2})
20:07amalloythis is a seq, and probably lazy
20:08amalloy(indeed, evidently lazy based on your refheap paste)
20:09danielcomptontechnomancy: so you should set :main to nil if you want to specify "Main-Class" in your :manifest?
20:10{blake}amalloy, So...if it was unrealized at some point, and then realized, it remains lazy. Do we ever de-lazify (neologism!) sequences?
20:11hiredman{blake}: in the jvm is not possible for the type of a refence to change
20:11fifosineHow do I input the EOF character and also read for it?
20:11justin_smithfifosine: in a *nix terminal, you can input it with Control+D
20:11hiredman{blake}: if x is a lazy seq, and you realize it walk it with doseq, x is realized, but the type of x cannot change
20:12{blake}hiredman, OK, then. Much to ponder. Thanks all.
20:12hiredman{blake}: you may not be aware of the features of lazy seqs that dictate their behaviour, checkout http://clojure.org/sequences
20:13danielcomptonfifosine: I don't think EOF is a 'character', it's system defined AFAIK
20:13fifosinedanielcompton: Does that mean there's not a way to specify functionality if it's read?
20:13danielcomptonfifosine: wait think i got that wrong
20:13justin_smithyeah, it's more of a "condition" of the input stream - but you can send it with C-d
20:13justin_smithfifosine: it isn't read so much as detected
20:14fifosinejustin_smith: err… how's that?
20:14justin_smithsince it isn't a piece of data
20:14llasramThere's the EO*T* character, ASCII/Unicode CP 4, usually entered via ^D
20:14justin_smithit's a state of the stream you get data from
20:14{blake}hiredman, Thanks. I keep going back to that, understanding bits and pieces. It's a journey. A journey of a thousand steps begun by walking backwards.
20:14llasramfifosine: Do you just want the EOT character, or are you actually trying to detect when you reach the end of a file?
20:15justin_smithfifosine: because we need to be able to input every possible byte (think image files), and when reading an image file or some other binary, still need to know whenthe input is closed
20:15amalloyllasram: he's trying to write a repl of some kind
20:15fifosinellasram: I'm trying to write an interactive command interpreter, so I want to be able to know when the user wants to exit by entering an EOF and detecting that
20:15llasramfifosine: Ah, then you -- you want EOT, which is character 4
20:16justin_smithwhich is control+d, which was the first thing mentioned up there
20:16fifosinellasram: So how do I read for "character 4" from what's returned from (read-line)
20:17llasramOh, from `read-line`? I don't think that you do
20:17justin_smithfifosine: I think you just check if *in* is closed
20:18fifosineugh I'm so lost, there isn't any documentation on doing something like this with clojure
20:18llasramfifosine: You do it just like you do from Java
20:18justin_smiththis is not really clojure specific, you should read up on the relevant java classes
20:18justin_smithInputStream etc.
20:18llasramOr probably using JLine, if you want full terminal input funtimes
20:19llasramfifosine: https://github.com/jline/jline2
20:19justin_smithyeah, technomancy mentioned JLine above, and it makes this all much easier
20:19justin_smithif what you want is a shell like experience for the user
20:20fifosinedocs of jline aren't that great
20:20justin_smithhttp://jline.sourceforge.net/javadoc/
20:21fifosineok, I'll read up on it, thanks
20:24technomancyjustin_smith: jline2 is a fork of jline, so those docs are probably not right
20:25justin_smithtechnomancy: oh, he said jline, so I linked the jline javadoc
20:26technomancyfifosine: https://github.com/trptcolin/reply uses jline2 if it would help to see some sample code
20:26technomancyfrom clojure
21:01lepahSorry, I was looking for Bronsa
21:01lepahWhere is he?
21:02justin_smithBronsa: you are being pinged
21:02justin_smithlepah: he is on this channel, but may not be around right now
21:03lepahI see
21:26mynomotoIs it possible to use double-check for async tests like cljs.test?
21:29hiredmanit seems unlikely, there are no blocking operators in the cljs version of core async, so no way to return control to double-check's logical thread
21:44mdeboardtechnomancy: lein repl starts an nrepl server itself?
21:44mdeboardwell, nevermind, I guess it just calls out to tools.nrepl to do so?
21:45mdeboardso concise
21:45mdeboardleiningen.repl is
21:45mdeboard:megusta:
21:49technomancycant-tell-if-serious.jpg
21:50Jaoodtechnomancy: you don't have a pic for that?! ;)
21:52mdeboardtechnomancy: dead serious
21:53mdeboardtechnomancy: I'm fumbling through how this stuff works atm irl bbq
21:53brehautmdeboard: have you visited https://github.com/trptcolin/reply yet?
21:53mdeboardYes
21:53mdeboardjust now
21:53mdeboardafter you linked it
21:54mdeboardI'm doing this for a different language's toolkit
21:54mdeboardThe more examples the better though, thanks brehaut
21:55mdeboardIf nothing else I've learned more about how nrepl, cider, etc. fit into the clojure ecology
22:01reiI'm using Vim, so I'm curious is there are any issues in Emacs reloading a namespace with a defmethod in it?
22:02mdeboardrei: What kind of issues?
22:04reimdeboard: It reloads without error, but the defmethod/defmulti is exactly the same even though I changed it.
22:04reiIf I restart lein repl it works as expected.
22:04mdeboardrei: I see, I don't actually have any idea what vim's behavior is--
22:04mdeboardShit, I thought this was in a different channel, sorry.
22:04mdeboardrei: Can you paste your code up somewhere and I can try it maybe?
22:05reimdeboard: Yes, give me a moment.
22:09reimdeboard: Here's a reduced form of what I was doing. https://www.refheap.com/89326
22:10reiI had messed up the defmulti earlier (it was only taking one argument), and when I switched it to two and reloaded it kept saying it wanted only one argument.
22:11reimdeboard: I edited the paste with what I had done wrong, but it through testing it was any modification.
22:12mdeboardrei: Works fine
22:12reimdeboard: Alright, thanks. I guess it may be an issue with the vim plugin.
22:12mdeboardrei: I mean, I changed "site.com" to "foo.com", and ran `(parse-site "foo.com" {:blah :blah})` and still got :b
22:13Jaoodrei: did you use :reload ?
22:13mdeboard(I changed it after I ran it against site.com and got :b)
22:14reimdeboard: Ah...can you try changing the defmulti function? Maybe just have it return "foo.com".
22:14reiThat's where I ran into an issue.
22:14reiJaood: I did.
22:15reiJaood: And :Reload!
22:18mdeboardgiving it a whirl
22:19mdeboardrei: Seems to work fine but only if I restart CIDER (emacs repl). if I just re-evaluate the defmulti it doesn't take hold
22:20reimdeboard: Hmm...okay, perhaps that's the equivalent of me restarting the lein repl here.
22:20mdeboardyeah it is, I'm pretty sure
22:21reimdeboard: Very weird...okay, thanks very much!
22:22acebulfhey guys, is there a Lispbox for Clojure on Linux?
22:32Jaoodacebulf: what's lispbox?
22:33justin_smithJaood: pre-configured emacs+lisp+package-manager
22:35justin_smithacebulf: lein is better than pretty much any other package management scheme out there, and is the tool you should use to run your repl and to package your library or app
22:35justin_smithregarding a full package like that, I don't know of one, but I wouldn't be surprised if there is one somewhere
22:50acebulfthanks @ justin_smith
22:50munderwoany tips on setting a value in a Java object? Im not sure of the syntax? its for swt
22:50munderwothe java code is "gridData.horizontalAlignment = GridData.FILL"
22:51danielcomptonmunderwo: (.horizontalAlignment gridData GridData/FILL) ?
22:52justin_smithdanielcompton: I think he needs to use set!
22:52munderwoyeah thats what I thought. But horizontalAlignment doesnt seem to be a method?
22:53justin_smith(set! (. instance field1) expr)
22:54justin_smithI only know this from looking it up, I don't mess with mutation much even in interop if I can help it, but that syntax should work
22:54munderwowoohoo! thanks justin_smith !
22:54justin_smithso it did work?
22:55munderwoYup!
22:55justin_smithcool
22:55munderwoIm only doing the mutation to get a sample of Java to work.
22:55justin_smithright, I am not saying it is never needed
22:55munderwoand it looks like its normal practive in swt soo… ahh well..
22:55justin_smithI consider luck that I have avoided it so much so far :)
22:55munderwohopefully the luck keeps rollin!
22:55munderwothanks!
22:55justin_smithnp
23:04xeqirei: defmulti has some sort of defonce semantics, so either removing the binding or restarting the repl is required
23:05xeqiI feel like I've seen technomancy complain about this somewhere
23:06bbloom_use ##(doc ns-umap)
23:06bbloom_(doc ns-unmap) ; rather
23:06clojurebot"([ns sym]); Removes the mappings for the symbol from the namespace."
23:07bbloom_the defonce-ish semantics are a massive pain for multimethods
23:08reixeqi: Thanks, I tried reading the code, but I couldn't make sense of it.
23:08reibbloom_: Oooh, let me give that a shot.
23:09technomancyor (def mymulti nil)
23:12reibbloom_: The Vim plugin did not want to co-operate with me, but the technomancy trick worked.
23:12bbloom_technomancy: clever
23:18dogonthehorizonGreetings folks. I have a vector of keys and a list of vectors that I would like to join together. (zipmap keys vecs) isn't quite what I'm after and (apply zipmpap keys vecs) gives me an arity error... my next idea is to do this with loop/recur, however I'm curious to know if there's a cleaner way?
23:20justin_smithcan you give a simplified example of the inputs you get and the outputs you expect?
23:21justin_smithis it something like [:a :b :c], [[0 1 2] [3 4 5]] -> {:a [0 3] :b [1 4] :c [2 5]} ?
23:21dogonthehorizonjustin_smith: Yes that's exactly what I'm after
23:22justin_smith,(zipmap [:a :b :c] (map vector [0 1 2] [3 4 5]))
23:22clojurebot{:c [2 5], :b [1 4], :a [0 3]}
23:22dogonthehorizonEssentially I have a response from clojure.java.jdbc/query where the first element of the sequence is a vec of keys and (rest response) is the list of values. I was hoping to use zipmap in some way to label the data
23:22dogonthehorizonAh. Let's give that a try then!
23:24justin_smith(partial map vector) swaps columns / rows in a sequence of sequences
23:24justin_smithit would likely have a handy name like rotate2d if it weren't already so concise
23:26dogonthehorizonWell actually no, looking at this answer again this isn't what I'm after. What I'm after is a result that looks more like this: [:a :b], ([0 1] [2 3] [4 5]) -> ({:a 0 :b 1} {:a 2 :b 3} {:a 4 :b 5})
23:27justin_smith,(map zipmap (constantly [:a :b :c]) [[0 1 2] [3 4 5]])
23:27clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.core$constantly$fn__4178>
23:27justin_smith,(map zipmap (repeat [:a :b :c]) [[0 1 2] [3 4 5]])
23:27clojurebot({:c 2, :b 1, :a 0} {:c 5, :b 4, :a 3})
23:27justin_smiththat should be it
23:31dogonthehorizonjustin_smith: Oh, this is nice; I hadn't thought of using repeat in this way. Thanks for the help!
23:31justin_smithnp
23:38munderwoHmm..im having trouble linking to native libraries on OS X? getting Caused by: java.lang.UnsatisfiedLinkError: /Users/mlakewood/projects/indifference/indifference-app/lib/libchromium_loader.dylib: dlopen(/Users/mlakewood/projects/indifference/indifference-app/lib/libchromium_loader.dylib, 1): Library not loaded: @executable_path/Chromium Embedded Framework
23:39munderwoIm not sure how to workout where it thinks @executable_path is going to be?
23:39munderwolong shot that anybody has had anything to do with this.
23:40justin_smithmunderwo: try running ldd on the artifact, it should tell you where all the shared libs it needs are
23:40justin_smithand which are perhaps missing
23:41justin_smith(the artifact meaning the .dylib file)
23:41munderwoSo I know which ones are missing.. I just dont know where to put them.
23:41munderwothe reference for @executable is an OS X thing that I dont know much about
23:42justin_smithyeah, I am not an OSX user, and have had no luck with trying to use native deps, hopefully someone else can help you
23:42munderwothanks for trying.. I think it might be one of those things that is between two fields of experts...
23:43justin_smith##java will likely say "don't do native code", but if you ask at the right time someone there may just be able to help
23:45munderwooh thats a good thought
23:50puredangermunderwo: are you setting DYLD_LIBRARY_PATH ?
23:51munderwonope. not at the moment. I just came across something that says I can use DYLD_FALLBACK_LIBRARY_PATH to specify a fallback dir to look in?
23:55munderwooooh… just got a little further! thanks for the tip puredanger !
23:55munderwols
23:55puredangermunderwo: no idea what the fallback thing is
23:55puredangeryou need to actually load the library via java interop
23:56puredangerpresuming you've used JNI to generate a Java interface, you should just be able to call it then
23:56munderwoIts apparently where the system looks to find the library if it cant find it in all the normal places.
23:56puredanger(System/loadLibrary "foo") is the call to make to load
23:56munderwoyeah. It finds the dylib… but then it goes looking for another file and couldnt find it.. I put it in the right place and it seems happier now?
23:57joshuafcoleIf I have a folder full of files that I would like to require, is there a suggested way to do that? (Or alternatively, is there a better architecture approach I should consider?)
23:57munderwoIm actually useing a java library that wraps that.. But Its install story is… umm not great… or Im messing it up completely… either could be true
23:58justin_smithjoshuafcole: in order to use require, the directory structure should reflect the namespace structure
23:58joshuafcoleUse case is a folder of renderer's in a component entity system.
23:58joshuafcoleOkay, I've got that much in place
23:58justin_smithie. my.app.foo should be in my/app/foo.clj somewhere under the soruce path
23:58joshuafcolebut right now I'm manually requiring each renderer
23:58joshuafcolee.g.
23:59joshuafcole*quickly hacks :require to something manageable*
23:59joshuafcole (:require [overcode.sces :as sces]
23:59joshuafcole [tetsujin.renderers.pacman :as pacman]
23:59joshuafcole [tetsujin.renderers.block :as block])
23:59justin_smithyeah, that's pretty much how its done
23:59joshuafcolethe format is identical for each of the renderer files, is there a way I could map over all the ones in the folder without needing to list them by hand?