#clojure logs

2014-12-10

00:03irctchi
00:04irctcI was wondering if someone could tell me why this seemingly basic program (6 lines) doesn't work as intended http://lpaste.net/116138
00:06irctcI guess everyone is sleeping
00:06irctcI'll try again tomorrow
00:06irctctired anyway
00:06gfredericksirctc: conj isn't side-effecting
00:07gfredericksit returns a new data structure, which you're ignoring
00:07irctcso I need to use something else or take in the new structure?
00:07gfredericksuse the new structure
00:07irctchow'
00:08gfredericksdepends on what you're trying to do; your whole example is based on side effects which is not the normal style of programming
00:08irctcI'm trying to add data to a vector, then sort the vector and print the head
00:09irctcthe data comes from input
00:09irctcso I have to add incrementally
00:09irctcI can do this very easily but I don't seem to understand just the data gathering
00:10irctc(I've tested the rest of the program and it works)
00:12irctcthanks for the hint I'll keep googling
01:27Javran大白兔!
01:27Javransorry wrong channel
01:39justin_smith$mail irctc the easy way to do it is to make the vector an extra loop parameter, and put the conj inside the recur. Also, look up peristent data strucures, immutibility is one of the most fundamental concepts in Clojure.
01:39lazybotMessage saved.
02:15dysfunthere's got to be a better way to debug macros than macroexpand and friends
02:16justin_smithhaving as little code as possible inside macros, and doing the real work in functions?
02:24fairuzHi guys. I've seen a lot of #( ... ). Is this some syntatic sugar to something? I suspected it's the same thing as (fn [] ...) ?
02:24justin_smith,'#(+ % %)
02:24clojurebot(fn* [p1__25#] (+ p1__25# p1__25#))
02:25justin_smith,'#(apply + %&)
02:25clojurebot(fn* [& rest__50#] (apply + rest__50#))
02:26fairuzcool
02:27fairuz,'(+ 1 2)
02:27clojurebot(+ 1 2)
02:27fairuz,'#(+ 1 2)
02:27clojurebot(fn* [] (+ 1 2))
02:27fairuz,'#(+ 1 %)
02:27clojurebot(fn* [p1__123#] (+ 1 p1__123#))
02:27fairuzcool got it. Thanks!
02:28fairuzpretty neat
02:28justin_smithyeah, quote is often handy for figuring out anything with a # in it
02:28justin_smith(that is, reader things)
02:29fairuzah ok
02:29fairuzbut why the * at fn* ?
02:29justin_smithfn* is the underlying implementation of fn
02:30fairuzah ok
02:31justin_smithit is almost identical, except it doesn't do the same destructuring - if you look at the source to fn, it's a complicated macro constructing a call to fn*
02:32justin_smithit also handles things like :pre and :post
02:37fairuzJust want to shoot my question about Liberator's defresource here. I have this :location #(build-entry-url (get % :request) (get % ::id)) in my defresource. How it knows what to put as the functions arguments? In this case I assume there are 2 since there are 2 %
02:39seancorfieldfairuz: no, that's just one argument
02:39seancorfield% is the same as %1
02:39seancorfieldmultiple arguments would be %1 %2 etc
02:39fairuzoh
02:39fairuznew thing again :) thanks
02:39fairuzneat neat
02:40seancorfieldso it calls build-entry-url with two arguments, the :request key of the argument and the :id key of the argument
02:41dysfunjustin_smith: well yeah, of course i've minimised them, but the output looks fine...
02:42fairuzseancorfield: ok
02:42fairuz,'#(% %1 %2)
02:42andyfdysfun: Colin Fleming might be working on some enhancements to Cursive to show macro-expansions step by step
02:42clojurebot(fn* [p1__25# p2__26#] (p1__25# p1__25# p2__26#))
02:42andyfdysfun: pprint can help longer macro expansions look a bit more readable.
02:42schrottihm has someone advise on how to conditionally load namespaces or resources? currently i use an env variable and the load fn, to load a .clj file with definitions into a namespace. i'd like to do this to make the app more modular and to easily add support for other storage backends.
02:44justin_smithschrotti: better to define a multimethod or protocol, and use the implementation that the runtime code passes in
02:44schrottijustin_smith: i'm using protocols already
02:45dysfunandyf: that sounds promising
02:45dysfunhttps://www.refheap.com/6ddc06df791b72447725807f9 # if you try to even (macroexpand '(dev-prelude)) it complains with an error. i can't for the life of me figure out why
02:45dysfuni've stepped through all the individual macro invocations and i can't see what the problem is
02:46justin_smithschrotti: in that case, code to the protocol functions, and that way the decision of which impl to use is isolated to one place in the code. You can use a change in classpath to determine which impl gets loaded.
02:46schrottijustin_smith: but how to define which implementation should be used during runtime? i don't like to throw conditional statements in everywhere. and theres also the problem how the storage backends access tables/keys.
02:47andyfdysfun: :Private should be :private, but I doubt that is the issue.
02:47justin_smithso instead of having everything in src/ you can also have foo-backend/bar/storage_impl.clj and quux-backend/bar/storage_impl.clj and decide at launch which is on the classpath
02:47justin_smiththat is going to be a lot cleaner than conditional load
02:47dysfunandyf: yeah, it'd be nice if that one was flagged up heh
02:47andyfI don?t know if it is kosher to use ~ or ~@ with a macro inside ? never tried it.
02:48dysfunhrm, i just assumed it would work tbh
02:49schrottijustin_smith: but i don't understand how to implement the decision which one should be on the classpath, tried it already with require
02:50andyfit might. I just don?t recall seeing it before, and don?t know what happens.
02:50dysfun,(defmacro tm [] `(println ~(quote foo)))
02:50clojurebot#'sandbox/tm
02:50dysfun(macroexpand '(tm))
02:50dysfun,(macroexpand '(tm))
02:50clojurebot(clojure.core/println foo)
02:50schrottijustin_smith: is it possible that you can provide me a small example?
02:50dysfunandyf: looks like ~ works
02:51dysfunwell, quote is a special form i suppose
02:51justin_smithschrotti: it would be a question of launch profiles (easiest to do via lein) lein with-profile :foo run where foo adds foo-backend/ to the source-paths
02:52schrottijustin_smith: ah thanks now i understand
02:52justin_smithexample of profile-specific paths setup here https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L160
02:52amalloyandyf: ` and ~ are just reader shorthands for functions that build lists. there's no reason they would care whether there's a macro involved
02:54sm0kehow do i call a super method in a deftype?
02:55dysfunsm0ke: a super method? are you sure?
02:55justin_smithsm0ke: I don't know - I don't even know if it is possible actually. But proxy has proxy-super.
02:55justin_smithdysfun: well, deftype can inherit
02:55sm0keyep proxy has , gen-class also has :expose or something
02:55dysfunjustin_smith: since when?
02:56justin_smithoh wait, deftype can't do concrete inheritance, only protocols and interfaces
02:56justin_smithmy bad
02:56amalloythe first problem i see with dysfun's dev-prelude is that midje.sweet gets namespace-qualified to like clojure.core/midje.sweet
02:56dysfunnice spot
02:56justin_smithsm0ke: so there's your answer: you can't call the super, because there is no way to have a super
02:57dysfunhowever, that doesn't fix it :/
02:57sm0ke,(deftype Foo [] Object)
02:57clojurebotsandbox.Foo
02:57amalloydysfun: "it complains with an error" is a complaint i generally decline to do anything with
02:57dysfunsm0ke: when you're doing undocumented things, you get to keep the pieces
02:57justin_smithsm0ke: Object is special cased, not as a superclass, but just to let you override methods on Object
02:58dysfunamalloy: how about "it complains with IllegalArgumentException Don't know how to create ISeq from: clojure.lang.Var clojure.lang.RT.seqFrom (RT.java:505)" ?
02:58amalloythe errors are printed because they're useful; saying there's an error but not gisting it is just teasing
02:58amalloydysfun: better, but a whole stacktrace would be much easier
02:58dysfunsorry, i didn't realise i wasn't being helpful enough
02:58dysfunhow can i generate you a stacktrace?
02:58justin_smithclojure.repl/pst is the easy way
02:59amalloydysfun: (.printStackTrace *e *out*), immediately after your failing call to macroexpand
02:59amalloypst is evil
02:59justin_smithwhy is that?
02:59dysfunhttps://www.refheap.com/94664
02:59amalloyjustin_smith: it tries to be too smart
02:59amalloyhides a lot of useful information
02:59justin_smithI had no idea
03:00amalloysee? that output came from pst, and it's useless garbage
03:00amalloydysfun: can you try again, with the longer form?
03:00dysfunhttps://www.refheap.com/94665
03:01amalloyfipp.printer? how is fipp getting involved?
03:01dysfuni don't even know what fipp is
03:01justin_smithit's a pretty printer
03:01amalloythis looks like a stacktrace from nrepl
03:01dysfunthis is from lein repl
03:01amalloyweeeeeird
03:02dysfunwould you like me to do it at a plain java prompt?
03:02dysfuner clojure prompt
03:02amalloydysfun: that would be great, yeah. sorry to make you go through that horror
03:02amalloybut it does look like something is going wrong in lein repl itself
03:02dysfunheh. i can live with typing one thing into it
03:02justin_smithI bet something weird is happening in a "pretty printing" middleware
03:02dysfuni note that this happens outside of lein repl too, incidentally
03:03justin_smithso what's the cause/symptom again? I missed it in the scrollback
03:03amalloyjustin_smith: dysfun gisted some code that throws an exception when you macroexpand it
03:03amalloyit looks fine to me, so i asked for the macroexpansion stacktrace
03:04dysfungah, how do i open a clojure repl when i don't know where the clojure jar is?
03:04amalloydysfun: java -cp `lein classpath` clojure.main
03:04dysfunty
03:05justin_smithif nil-macros returned a var instead of a list, you would see that var/sequence error
03:05andyfpuget and whidbey are in that stacktrace, too.
03:05dysfunamalloy: and *e doesn't appear to work. how can i get you a stacktrace?
03:05justin_smithdysfun: additionally, you as using (do ~@(map ...)) to generate the return value from nil-macros
03:06amalloyreally?
03:06justin_smithI would not be surprised if that did not return a collection
03:06dysfunoh hang on
03:06dysfunno, it's because it *worked*
03:06amalloylovely
03:06sm0ke,(deftype Foo [x] Object)
03:06clojurebotsandbox.Foo
03:06sm0ke,(Foo 1)
03:06clojurebot#<RuntimeException java.lang.RuntimeException: Expecting var, but Foo is mapped to class sandbox.Foo>
03:06sm0ke,(Foo. 1)
03:06clojurebot#<Foo sandbox.Foo@fc374c>
03:06sm0kehow do i access the x now?
03:07dysfunamalloy: would it help if i disabled all my nrepl middleware?
03:07justin_smith,(.x (Foo. 1))
03:07clojurebot#<CompilerException java.lang.IllegalArgumentException: Unable to resolve classname: Foo, compiling:(NO_SOURCE_PATH:0:0)>
03:07sm0kehehe
03:07amalloydysfun: well, there's either a bug in leiningen, or in some of your middleware
03:07sm0ke,(deftype Foo [x] Object)
03:07clojurebotsandbox.Foo
03:07sm0ke ,(.x (Foo. 1))
03:07clojurebot1
03:07amalloyi'm guessing it's a fipp-related middleware, so turn them off until it stops breaking
03:07sm0keoops
03:07amalloythen file a bug at the one that is breaking things
03:08sm0kewow embarasing, thanks justin_smith
03:08amalloyit is probably whidbey?
03:09dysfunit hadn't even occurred to me that a pretty printer would perform such action at a distance
03:10dysfunokay, replicated with all nrepl middleware disabled
03:10amalloythe foundational tools you use need to be rock-solid, because you'll never suspect they're the problem
03:10andyfIt is tough to test every case when code is involved.
03:11amalloydysfun: replicated, as in the issue still occurs? with the same stacktrace inside whidbey and fipp? that seems unlikely
03:11amalloymaybe whidbey is part of nrepl now, i dunno
03:11andyfpprint by itself goes into an infinite loop for forms containing Vars created by defprotocol.
03:11dysfunthe same error message
03:11dysfunnew stacktrace :)
03:11dysfunhttps://www.refheap.com/94666
03:12amalloyoh
03:12amalloydysfun: just remove the ~@ around nil-macros completely
03:13justin_smithhaha, I called it
03:13amalloythe problem is obvious now that there's not this weird fipp thing distracting me :)
03:13dysfunoh
03:13andyfwhat is the problem?
03:13dysfunright, yeah
03:13dysfunthanks folks
03:14dysfunand of course the reason it worked in the clojure repl is because it went into 'live' mode
03:14justin_smith <justin_smith> dysfun: additionally, you as using (do ~@(map ...)) to generate the return value from nil-macros ... <justin_smith> I would not be surprised if that did not return a collection
03:14amalloyjustin_smith: but that's not actually right
03:14justin_smithOK
03:14justin_smithwhat is it then?
03:14amalloynil-macros returned a list, as expected
03:15amalloybut it's a macro
03:15amalloyso you should either just call it, eg with (in-live (nil-macros ...)), or else make it into a function and then splice it in
03:15amalloyyou can't make it a macro *and* splice it in
03:16andyfI should have listened to my vague misgivings about that.
03:16amalloybecause if you do, nil-macros gets called at macroexpansion time! and it returns a var, of course, which you try to splice into the user's code
03:16justin_smithOK. I would have said "since it's a macro you don't get the list it returns" but I guess my understanding of the world of macros is still insufficient
03:16cflemingdysfun andyf: I have a prototype of a stepping macroexpander parked - the issue was that naive stepping (i.e. stepping from start to finish) is really tedious. You need to be able to select a form to expand, but that's surprisingly hard to do if you want to properly respect &env
03:16cflemingdysfun andyf: I'm hoping to get back to that soon.
03:16justin_smithand with my simplified explanation "it doesn't return a list" actually makes sense. But I understand that your explanation is much more accurate.
03:18justin_smith(inc amalloy)
03:18lazybot⇒ 204
03:18dysfunjustin_smith: well, you aren't technically wrong, you just could have been more correct :)
03:18amalloyhmmm, i'm trying to think of a simpler example to make the distinction clear
03:20dysfun(inc amalloy)
03:20lazybot⇒ 205
03:21amalloyjustin_smith: actually, maybe my old blog post on macro-writing macros is enough: have you read http://amalloy.hubpages.com/hub/Clojure-macro-writing-macros ? it's got the opposite side of this coin, the inverse of the mistake dysfun made
03:23justin_smithso the alternate solution is that dysfun could still use ~@, and define his impl as functions rather than macros
03:24justin_smithand those would get used and expanded properly
03:24dysfunamalloy: heh, that macro is insane
03:24amalloyjustin_smith: right
03:25amalloywhich i tried to say, with "so you should either just call it, eg with (in-live (nil-macros ...)), or else make it into a function and then splice it in"
03:25amalloybut i can see how that might not be clear
03:25justin_smithso the standard "put your impl in a function, and only use a macro for the syntax part" advice helps here too
03:25dysfunexcept in this case, where the goal is removal
03:25dysfunso it does have to be a macro
03:26justin_smithdysfun: until the last step, you can just be constructing lists
03:26justin_smithyou can easily remove items from a list
03:26justin_smithand finally splice the lists into what the macro returns
03:26zotwhat might i do to debug if (shutdown-agents) doesn't actually shutdown fast anymore? i assume that one of my go blocks is doing something errant, but i can't find it yet :/
03:26amalloydysfun: no, it doesn't have to be a macro. try this: put the ~@ back in, and change nil-macros from defmacro to defn
03:27amalloyyou should get equivalent behavior
03:27amalloylike justin_smith is saying, you only need one defmacro as the outer shell; inside that, everything can be functions
03:27dysfuni thought ` was only valid inside macros?
03:27amalloy,`x
03:27clojurebotsandbox/x
03:28dysfunhrm
03:28amalloy` is just a shorthand for functions that build lists
03:28amalloyyou can even see in your own nil-macro: that's a function, which contains `!
03:29dysfuni must have been drunk when i wrote this
03:29amalloythat's a ^:Possibility
03:29dysfun:)
03:29andyfzot: Do you use any of future, clojure.java.shell/sh, or pmap
03:29andyf?
03:29justin_smithdysfun: learning is state dependent, the more you code while drunk the better you will be at coding drunk.
03:29zotandyf: core.async only
03:30andyfThose are functions, not namespaces.
03:30dysfunjustin_smith: i used to work at an investment bank. drinking at lunch was practically mandatory. my drunken perl is quite something
03:30justin_smith:)
03:30rhg135justin_smith: tp a point only
03:30rhg135Look at m$
03:31zotandyf: i don't follow what you mean
03:31andyfI mean, do you use the functions future, or pmap, or sh?
03:31zotno, i do not.
03:32dysfunamalloy: i do not get equivalent behaviour. i get unable to resolve symbol now
03:32dysfun#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: facts in this context, compiling:(tk0/util/macros.clj:49:18)>
03:32zotandyf: although i realize after answering that a third-party library might. looking now.
03:33amalloyoh, sure
03:33zotindeed, it does use future.
03:33amalloyyou'd have to make some more changes than i said, because you'd need to quote things
03:33dysfun*nod*, i was about to test quoting them
03:33amalloy~@(nil-macros 'facts ...)
03:33clojurebotHuh?
03:33amalloyclojurebot: stuff it
03:34clojurebotexcusez-moi
03:34amalloythat's right
03:34andyfzot: You currently have a call to (shutdown-agents) in your program just before it exits?
03:34zotyep. otherwise i get to wait. but not even calling that just sits.
03:34zots/not/now/
03:35andyfzot: I?m not sure, but maybe if a future was created and its function is doing some long-running thing, the process will not exit? Is there much CPU utilization when your program fails to exit?
03:36amalloydoes core.async even use the agents threadpool?
03:36andyfamalloy: I do not know, but zot says one of his third-party libs uses future
03:36amalloyah, i missed that
03:39zotugh. this is tricky. apparently i'm still a liar. the old version of the lib did. the current one doesn't. i'm ignorantly running the slightly new, so my grep gave me wrongness. (https://github.com/pingles/clj-kafka/blob/0.1.2-0.8/src/clj_kafka/consumer/zk.clj#L48 versus newer 0.2.8-0.8.1.1 tag)
03:40justin_smithzot: yeah, any impl of kafka is going to be doing some threaded stuff
03:40zotyes, as i would expect
03:40zoti would just hope that it cleans up when using with-open / with-resource [their built in similar wrapper]
03:40justin_smithand the jvm won't shut down until those threads are good and ready
03:41zoti must be misusing it someplace :/
03:42justin_smiththe underlying zookeeper lib is creating the threads, I think
03:42justin_smithalso, top level namespace, which is terrible
03:44justin_smithfound this gem in the zookeeper javadoc: "The request doesn't actually until the asynchronous callback is called."
03:45zotlol. except, ugh.
03:45justin_smithyeah, instantiating a ZooKeeper object implicitly creates a thread, the connection establishment is async
03:45zotbut there was a time when it shutdown gracefully. so i must have done something wrong. (or i'm using it in a new/different way, and have forgotten.)
03:46justin_smithzot: you could try explicitly call .close on your zookeeper client? or does clj-kafka even expose that to you?
03:47justin_smithoh, it is already doing with-resource / zk/close
03:47justin_smithand furthermore, you already mentioned this
03:47justin_smithI am slowly catching up
03:47zotand it's greatly appreciated :)
03:48justin_smithzot: I have an ulterior motive here, I may have client work coming up that uses kafka, so this is a good chance to figure some stuff out
03:48zotyeah, i'm doing (kcore/with-resource [kc (make-kafka-consumer cfg)] kcons/shutdown …) which afaict is the right way
03:49zotnote that afa = not very far.
03:49justin_smithzot: backing up to another approach entirely - if you connect to your app in jvisualvm, you could check which threads remain active when it should be shutting down
03:49justin_smithzot: often the threads have informative names, otherwise you can see what code they are running
03:50justin_smithactually even jstack should suffice
03:50zotthis sounds like exactly what i would want to do. it's new ground, but useful. i've not worked in the JVM in years, so it's mostly a black box to me ;)
03:50justin_smithzot: jvisualvm and jstack both come with the JDK if you have it
03:50zoti do. will play and see what i learn. thanks!
03:51justin_smithjstack will give you a stack trace for every thread - that should help
03:51andyfThis isn't much additional info, but I did just run a toy test verifying that even calling shutdown-agents, any futures that are not finished will postpone the exiting from the JVM. But you may have known that already.
03:52zoti did not — i've still never used futures in clojure. every day is still learning new things.
03:57andyfWhen I tried jstack on a JVM waiting to exit with a future that was not done, the process showed up with a name like "clojure-agent-send-off-pool-0"
03:57andyfwhich is what the Clojure runtime names such threads by default, if you do not override it.
03:58andyfuh, I meant "thread" not "process" there.
03:59zotcool, nice to know. i'm checking it now.
04:00justin_smithandyf: well, given how rare Windows users are in the Clojuresphere, we can almost take pthreads for granted :)
04:00cblopdoes anyone know how to feed core.logic's pldb relations and facts from a vector?
04:00zotshall i assume that a thread in the state 'runnable' would willingly shutdown, and that the problems are likely WAITING (parking) threads?
04:01cblopi'm having problems because macros like db-rel require symbols as part of the relations
04:01schrottijustin_smith: maybe i'm still missing something, but to me it seems, that the way you suggested requires me to build an uberjar for each backend implementation
04:01justin_smithzot: this may help https://docs.oracle.com/javase/7/docs/api/java/lang/Thread.State.html
04:03justin_smithschrotti: yeah, that solution would require a different uberjar for different backends. But one option could be separating those backends to their own jars, and providing those to the jvm separately on the classpath along with the uberjar
04:03justin_smithschrotti: I acknowledge that this is awkward
04:05justin_smithschrotti: backing up, you could have multiple namespaces that implement the same protocol, and pass the protocol implementation to the code that uses it. Then the conditional is only in one place at least. And it does not require using load at all.
04:06justin_smithschrotti: I kind of like the default assumption that a given namespace is only implemented in one place. I could easily foresee weird debugging experiences with a codebase that handled this in an idiosyncratic way.
04:09zotjustin_smith: it seems likely that this is my problem: https://gist.github.com/anonymous/cf3023be4cce85ef67bb ; still trying to read, when the a (take N …) around the message block ought to have allowed this to close and stop trying to read. the rest are either in waiting / waiting_timed state, or appear to be normal jvm threads. am i crazy?
04:10justin_smithyeah, those are both stuck in polling state it looks like?
04:12zotappears to be. i'm curious if there's something bad that kcore/with-resource is being called within a core.async/thread call, since i just wrapped the shutdown handler, and it doesn't appear to be getting called.
04:14justin_smithzot: it's after 1 am my time, so I need to turn in. Good luck though.
04:14zotnope, makes no difference when i pull it out of the thread. ok. live with it and file an issue i guess.
04:14zottnx, sleep well
04:35nonubyusing clojure.java.jdbc if I want to do an update! with col1 = col1 + 1 (on the db side) how would one accomplish that?
04:36clgvnonuby: that's not clojure specific, but sql specific. so you should find enough material on that online ;)
04:36nonubyclgv, i get that, found it, was looking for execute! not update! (a map friednly wrapper around execute!)
04:37clgvnonuby: good :)
04:45SagiCZ1can i somehow let the producer in core.async know that i wont be consuming anymore?
04:46clgvnot through the channel I guess. you can only build up backpressure through the channel
04:46clgvdoes it even make sense not to consume products?
04:47SagiCZ1does it make sense to produce when no one is consuming?
04:50kenrestivoasync macroeconomics.
04:51SagiCZ1let say the producer is keeping some expensive resource opened, so once it know that no one wants to consume, it can close the resource
04:54clgvSagiCZ1: sure, I was questioning the asymmetry itself
05:01rritochIs there any way to type right on the function? When I try
05:01rritoch(defn ^void myfun [] ...) I get an error
05:01rritochErr, to type hint void return type that is.
05:02SagiCZ1rritoch: i dont think so.. type hinting is to avoid reflection.. there is no reflection with void
05:04rritochSagiCZ1: Ok thanks, I'm mostly using type hinting for improved documentation since the interface should automatically apply the correct types
05:05SagiCZ1rritoch: i am not sure that's a good idea.. well it probably can't hurt..
05:12schrottihm why isn't the :uberjar-exclusions not working :/
05:14schrottii'd like to exclude app/storage/core.clj, with the following regex #".*storage/core.clj"
05:36dysfunhrm, lein repl times out, but :headless/:connect works fine. any clues?
05:39rritochdysfun: If there is a possiblity that one of your repositories is offline or frozen you could try :update :never in your project.clj, and if your using :aot sometimes doing a precompile via lein compile can help. I've run into timeouts a few times for larger apps, 90% of the time my internet connection is to blame.
05:39dysfuni have all of the deps locally
05:39dysfunand i am not using :aot
05:40rritochdysfun: Even if you have your deps locally, it will still check the online repositories for newer versions
05:40dysfuni'm only using clojars
05:41rritochdysfun: Ok I can't help you then. These are the only situations that have lead to me getting timeouts errors.
05:41dysfun:/
05:42rritochdysfun: Is it possible that you have an infinite loop in code that's executing at compile time?
05:42dysfunif that was the case, it wouldn't work under :headless, surely?
05:46rritochdysfun: Probably, the inf. compile loop was just a wild-guess. I really haven't run into a timeout when I precompile and disable downloading. Maybe you can try aot compiling it and see if it does any better. Aot compiled code loads faster.
05:47dysfunthere just isn't enough code there to take ages, frankly
05:49dysfunhrm, you may have been right actually
05:49dysfunone of the deps was in maven central
05:49dysfunand that seems to have just started working
05:50dysfunbut that seems an implausible outage
05:50rritochdysfun: Plugins aren't aot-compiled, even if you want them to be. At least I haven't figured out a way to aot compile a plugin. So when you ran without aot, even though you don't have much code, the plugin code had to be compiled which was probably taking too long.
05:58dysfunhrm, it's cider-nrepl!
05:59dysfunwhen i comment out their middleware, it works fine
06:02rritochdysfun: Well at least your up and running, when I have timeouts like that it usually ends to a lot of f-words flying around until it's solved.
06:14dysfunbelieve me, i know that state well
06:14rritochIf you have an atom with a map where one of the keys contain an atom, is it possible and reliable to call swap! within the swap! method to ensure that the code remains thread-safe?
06:18noncomrritoch: ofcourse
06:18noncombut
06:19noncomyou actually need to retreive the inner atom and call swap on it
06:19noncomit will remain the same atom
06:19noncomyou do not need to re-include it again into the top one
06:19noncomrritoch ^
06:21noncomrritoch: i thought more and wanted to add that if you need to ensure the two atoms be changed as a single transaction, not like 2 thread-safe transactions, then them need to be refs
06:21noncombut as i said, i think that swapping only the inner atom will suffice for you
06:21clgvyou cant convince a clojure function to have void as return
06:22clgvrritoch: ^^
06:22clgvrritoch: for primitive types you need to use this pattern (defn f ^long [^double x ...] ...)
06:23rritochclgv: Thanks. I've had no problem with types so far, just the void which wasn't working.
06:23clgvrritoch: for general type hints up to clojure 1.6 you should prefer (defn ^String f [...] ...) - if I remember correctly that wont be needed in 1.7 anymore
06:23clgvrritoch: if thats the case you only type hint the argvector
06:29rritochclgv: What about array types, can they be type hinted?
06:30rritochclgv: (defn ^{:tag (resolve (symbol "[I"))} foo [] ) compiles, but I'm not sure it's valid.
06:50dysfunrritoch: longs = array[long]
06:50dysfunand similar appendings of 's' DTRT with other types
06:51hydoAny of you ever seen a funky classcastexception saying 'cant cast x.y.z to [Lx.y.z? packages are the same aside from the '[L'? Not the easiest thing to search google for.
06:53clgvrritoch: you can hint them as strings. but that has only effect on type inference and not the return type
06:54clgvrritoch: no the above form you provided probably wont work. I think I tried something like that myself. just use (defn ^"[I" foo [] ...)
07:00rritochhydo: That is actually related to my discussion with clgv, you need to use make-array, the L means it is an array and your passing a single class instance.
07:01hydo!
07:01noncomhydo: [L is an array of longs
07:01hydoThank you! No idea how long it would have taken me to figure that out.
07:01noncomactually that is a general java convention name
07:01noncomnot clojure-specific
07:02hydoI'm coming from cl, so it's all greek to me. heh
07:02clgvhydo: probably a java function with variable arguments, right?
07:03Bronsanoncom: not a convention, it's from the jvm specs
07:03clgva trick to figure out the class #(.getCanonicalName (Class/forName "[I"))
07:03hydoWell, no, the java call would be sender.getInventory().addItem(thing); Not sure if it takes a variable amount of arguments.
07:03clgv,(.getCanonicalName (Class/forName "[I"))
07:03clojurebot"int[]"
07:04clgvhydo: the javadoc or source will tell you ;)
07:04hydoYea, that's what I'm hunting :)
07:04hydoActually, first I'm going to hunt a drink.
07:05Bronsayou can use reflection if you can't find the javadoc or the source
07:11hydoBronsa: interestingly, it's cl.lang.reflector.boxarg that's throwing the exception.
07:12rritochhydo: Here is some code which may make it more clear. ##(type (make-array (class {}) 5))
07:12lazybot⇒ [Lclojure.lang.PersistentArrayMap;
07:12rritochhydo: As you can see [L gets added for any array
07:12andrewmcveighIs anyone from clojars.org here? I can't access https://clojars.org from our (shared) IP. Do you run a blocklist?
07:13rritochhydo: accept primitive types which have their own [x symbols.
07:15hydoYes, that does make it a little more clear. and, of course, you were right. The type signature (if you'll let me call it that) is (Item... items), which I'm assuming in java parlance means 'one or more'.
07:35clgvandrewmcveigh: do you use a proxy?
07:36clgvhydo: yes thats the varargs syntactic sugar
07:37andrewmcveighclgv: No. No proxies here.
07:38andrewmcveighclgv: Everything was running fine last night.
07:38clgvandrewmcveigh: you can access the clojars.org implementation on github. I doubt that they run a permanent blocklist.
07:40andrewmcveighclgv: Yeah, I doubt it too, just a bit weird.
07:55mindbender1How do I check if a UUID is valid?
07:55hipsterslapfightmindbender1: you mean to spec for a certain version?
07:56mindbender1hipsterslapfight: yeah
07:56hipsterslapfighthttp://stackoverflow.com/questions/7905929/how-to-test-valid-uuid-guid
07:56hipsterslapfightugh wrong window sorry
07:56hipsterslapfightoh welp this is #clojure and i'm an idiot. sorry mindbender1 :v
07:57mindbender1np. Checking it out. thanks!
08:04mindbender1Is the no clojure library that handles uuid and issues realted to it?
08:04mindbender1*related
08:04clgvclj-uuid was mentioned yesterday
08:22mindbender1clgv: thanks
09:06saltsahello, I had a very strange problem. When using (printf "%s\n" "foo") the texts didn't necessarily printed to the stdout at all. But when using (println (format "%s" "foo")) it worked correctly. Both worked in REPL but when running the software from JAR, it did print nothing.
09:07saltsathis has something to do with the terminal buffering but i'm wondering why it didn't even displayed those messages after the program did exit?
09:10wunkiall of a sudden I keep getting that clojure can't find any java classes
09:10wunkiresulting in errors as: Caused by: java.lang.IllegalArgumentException: No matching method: sha1Hex
09:10wunkianyone have a clue how to debug this?
09:13SagiCZ1are you calling sha1Hex in some interop call?
09:13SagiCZ1seems like you are sending wrong parameters to the method
09:14wunkiSagiCZ1: this is being called in the carmine library (redis)
09:15wunkiSagiCZ1: but even if I remove or change this library, it will spit up a different error in which it says it can't find a java method
09:16SagiCZ1could be some sort of build error.. when this happen i invalidate caches and restart my ide
09:17wunkiSagiCZ1: invalidate caches with `lein clean`?
09:17SagiCZ1are you not using repl for this?
09:17wunkiI can't even get into the repl :(
09:17SagiCZ1and what ide/editor are you using?
09:19wunki`lein repl` in the console and also Emacs/Cider
09:20juliowhat is this channel about ?
09:20SagiCZ1julio: clojure the programming language
09:20SagiCZ1wunki: i guess some people who know more about emacs will help you
09:20julioThank you SagiCz1 !
09:21wunkiSagiCZ1: yeah, but this is not an editor problem. Must be some build artifacts or typo somewhere. But have no clue how to debug this.
09:22SagiCZ1i would check the objects you are passing with the 'type' function to make sure you have correct types of parameters
09:28ppppauli'm having a lot of problems trying to use alts! with cljs
09:28ppppauldoes anyone have any resources they know of that could guide me through?
09:29ppppaulzsh
09:40rritochsaltsa: I would suggest trying a different version of Java, check the output of (System/getProperty "java.vm.version") and make sure that is the same version your running it with. Based on the sources for the latest versions of clojure the only difference between the two methods is they both call java.io.PrintWriter.write but the println also calls java.io.PrintWriter.append to apply the newline.
09:40rritochsaltsa: If that doesn't work you can always try using a new version of clojure. Either way this appears to be a java specific issue as I've never run into this problem.
09:41saltsarritoch: in fact I did notice some differences between jdk 1.6 and 1.8
09:44craigglennieGood morning. I am building a toy webscraper to learn clojure, and I have a list of URLs to process. I’d like to do them in parallel, what’s the best way to go about it? I’m reading about core.async, but also wondering if there’s a simpler parallel map operation available
09:44wunkipmap?
09:44clojurebotpmap is not what you want
09:44wunkihaha, thanks bot
09:46craigglenniewunkl: The docs say it’s “only useful for computationally intensive functions”, but I’m pretty sure I’ll be bounded by network IO. Still, I could try it.
09:49clgvcraigglennie: clojure.core.reducers or maybe core.async
09:49rpaulocraigglennie: you can't do much about the networking part. only amortize the connection setup by reusing the same connection when the URLs point to the same server
09:51craigglennieConceptually pmap seems to be exactly what I want - map my download function over my list of URLs, but in parallel
10:00ppppaul(go (print (alts! (to-chan [1 2 3 4])))) should this work in cljs? i'm only getting errors saying i have an undefined function being called
10:03dnolen_ppppaul: should work, perhaps forgot to :refer something?
10:08ppppaulhttps://gist.github.com/boxxxie/783427920e949eaf70c4
10:09ppppauldnolen_, would you be able to look at that... i've been stuck on this for a whiel :(
10:09ordnungswidrigcraigglennie: IIRC pmap uses a pool that is optimized if cpu bound (cores +2 or like that). I'd expect that core.async will work better
10:10dnolen_ppppaul: looks like you don't know how alts! works yet :) read the docs look for examples
10:10ppppaul:D
10:11ordnungswidrigcraigglennie: maybe this is what you want: http://eng.climate.com/2014/02/25/claypoole-threadpool-tools-for-clojure/
10:11dnolen_ppppaul: (alts! [chan0 chan1 ...]) is the signature
10:11ppppauli tried that as well... let me try again
10:11dnolen_ppppaul: also (alts! [[chan0 value-to-write] ...) works
10:12dnolen_ppppaul: it returns a vector of [value chan]
10:12ppppauli get the same error when i wrap in a vector
10:13craigglennieordnungswidrig: Thanks. I just realised that since I’m using Phantom I probably want a number of browser instances reading URLs off a queue (or similar). So I don’t think pmap would work there (unless the function I supplied instantiated a Phantom instance each time, but that’s going to be slow).
10:14dnolen_ppppaul: update the gist with what you are trying
10:15ppppaulok
10:15ppppaulupdated
10:15ppppauldnolen_, ^
10:19dnolen_ppppaul: gist is not working code, only include the one that you think should work, comment out everything else
10:19dnolen_i.e. don't include multiple failing things
10:19dnolen_only *one*
10:20ppppaulupdated dnolen_
10:21ordnungswidrigcraigglennie: it's not a sin to use the java.util.concurrent classes for such tasks.
10:23dnolen_ppppaul: I'm going to try this - last point about gists - post minimal cases that people can test quickly, all the other dependencies are noise.
10:23ppppauli'll remove them now
10:25craigglennieordnungswidrig: I’ll take a look at that too. Thanks.
10:27clgvcraigglennie: pmap is not what you want. since you probably want to use a couple hundred threads for downloading and processing
10:27clgvpmap only use "processor core count + 2"
10:31dnolen_ppppaul: are you looking at your compile warnings - compiling that gist I get a compiler warning about `to-chan` be an undeclared var
10:31ppppauli added it to the refers
10:32dnolen_ppppaul: gist works fine for me
10:33dnolen_ppppaul: try a `lein cljsbuild clean` perhaps something got in a bad state during your experimentation
10:33ppppaulok
10:35ppppaulomg
10:35ppppaulstuff is working now
10:35dysfuni wish to provide a first run wizard for my ring webapp. i'm reading a config file in the ring init handler, from which i determine if the first-run needs to be run. this is too late to conditionally change which routes are loaded through a simple (def .. (if... . is there a recommended way to handle this?
10:36ppppauli have conflicting emotions at the moment
10:37weavejesterdysfun: You could set a var or atom, and then use a delay to define your handler.
10:38weavejesterdysfun: Or write your own main function that defines your handler function on the fly from a configuration.
10:38dysfunactually, i already have a main(), this is for running from 'lein ring server'
10:38dysfun(because free reloading)
10:38weavejesterdysfun: Well, if you already have a main, you could just add in wrap-reload to get the reloading capability.
10:39ppppaulthanks dnolen_
10:39weavejesterdysfun: Lein-Ring tends to make some flexibility compromises for ease of use.
10:39dnolen_ppppaul: np
10:39dysfunweavejester: *nod*
10:39dysfunokay, well wrap-reload sounds like a great option. thanks
10:40justin_smithsaltsa: use (flush) because printf does not flush automatically
10:40justin_smithsaltsa: that's likely your issue
10:40dysfunweavejester: what does it use to open a browser window?
10:40weavejesterdysfun: Lein-Ring just adds the wrap-reload and wrap-stacktrace functions automatically, but they can be manually added.
10:40weavejesterdysfun: Um, it's in clojure.core. Let me look up the name
10:41weavejesterdysfun: clojure.java.browse/browse-url
10:41dysfunbrilliant, thanks :)
10:42weavejesterIncidentally, I tend to use a pattern like: (fn [config] (routes ...)) in my applications these days
10:43weavejesterSo I generate my routes from a config map, usually supplied by Component
10:43dysfun*nod*
10:43dysfunthat's roughly what i had in mind :)
10:43ordnungswidrigweavejester: interesting, this matches my observation that `defxxx` macros tend to fall short for this kind of "wiring". I moved from `defresource` to `(fn [xxx] (resource ...))` recently.
10:44justin_smith"def* considered harmful"
10:44weavejesterordnungswidrig: Yeah, most of the time I'm not sure if def* macros are worth it. They tend to make things look more magical than they really are.
10:45ordnungswidrigordnungswidrig: and that's not only blunder but also giving you all kind of headaches because you find yourself trapped in macro land.
11:00SagiCZ1no love for defn?
11:02sm0ke,:a/122
11:02clojurebot#<RuntimeException java.lang.RuntimeException: Invalid token: :a/122>
11:02sm0ke,:a/w122
11:02clojurebot:a/w122
11:02TEttingerheh
11:03Bronsa,:100
11:03clojurebot:100
11:03TEttingernamespace rules, weird
11:03Bronsa,::100
11:03clojurebot:sandbox/100
11:03Bronsa:foo/100
11:03Bronsa,m:foo/100
11:03clojurebot#<RuntimeException java.lang.RuntimeException: Invalid token: m:foo/100>
11:03Bronsa,:foo/100
11:03clojurebot#<RuntimeException java.lang.RuntimeException: Invalid token: :foo/100>
11:03TEttingeris that a bug?
11:03sm0kethis is a blocker for me
11:04BronsaI just don't start keywords with a digit and live happy.
11:04sm0ke:D
11:04Bronsadefinitely a bug TEttinger, not sure wich behaviour should be expected between ::100 and :foo/100 though
11:04zB0hsis there a way to have lein-exec pull deps from project.clj rather than having to explicitly specify in your clj file?
11:05puredangerkeywords/symbols with a leading digit currently work by accident
11:05TEttingera happy accident?
11:05puredangeri.e., the regex accidentally allows it by backtracking
11:06puredangerI pushed a fix for that in 1.6 and we discovered that it broke a lot of people's code so we reverted
11:06sm0kepuredanger: is it intentionally disallowed for something like ##:a/11aa
11:06TEttinger,:a/122
11:06clojurebot:a/122
11:07TEttingerdone
11:07sm0kewhat
11:07sm0ke,:a/11
11:07clojurebot#<RuntimeException java.lang.RuntimeException: Invalid token: :a/11>
11:07sm0ke,:a/122
11:07clojurebot#<RuntimeException java.lang.RuntimeException: Invalid token: :a/122>
11:07TEttingersm0ke, there's a \ufeff in there :P
11:07puredangerI'd say the behavior and docs are inconsistent around all of it
11:07sm0ke:D
11:07puredangerthere is a ticket to clarify the docs and make the regex intentionally admit what we support
11:08Bronsapuredanger: this is where having a reader spec would help. if it was clear from the start what is allowed and what is not we could just tell those people "sorry, you have a bug"
11:08puredangerI'm not arguing
11:09puredangerhttp://dev.clojure.org/jira/browse/CLJ-1286
11:09devnim glad that it hasn't been nailed down 100% TBH
11:09devnbut it might be time...
11:12puredangerBronsa: I was looking at the reduce stuff in that range ticket just now… the difficulty is that the new LongRange implements both IReduce (when reducing over the sequence) and IChunk (when serving as one chunk of a chunked sequence) and those two forms of .reduce() have different semantics wrt reduced right now
11:12Bronsapuredanger: ouch.
11:12puredangerthe code in the ticket is essentially aligning them on a single semantic
11:12Bronsapuredanger: an IChunk RangeSeq is out of the question?
11:13puredangerthere are several possible ways to resolve it
11:14puredangerfor example not using the same class for both purposes or allowing it to support both senses (although the code is otherwise identical, so that's annoying and confusing)
11:14Bronsapuredanger: I'm obviously not the one to make those decisions but it's my opinion that a correct approach, whatever it may be, doesn't require users to explicitely (preserve-reduced f) on .reduce
11:14puredangerI think it's fairly confusing to have two interfaces with a reduce() method that have different semantics
11:15Bronsapuredanger: right I'd be much happier with IChunk/chunk_reduce
11:15puredangerthat is another option
11:15puredangerbut it breaks any external impls of IChunk (if there are any)
11:15Bronsapuredanger: gvec is the only one I'm aware of
11:15puredangerI mean external to clojure itself
11:15Bronsaright, core.rrb-vectors and stuff
11:16puredangerthere is both gvec's ArrayChunk and PV's ArrayChunk
11:16puredangerof course, changing the semantics of reduce() also potentially breaks external users
11:16puredangers/users/implementers/
11:16puredangeror maybe both :)
11:19saltsajustin_smith: yeah, flush is, but should those buffers be automatically flushed when the program exists? The stdout is just a normal terminal.
11:20justin_smithsaltsa: I think the OS will gladly throw away your resources, including your output buffer
11:20Bronsapuredanger: FWIW a quick search on github for c.l.IChunk hasn't shown any users other than from clojure forks. rrb-vectors itself is not using it
11:21saltsajustin_smith: I'm quite sure some other programming languages will always flush the output. But at least changing that printf to println fixed it
11:21justin_smithsaltsa: like I said, you can just call (flush)
11:22justin_smithor, that's what I tried to say, at least
11:23justin_smithsaltsa: also, if you ended the printf with a \n that may have gotten an auto-flush. Not sure of that though.
11:28joobusis aleph the 'event-driven' framework for clojure?
11:29joobusand does one need to worry about threads in clojure when serving a web site? I've been reading about java having support for lightweight threads in the jvm, so I'm not sure I need to worry about serving one thread per request.
11:30justin_smithjoobus: there are thread-pools, but no out of the box lightweight threads. They are just OS threads.
11:30justin_smithhttp-kit and aleph use pools iirc, jetty uses a thread per request (re-used out of a pool)
11:31joobusi'm trying to determine if i need to go the way of aleph, or if serving ring/http-kit behind nginx is good enough
11:31justin_smithyou need nginx no matter what I would say
11:31justin_smithit has security features that the other web servers don't provide
11:32joobusright now i use twisted in python which requires writing all code a certain way to handle deferreds, and I don't know if there is huge benefit to aleph over http-kit
11:32joobusi agree on nginx's other features
11:32justin_smithalso, aleph is not a framework, it's a server
11:33justin_smithaleph uses netty: http://netty.io/wiki/thread-model.html
11:34justin_smiththat isn't the right page for info about their thread usage actually...
11:34justin_smithyeah, it looks like netty uses a thread-pool
11:40kenrestivowhat reference type would you recommend for holding a mirror of external state, but which will get updated every few milliseconds with a polling loop. the state will need to be both read and written from the application
11:41kenrestivoin other words, i have to poll, but also need to write. either i'll be updating it or the external world will be. and writes will be a transform of the existing (external) state
11:43justin_smithan agent makes sense (with both the polling process and your app's own logic updating the agent state)
11:43justin_smithatoms would introduce retries, which seems like a bad idea for your use case
11:43justin_smithas would refs
11:44kungiI am trying to use the component / reload workflow with this example. When I run `lein repl` `go` and then change any println statement ant then `reset` no changes occur. What am I doing wrong? https://gist.github.com/Kungi/47493fbb9de4aadc0629
11:50nboskovicWhich should I get, On Lisp, ANSI Common Lisp or SICP?
11:51kunginboskovic: On Lisp is for free, SICP is also free, and the other one I don't know.
11:52nboskovicYes, I know
11:52nboskovicI'm saying though
11:52justin_smithsicp is the better of the three
11:52nboskovicIF you had to pick one, which one would it be? I'm at the Uni and while I would love to print them all out, there's only so much time in one day
11:53kunginboskovic: I would get SICP
11:53kunginboskovic: Or save time and get a copy from Amazon
11:54nboskovicheh, well
11:54nboskovicIt would take weeks to get here if it got here at all
11:54kunginboskovic: Ok where is here?
11:54nboskovicArgentina
11:54justin_smithsplit the difference and get a semi-decent ebook reader and load up all those free books?
11:54justin_smithjust a thought
11:54nboskovicOur customs agency is pretty terrible
11:54nboskovicI had a kindle once
11:55justin_smithhow was it?
11:55nboskovicSmall
11:55nboskovicI'd rather have technical books in paper
11:55nboskovicIt's better for notes and stuff
12:00nboskovicI can print out 5k pages per month as long as I provide the paper, which is dirt cheap anyways, so I might as well take advantage of it
12:01justin_smithnboskovic: yeah, with my favorite books I can actually find frequently needed info based on marks or tears on the pages
12:01justin_smithnboskovic: maybe we need an ebook reader that adds entropy to frequently accessed pages to make them stand out in the TOC
12:01nboskoviclol
12:01nboskovicNothing beats paper imo
12:02justin_smithpaper is great
12:02justin_smithsometimes I print out code to go over it with a pencil away from a screen
12:02nboskovicThe only thing that could surpass paper is some kind of virtual reality environment where it feels like you're reading paper anyways
12:02justin_smithI am doing a project where I am going to need to write TANDY basic, and I am going to do everything in paper first because basic sucks so much
12:02nboskovicyeah, that's how I solve my hardest problems usually; though I write it down by hand
12:02nboskovicOuch
12:03bja_I hate paper. If I can't use regex search on it, I'm not interested
12:03nboskovicThat's one advantage to digital media
12:03justin_smithbja_: clearly you don't have the pcre ocular implant
12:03justin_smithlife changer
12:03kungiI would like to have both. Write on the paper and transfer the notes into the eBook
12:03bja_(inc justin_smith)
12:03lazybot⇒ 157
12:03kungiThis would be awsome
12:03nboskovicsome day, that will be something
12:03justin_smithwe can only hope!
12:04nboskovicProbably sooner than we think
12:04kunginboskovic: There was a company creating pens which record what you wrote
12:04justin_smithwe have wetware that greps for faces
12:04kungiBut they destoryed themselves
12:04bja_in the meantime, I have interns who have OCR software and a scanner
12:04nboskovicI remember that.. shame, really
12:04kungiLivescribe was awsome
12:05TEttingerkungi, it would be awesome to have a live scribe, a dead scribe doesn't sound useful
12:05nboskovicWell, if the technology exists it could be rebuilt
12:05justin_smithTEttinger: leaving one around just sounds depressing!
12:05kungiTEttinger: is there an english word for the german carnival Tata tata ...
12:06justin_smithkungi: maybe Ba-Dum-Tish
12:06TEttingerkungi, as I understand it, there are lots of german words with no english equivalents (Weltschmerz)
12:06TEttingerZeitgeist
12:07kunginboskovic: It's called dot-paper or donane paper afaic. You have a nearly invisible dot pattern on the paper and your pencil has a camera recognizing the pattern.
12:07nboskovicYeah, I'm looking it up
12:07justin_smithTEttinger: don't be silly, Zeitgeist is just timeghost
12:07nboskovicI was wondering
12:07kungiWe only need to print books with pattern and have an appropriate ebook then -> BAM!!!
12:07justin_smith /s
12:07TEttingerthough both of those are compounds, and "spirit of the times" is pretty close
12:07nboskovicyou could probably have a pen with a small gyroscope on the tip
12:07nboskovicthen record the movement when you're writing
12:07kunginboskovic: then you dont't know where you are in the book
12:08justin_smithTEttinger: but timeghost sounds so much more awesome, like something from Adventure Time
12:08nboskoviclooks like gyroscopes are too big atm
12:08TEttingerheh
12:08nboskovicyou'd have to have a pen, a gyroscope and a recorder/transmitter
12:08nboskovicfor the movement
12:08justin_smithnboskovic: accellerometers are pretty miniaturized though
12:09TEttingerswedish has the interesting word "lagom" (might be missing a mark)
12:09justin_smithnboskovic: and iirc they are mady with super tiny gyros + super sensitive pressure sensors
12:09justin_smithnboskovic: and more to the point, an accellerometer in a pen tip would basically do what you want I think
12:09kungi\o/ It is made of wörkings!
12:10nboskovicGood
12:10nboskovictime to patent it
12:10justin_smithhttp://en.wikipedia.org/wiki/Digital_pen too late
12:11nboskovicwelp
12:11kungiNote to my future self: when you have a dev/user.clj file you should include it into tools.nrepl .... refresh. If not everything breaks.
12:11justin_smithkungi: so that was your reloaded issue?
12:11justin_smithmakes sense I guess
12:11kungijustin_smith: yes
12:11nboskovicbut wait, those seem to be more like wacom-style pens
12:11justin_smithnboskovic: it's all varieties
12:11justin_smithincluding wacom and standalone
12:11justin_smithit's wikipedia after all
12:11nboskovictrue
12:12nboskovicthe maxell penit looks good
12:12kungijustin_smith: this issue took me nearly the whole day. And I was starting to question my sanity.
12:12justin_smithkungi: that always sucks
12:12nboskovicdoesn't seem to be on sale though
12:13kungijustin_smith: Yes especially if you start to minimize and minimize and then you have less than half a page of code and still can't see the error
12:45ppppaulwhen making macros in cljs, do i have to make them in a clj file?
12:50edbondppppaul, yes
12:51ppppaulok
12:53Bronsadnolen_: do you have a testcase for MATCH-98? I'm curious to see if the patch for CLJ-979 fixes that
12:54Bronsaamalloy_: kinseapo is the daily spammer
12:54dnolen_Bronsa: ticket has a test case http://dev.clojure.org/jira/browse/MATCH-98
12:55Bronsaah, should have looked at it, thanks
12:56dnolen_Bronsa: let me know if your patch fixes, this definitely a years old infuriating bug
12:57dnolen_Bronsa: if it fixes, might be worth mentioning that all the AOT bugs in core.match pretty much boiled down to multimethod + classes
12:57Bronsadnolen_: yep it does
12:58dnolen_"worth mentioning to puredanger"
12:58dnolen_Bronsa: wow, thanks for verifying
12:59Bronsadnolen_: uhm wait I might have spoken too soon. it fixes an issue but not 100% sure it's that one
12:59dnolen_heh ok
12:59Bronsadnolen_: (compile 'clojure.core.match) w/o that patch throws java.lang.NoClassDefFoundError: clojure/core/match/protocols/IPatternCompile, w/ patch completes
13:06seangroveBronsa: Looking at https://github.com/clojure/tools.analyzer, it references create-var, but I'm not clear on what that should be
13:07seangroveBronsa: Sorry, nevermind, just looked at the source
13:12pandeirois it possible to do the clojure CA online now?
13:16joegallopandeiro: i googled "clojure ca" and got to http://clojure.org/contributing
13:16joegallothen searched in the page for 'online' and found https://secure.echosign.com/public/hostedForm?formid=95YMDL576B336E
13:16joegalloso i believe the answer is yes
13:17pandeirojoegallo: yeah i'm there i just wanted to make sure this was actually valid in place of mailing it in
13:18pandeiroi did it already, so i hope so :)
13:23EvanRi did it, i overwhelmed vim clojure-static's ability to format my indentation with ==
13:23EvanRtoo many levels of brackets i guess
13:26Bronsadnolen_: still not sure, will investigate better the interaction between defmulti/class literals/AOT tomorrow and let you know if there's an obvious fix on the clj side. I remember investigating this months ago but I don't remember what I found out.
13:27TEttingerEvanR, split up some logic then? ouch...
13:27Bronsaseangrove: in case it helps, in t.a.jvm create-var is ~ intern, in t.a.js it just returns a "var" map
13:28Bronsaseangrove: in t.a when I write "var" (not capitalized) I don't mean a Var. it means some kind of object that the platform uses to hold a def init, in clj it's a Var in cljs it's a map in the compiler env
13:28EvanRTEttinger: well, its a big nested data structure, but yeah i plan to split it up
13:28EvanRits easier for me to read sometimes if its all expanded into one big record (with proper indentation)
13:28TEttingerif a nested data structure gets too big it can't be read by the JVM
13:29TEttingerthe example I found this in was https://dl.dropboxusercontent.com/u/11914692/weapons-map-too-large.clj
13:29EvanRok but ... its an element of a map that ends with }}]]]
13:29EvanRafter that point the other elements dont indent
13:29TEttingertrying to parse one huge map didn't work
13:29EvanRso its 5 or 6 levesl deep
13:30EvanRi think its an inefficiency in the implementation of the clojure static auto indenter
13:30TEttingerIIRC, that map is only 100 elements of 72-key maps
13:31EvanRwhats the problem? that his weapons map *literal* has too many keys?
13:31EvanRthats ridiculous
13:32EvanRsurely runtime maps and serializations can support more
13:32TEttingeryeah, it works if you split it up, but not as one literal
13:32TEttingerhttps://dl.dropboxusercontent.com/u/11914692/weapons-map.clj works
13:32EvanR;_;
13:33EvanRkinseapo is spamming
13:33TEttingeryep
13:33EvanRanyway, i have 4 keys, but like 5 levels of nesting
14:24dmahantaif we have two list listA and listB i want to do this map fn listA, but fn need listB everything whats the best way to do it, is global variable the only way
14:26Gay-championanyone here is a programmer unity 3d? 9àè
14:28TEttingerdmahanta: you can use a let binding to make a local "variable"
14:37kungi
14:39Gay-championWho is a transexual gay here ? 9à9
14:40kungiGay-champion: I don't think sexuality is of interest in this channel
14:56amalloyEvanR: i don't see kinseapo in this channel at all. kicked already?
15:06sg2002 Hey guys. What's the best tagging application for clojure src? It seems that neither ctags nor etags, nor gnu global support clojure out of box...
15:06arrdempuredanger: is "not trivially portable to cljs" a legitimate criticism of a feature at this point in time? Kicking around the numerics patch since it's something I've done worse before.
15:13puredangerit's a consideration, surely. I'm not too concerned with whether it's "trivial" or not. certainly we should be considering portability for anything like that.
15:16puredangerI haven't talked to Rich about it, no idea what his opinion would be. I could see him going either way.
15:17EvanRis there a way to multi-line comment, such as a section of a map literal (in which case #_ does not work)
15:18justin_smith#_( ... ) works
15:18justin_smithjust remember to remove the parens with the #_
15:18amalloyEvanR: there is no multi-line comment except those that work on single sexps
15:18EvanRtrying that
15:19justin_smith&{:a 0 #_(:b 1 :c 2)}
15:19lazybot⇒ {:a 0}
15:19EvanRworks
15:20puredangeryou could put " " around the whole thing :)
15:20EvanRnot in a map literal
15:20puredangerwell, then #_" "
15:20amalloypuredanger: also no good if there are any strings inside
15:20puredangeryou people are too smart
15:21amalloythe parens are nice because it only requires N well-formed sexps
15:21EvanRas opposed to infinite?
15:22amalloyEvanR: infinite??? as opposed to needing sexps that don't have string, or aren't in a map literal, or...
15:22EvanRnevermind
15:30TimMc,[1 2 #_#_#_#_ 3 4 5 6 7] ;; EvanR
15:30clojurebot[1 2 7]
15:31EvanRhmm
15:33TimMcLet me just trot out one of my favorite weird syntax things...
15:34TimMc,(#(+ 1 2 #_ %4) :a :b :c :d)
15:34clojurebot3
15:38hyPiRionTimMc: That's a nice find
15:38coffeeElfHello All
15:38TimMcSomeone showed it to me a year or two ago.
15:39coffeeElfI am new to IRC and trying to learn Clojure
15:39coffeeElfKnow a bit of java
15:40coffeeElfCan Clojure functions have names like 'str->int' ?
15:40justin_smithyes
15:40coffeeElfSo it is just a name, no speacial meaning to that arrow !!
15:40EvanRbut not int<:real
15:40justin_smith,(defn str->int [s] (Integer/parseInt s))
15:40clojurebot#'sandbox/str->int
15:40justin_smith,(str->int "1")
15:40clojurebot1
15:40justin_smithright
15:41coffeeElfthanks guys
15:41coffeeElfsandbox is the name space ?
15:42justin_smithyes, it is clojurebot's namespace
15:42TimMchyPiRion: Clearly the solution to the problem of positional args in fn literals is to keep track in a monad.
15:42justin_smithand #' indicates a var
15:42hyPiRionTimMc: exactly that
15:43TimMcI still don't quite understand monads but at least I know when I could be using them!
15:44amalloyyou can tell what issues i just love bringing up, because chrome autofills "d" to dev.clojure.org/jira/browse/CLJ-865
15:44coffeeElf (defn str->int [str] (Integer. str))
15:44coffeeElfWhat does that function body do exactly ?
15:45justin_smithit calls the Integer constructor
15:45coffeeElf(Integer. str) ?
15:45justin_smith,(Integer. "1")
15:45clojurebot1
15:45justin_smithclassname followed by . indicates that you are calling the constructor
15:45justin_smith$google clojure java interop
15:45lazybot[Clojure - java_interop] http://clojure.org/java_interop
15:45coffeeElfcool
15:45EvanR,(number "1")
15:45clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: number in this context, compiling:(NO_SOURCE_PATH:0:0)>
15:45EvanR,(int "1")
15:45clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Character>
15:46justin_smithcoffeeElf: see the above link for the official intro
15:46justin_smith(to instantiating java classes in clojure code, and using their methods)
15:46verma,(Integer/parseInt "11")
15:46clojurebot11
15:46andyfEvanR: Emacs, vim, and most or all code editors can prefix or remove comments from contiguous range of lines with a few keystrokes. Good to learn those, and avoid fancy tricks, IMO
15:47EvanRandyf: well, the comments have to exist before that can be removed with a single keystroke, so i used #_( .... ), though i dont know how to remove this in vim at the moment
15:48EvanRsince the inside is not a single expr
15:48coffeeElfThanks Justin
15:48justin_smithEvanR: he's referring to "comment region" - which I am sure fireplace can do
15:48justin_smithcoffeeElf: np
15:50coffeeElfLooks like this this chat also works as a REPL :)
15:51coffeeElf(println "Hello")
15:51coffeeElf,(println "Hello")
15:51clojurebotHello\n
15:53amalloycoffeeElf: if you're going to use him as a repl, rather than to assist in demonstrating something or asking a question, please do so in /msg
15:53justin_smithI hear it is possible to run a repl locally too
15:54crash_epDoes anyone know if there is a way to get Midje to evaluate the `msg` parameter to `fact`?
15:54coffeeElfWill do, was just trying to check if this really is a REPL
15:54EvanRis Integer/parseInt a static method
15:54crash_epIn my case it is a symbol that points to a string, not a string literal…
15:54coffeeElfhave a REPL running on my PC
15:54coffeeElfThanks guys
15:54justin_smithEvanR: yes it is
15:55EvanR,(Integer/parseInt "abc")
15:55amalloycoffeeElf: it's not a very good repl, really. if you try to print long or deep lists he'll balk, and he'll forget anything you've def'd within a few minutes
15:55clojurebot#<NumberFormatException java.lang.NumberFormatException: For input string: "abc">
15:55EvanRamalloy: a time limit just makes you better, like practicing basketball with a way smaller hoop, or training in the hyperbolic time chamber
15:56EvanRor using dynamic types for everything
15:59poushkarcould someone look at small function please? https://gist.github.com/vitaly-pushkar/efb19a69232f4cc1ba6d
15:59poushkarI don’t get why it’s failing
15:59TimMcEvanR: oh snap
16:00TimMcpoushkar: Is this a CLJS thing? What call are you making? What do you expect to have happen?
16:01poushkar@TimMc yes, sorry, it’s cljs. I expect it to return all values from atom if it’s called without arguments, and filtered version of first case if called with argument
16:01justin_smithpoushkar: it looks like you are providing get-entries where your code expects (get-entries x)
16:01justin_smithpoushkar: that's my best guess at least
16:03poushkar@justin_smith well, I am expecting it to accept both zero or one agrument
16:03justin_smithpoushkar: that's not what I am talking aout
16:03justin_smith*about
16:03justin_smithI mean that the error is saying get-entries, the function, is not a sequence
16:04justin_smithbut it would return one
16:04EvanRi havent used joda time, is clj-time doing very much as a wrapper?
16:04justin_smithso likely something is getting get-entries where you meant to give it the return value of calling get-entries
16:04justin_smithif you want to provide no args, the syntax is (get-entries)
16:05poushkaroh, I see, let me try
16:05poushkaryes, that works! thank you @justin_smith
16:06justin_smithnp. Just remember that clojure doesn't implicitly evaluate very often, you almost always need () to make evaluation happen
16:06justin_smithsorry s/evaluation/invocation/g
16:08poushkaryeah, spent on it like 20 minutes, gonna remember that forever now :D
16:09EvanRand putting extra ( ) around stuff is usually bad
16:09justin_smithright, unless you want an extra invocation to happen of course
16:24mikerodI have been messing around with emacs-live and it has some "save hook" type of function that removes all trailing whitespace in a given file when I hit save - this is then not even undo-able.
16:24mikerodAnyone have an idea what is causing this? This actually isn't great when we don't want git to show all these white space changes in big files.
16:24mikerodI believe (haven't tested) it is specific to clj files
16:25mikerodI'm not sure where this falls in the emacs structure
16:25justin_smithmikerod: try M-x describe-variabe after-save-hook
16:25mikerodI know this isn't strictly clj related, but emacs-live is mostly meant for clj dev with cider and some extra configs
16:26justin_smithmikerod: it may also be hooking into something clojure-mode specific, but I would check after-save-hook first
16:27CaptainLex|2I'm having trouble with splitting a pipe-delimited string. The regex for matching a pipe doesn't even seem to work escaped
16:27sg2002mikerod: Search for 'delete-trailing-whitespace
16:27CaptainLex|2,(clojure.string/split "Hello!|World?" #"\\|")
16:27clojurebot["" "H" "e" "l" "l" ...]
16:28EvanR,(split "a|b|c|d" (re-pattern "|"))
16:28clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: split in this context, compiling:(NO_SOURCE_PATH:0:0)>
16:28EvanR,(clojure.string/split "a|b|c|d" (re-pattern "|"))
16:28clojurebot["" "a" "|" "b" "|" ...]
16:28EvanRdouble fail
16:28justin_smith(= (re-pattern "|") #"|")
16:29justin_smith,(= (re-pattern "|") #"|")
16:29clojurebotfalse
16:29justin_smithhm
16:29justin_smiththat surprises me
16:29EvanRobject equality
16:29justin_smithof course
16:29dnolen_getting excited about adding cata-matching to core.match a la Friedman et al
16:29justin_smith,(clojure.string/split "a|b|c|d" #"|")
16:29clojurebot["" "a" "|" "b" "|" ...]
16:29justin_smith,(clojure.string/split "a|b|c|d" #"\|")
16:29clojurebot["a" "b" "c" "d"]
16:30CaptainLex|2Gah!
16:30justin_smithEvanR: was the latter what you wanted?
16:30justin_smithor CaptainLex
16:30CaptainLex|2The latter was what I wanted, yes
16:30mikerodjustin_smith: sg2002 both of these were helpful. I ended up finding it i think under the `before-save-hook` actulally though
16:30CaptainLex|2Why was I double-escaping it?
16:30mikerodemacs-live has this `live-cleanup-whitespace` there
16:30mikerodI think it is the culprit
16:30mikerodnow to find the graceful way to disable that
16:30justin_smithCaptainLex: #"" is special, it makes it so you can use \ instead of \\
16:30EvanRyou were trying to match literally a backslash followed by empty string
16:31EvanRi mean, backslash OR empty string
16:31justin_smith(re-pattern "\\|") would have worked too
16:31CaptainLex|2Well, wow, thanks guys!
16:31CaptainLex|2That's been driving me crazy for the better part of two days at work
16:31CaptainLex|2Not two days straight of regexes
16:31CaptainLex|2just two days of getting frustrated and doing something else
16:32mikerodLooks like `(remove-hook 'before-save-hook 'live-cleanup-whitespace)` worked nice :)
16:33justin_smithoh, of course it would have to be before-save-hook, because otherwise it would make the change after you save...
16:34mikerodjustin_smith: that's sort of what I thought :P
16:41amalloymikerod: if you commit files with trailing whitespace you're an infidel, though
16:42amalloyhuh. i just noticed the roots of "infidel". not believed? not believing? i guess it must just be nonbeliever
16:43mikerodamalloy: I don't like it either
16:43mikerodI'm competeting with Eclipse CounterClockwise formatter
16:43mikerodit likes to put a bunch of whitespace on empty lines
16:44mikerodto align with the lines around them
16:44mikerodthis save hook for emacs-live destroys those too
16:44mikerodAnd I don't think the CounterClockwise stuff is configurable at that level, but emacs is. So I lose since I can change it in emacs to match the ccw users :P
16:45justin_smiththe answer is to switch to ed, and then everybody needs to switch what they do to be ed compatible
16:45mikerodhmm
16:46TimMcjustin_smith: I don't think anyone needs to switch. ed is the standard text editor. It can handle anything other editors produce. Ed is the standard text editor.
16:46mikerodI thought it has been decided that Emacs is the best editor - siting my source of http://xkcd.com/378/
16:47justin_smithM-butterfly is gibberish :P
16:47amalloyyou don't have a butterfly key, justin_smith?
16:48justin_smithhah - and here I thought that was the windows logo
16:48amalloya common mistake
16:49amalloythe apple logo looks a bit like a butterfly too. coincidence? i think not
16:50mi6x3mhey Clojure, any list of leiningen templates available?
16:51amalloymi6x3m: https://clojars.org/search?q=lein-template
16:51amalloybased on the lein docs, which say "All lein templates have an artifact-id of "lein-template", and are differentiated by their group-id, which always should match the project for which they provide a template."
16:52amalloy(from https://github.com/technomancy/leiningen/blob/stable/doc/TEMPLATES.md)
16:52mi6x3myes, this sounds reasonable :)
16:57noncom|2how do i make uberjar consider the projects in the checkouts dir ?
16:57noncom|2looks like it just ignores them...
16:57noncom|2am i obliged to lein install them ?
16:58arohnerhuh. test.check gen/pos-int includes zero as a positive number
16:58hiredman:(
16:59hiredmanare you sure?
16:59arohneruser> (gen/sample gen/pos-int)
16:59arohner(0 0 0 3 4 5 5 6 5 2)
16:59TimMcheh
16:59hiredman:(
16:59arohnerthe bug is pos-int is an alias for gen/nat
16:59hiredmanhttps://github.com/clojure/test.check/blob/master/src/main/clojure/clojure/test/check/generators.clj#L344-L350
17:00TimMcI think test.check would have foudn that with some generative testing. :-P
17:00hiredmanneg-int will also generate 0
17:00arohneroh, wiki "There is no universal agreement about whether to include zero in the set of natural numbers"
17:00hiredmanthere is s-pos-int
17:00arohner:(
17:01TimMcI feel like distinct-by should be a thing.
17:01TimMcDoes this feeling mean I am forgetting about some other fn?
17:03EvanRarohner: probably a good idea to include zero
17:03EvanRunless you have a reason not to
17:03arohnerEvanR: why?
17:03mi6x3manyone around using lein oneoff by any chance?
17:03arohnerwe already have gen/int, gen/nat
17:03amalloyTimMc: (flatland.useful.seq/groupings f (fn [a b] a) nil xs) kinda does this
17:03mi6x3mI keep getting FileNotFoundException when I try to execute my script
17:03amalloyno, i guess it doesn't
17:04EvanRarohner: well, practically, youd need to have another type like "Nat or zero" for most programming cases where you would use this type
17:04TimMc&(map first (vals (group-by even? (range 10))))
17:04lazybot⇒ (0 1)
17:04arohnerEvanR: nat includes zero
17:05EvanRgood
17:05EvanRi was refudiating the wiki quote above
17:05TimMc...but that accumulates values that should be tossed immediately, which could be unsuitable from some purposes.
17:06EvanRneeds more lazy
17:06amalloyTimMc: i've certainly written distinct-by myself. http://amalloy.hubpages.com/hub/The-evolution-of-an-idea is a blog post i wrote ages ago, with a version of distinct-by that also allows you to keep up to N items in each bucket, instead of just 1
17:09justin_smithgithub formatting is still screwed https://github.com/clojure/data.csv/blob/master/src/main/clojure/clojure/data/csv.clj#L91
17:09TimMcew
17:09amalloythat's actually a whole different problem, isn't it?
17:10justin_smithyeah, may be a new one
17:10amalloythe recent problems have just been styling the parsed language; this looks like a problem with parsing it
17:10justin_smithis there a place where we report those now?
17:11amalloyjustin_smith: just drag complaints into the file labeled Recycling Bin
17:12justin_smithoh I've got to get me one of those - I assume a symlink to /dev/null would work?
17:15andyf
17:16ppppaulhow do you spell cognitech? i'm doing google searches and only coming up with some forensic websites
17:17zerokarmaleftcognitect
17:17ppppaulthansk
17:19EvanR,(sequential? {})
17:19clojurebotfalse
18:12seangrove,(let [print str] (resolve 'print))
18:12clojurebot#'clojure.core/print
18:12justin_smithresolve wouldn't ever work on let bindings would it?
18:13arohner,(doc resolve)
18:13clojurebot"([sym] [env sym]); same as (ns-resolve *ns* symbol) or (ns-resolve *ns* &env symbol)"
18:13arohner,(doc ns-resolve)
18:13clojurebot"([ns sym] [ns env sym]); Returns the var or Class to which a symbol will be resolved in the namespace (unless found in the environment), else nil. Note that if the symbol is fully qualified, the var/Class to which it resolves need not be present in the namespace."
18:13amalloyjustin_smith: indeed not
18:13seangroveI'm not clear on why though
18:14amalloyseangrove: because locals aren't vars
18:14seangroveamalloy: Ah, ok
18:14amalloyand resolve looks up vars
18:15seangroveamalloy: Let me check a few things and I'll have a follow up :)
18:31nicferrierdealing with OS processes in clojure looks hard.
18:32justin_smith(.run (ProcessBuilder. "ls" "-l"))
18:32justin_smithor you can just use clojure.java.shell of course
18:32justin_smithbut that's not as flexible
18:32nicferrierjustin_smith: yeah. we talked yesterday. I'm using conch.
18:32justin_smithgot it. I decided pretty quickly using ProcessBuilder / Process was easier than using conch myself
18:33nicferriermy current problem is that I want to start a bunch of processes and do something when one of them finishes.
18:33nicferrieryou can't future it because you can't do the equivalent of alt! with futures.
18:34nicferrierit looks like I have to allocate a thread just to run each process, or at least to collect it's exit.
18:34justin_smithsounds like you want a collection of processes, and a loop where you check .isAlive on each process? probably paring each process with the function to call when it finishes
18:34justin_smiththen sleep and loop again, of course
18:35nicferrieryeah. that sucks. I might as well have used java.
18:35justin_smithwell, this part is java. clojure has nothing nice beyond the java apis - but clojure has better tools for using those apis though
18:35nicferrierbut not in this case.
18:35nicferrierhey ho.
18:36amalloyclojurebot: clojure |has| nothing nice beyond the java APIs
18:36clojurebot'Sea, mhuise.
18:37justin_smithnicferrier: what I mean by better tools is the general lispy abstractions you can use. conch makes a decent attempt but doesn't really address your use case.
18:38nicferrierjustin_smith: I think this shows a poor future api.
18:38nicferrierI can't see how the poor future api is compensated by the core.async stuff.
18:38nicferrierprobably it is more than compensated normally, just the case of external processes is weak.
18:38nicferrierit is a bit odd I guess.
18:39nicferriersorry, I'm just moaning really I guess.
18:39justin_smithnicferrier: I have the very early stages of a "process graph" lib that would create the equivalent of shell pipelines, but made out of a clojure datastructure so that individual parts can be reconnected / teed off / restarted as needed. It's really not near usable yet though.
18:40nicferriersounds cool.
18:41justin_smithbut I resigned myself that it needs a nanny thread that moves the data between the processes. Or even if it goes into parallel paths it would need one nanny per branch.
18:41nicferrierone thread per process?
18:41justin_smithbut that's better than one extra thread per process at least
18:41justin_smithno
18:41justin_smithone per parallel path
18:41justin_smithremember I mentioned tees :)
18:41nicferriernot sure how you're going to tell when they finish.
18:41justin_smithso if it is linear, you only need one nanny
18:42justin_smithnicferrier: (.isAlive proc)
18:42justin_smiththe api is really small file:///home/justin/java/doc/api/index.html
18:42justin_smitherr, sorry, bad link
18:42nicferrierit's not like waiting on the exit status though.
18:42justin_smithhttps://docs.oracle.com/javase/7/docs/api/java/lang/Process.html
18:42justin_smithnicferrier: no, this is for processes I expect to stay alive for a long time
18:43nicferrierisalive isn't in j7
18:44justin_smithwow, that is surprising, and also sad
18:44nicferrierit's a j8 thing?
18:44justin_smithyeah, that leaves you in a tough place if you don't want a nanny thread per process
18:44justin_smithI guess so
18:44amalloyis justin_smith running java 9 or something? i remember another suggestion recently for something that doesn't exist yet
18:45justin_smithhaha - .isAlive does exist in java 8
18:45nicferrierguess your api won't work then.
18:45nicferrier:-)
18:45amalloyi'm on java 34 now
18:45nicferrierchrist. I hope it's dead by then.
18:47nicferrierI guess I just need a thread per process.
18:47justin_smithwhat about checking if the output stream is closed? that's a hack I guess
18:48nicferrieryes. definitely.
18:48nicferrierunix is hard. doing anything but exit status makes it harder.
18:49nicferrierI wouldn't trust any polling particularly.
18:49justin_smithwhat does .exitValue return for a running Process?
18:49nicferrierit doesn't.
18:49nicferrierit excepts.
18:50nicferrierI should have said "Maybe" that would have been a nice haskell joke.
18:50justin_smithputting a try/catch on that would be yet another disappointing hack of a way to do it
18:51nicferrierdon't see that's any better than (and @one @two @three) ?
18:51justin_smithless threads used. But yeah, just use futures unless you have hundreds of process I guess.
18:52nicferrierwhy less threads?
18:52nicferrieroic. right.
18:53justin_smithyou could launch the process inside something that returns you the PID, then you could use a shell call to check if that PID is live
18:54nicferrierno. that would be terrible.
18:54nicferrieryou've got the process handle from launching it! so wasteful not to use it.
18:54justin_smithbut the information actually needed is obfuscated
18:54ffwacomdoes future pull from a thread pool or does it always create a new thread?
18:54nicferrierpossibly using a thread to poll the exitValue and send a message to a channel.
18:54nicferriersigh.
18:55justin_smithffwacom: thread pool
18:55nicferrier^^
18:55nicferrierbut it's so annoying you can't resolve on a bunch of futures.
18:57nicferrierwhen a future is "promised" it's mapped to a thread, right?
18:57nicferrierthe thread is taken all the time the future is extant.
18:58justin_smithyeah, futures don't jump between threads.
18:59justin_smithand they don't let go of them until fully completed
18:59nicferriers'what I thought.
19:01nicferrierthey complete though without specfically derefing them. right?
19:02nicferrierso my future could be (future (go (>! exit-channel (.waitFor proc))))
19:02nicferrierand I don't then have to block on all of them
19:02amalloyfuture (go ...) looks like a bad plan
19:03nicferrierok. (future (>!! exit-channel (.waitFor proc)))
19:03amalloyyeah, i think you have to do like that
19:03amalloyor even (thread (>! ...)) is probably fine, right?
19:03nicferrierdon't think it matters.
19:04nicferrieridk. can't find the doc for fn thread :-)
19:04amalloythread is supposed to be like go, except that it uses a thread from the future pool instead of the core.async pool
19:04amalloysomething like that anyway
19:05nicferrierfuture seems fine for what I did?
19:05devnim late to the party: could you use agents + add-watch?
19:06nicferrierpossibly. idk enough about agents.
19:06hiredmanhttps://github.com/clojure/core.async/blob/master/src/main/clojure/clojure/core/async.clj#L392 not the future thread pool
19:06nicferriercentral problem - how to wait on the process.
19:06hiredman(but pretty close)
19:07nicferrieragents sound like actors.
19:07amalloynicferrier: they're not. rich even has a blog post or something, about how the main thing they have in common is names of professions that start with A
19:07nicferrierha.
19:09nicferrieranyway. food for thought. thanks everyone!
19:09nicferrierit's a jolly interesting exercise. I have this already in scala and it's interesting to see what the strengths/weaknesses are.
19:09Morgawris it possible to do nested structural matching with :keys ?
19:09Morgawrlike if I have {:hello {:world 3}}
19:10Morgawrand I want to get the symbol world in a let
19:10sg2002Is there a reason why ob-clojure in the stable org is so obsolete and you have to install dev version of org to use it?
19:10MorgawrI have to do [{:keys [world]} (:hello data)]
19:10Morgawrcan I move the :hello to the other side?
19:11amalloyMorgawr: you don't use :keys for that. are you aware that :keys is shorthand for a more flexible map destructuring?
19:11hiredmanthe people who make tools don't value stability of said tools as much as the people who use them
19:11Morgawramalloy: what do you mean?
19:12amalloyMorgawr: (let [{:keys [x]} m] x) just expands to (let [{x :x} m] x)
19:13Morgawrso I can do (let [{{world :world} :hello} x] ...) ?
19:13Morgawr(where x is the map)
19:15devn,(let [{{world :world} :hello} {:hello {:world 3}}] world)
19:15clojurebot3
19:15devnMorgawr: yes. ;)
19:15Morgawrnice
19:15Morgawris it the best way to do it?
19:15Morgawrif I want to abstract multiple keywords as symbols from maps within maps
19:15Morgawror is there a more idiomatic way?
19:16devn,(get-in {:hello {:world 3}} [:hello :world])
19:16clojurebot3
19:16Morgawryes but that doesn't look elegant in a let binding
19:16devn,(get-in {:hello {:world [1 2 3]}} [:hello :world 1])
19:16clojurebot2
19:16devnyour choice, just sayin...
19:16Morgawrand I might want to get multiple symbols
19:16Morgawrlike normal :keys destructuring but for inner maps :)
19:17Morgawrbut yeah thanks for the examples
19:17MorgawrI love programming in clojure, it's all reasoning about data transformation
19:17MorgawrI've been using it for 2 years and my thought process is so different from most other languages I use every day, I start from two structures, the input and output I want, then I work twards turning the input into the output
19:17MorgawrI've never really done that before, it's cool
19:18devnMorgawr: it's kind of like this: https://www.youtube.com/watch?v=9CS7j5I6aOc
19:18Morgawrahah yes :P
19:58akkadMorgawr: yeah it's a nice group compared to CL :P
20:46hydoIs there any way to change the class loader aside from loading from java or patching the source? I'm sure this hasn't changed, but I thought it was worth asking.
20:46TEttingerhydo, ask rritoch when he gets back, he's been working with classloader related things for OSGi for a while
20:46hydoI'm runing a (one character) change to the 1.7 source and I'm runing into weird issues with (instance?)
20:47hydowhich probably means I should have grabbed the 1.6.x source instead. duh.
20:47TEttingerwhat's the one character change?
20:48hydoFlipping T to F in RT.java line 202 or thereabouts.
20:48TEttingerah. what behavior does it change?
20:48amalloydefaults *use-context-classloader* to false, apparently
20:49amalloythat sounds like a really scary switch to be flipping
20:49hydo*use-context-classloader* to False. Changes the default classloader, to... something. I know far too little about java's guts.
20:49TEttingerah, https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/RT.java#L205
20:50hydoamalloy: I read a few threads and articles about others doing it before I did it. :)
20:50hydoresearch is best search
20:50TEttingerwhy the ops, amalloy?
20:50hydoThe reason for it is that I'm loading clojure in a plugin to another huge java application.
20:51amalloyTEttinger: had someone to kick
20:51amalloythe usual PM spam
20:51hydoTEttinger: Thanks! I'll watch for 'em.
20:53kenrestivoi'm going to create github project called solo hoy. not sure what it'll do, but i got the name picked out
20:54TEttingerhydo: he also forked clojure, you can see some of his code dealing with classloader-like stuff here https://github.com/rritoch/clojure/commit/0f4804bbf584049fd85ffa872f10522cc41eff9a
20:54Morgawris there an equivalent to update-in but for singular key?
20:54Morgawrlike assoc -> assoc-in
20:54Morgawr???? -> update-in
20:54TEttingerMorgawr: update should be in 1.7
20:54amalloykenrestivo: you might want to check whether that's offensive or obscene first
20:54MorgawrTEttinger: awesome!
20:54TEttingeramalloy: only today
20:54TEttingerhoy is now, solo is only
20:54Morgawris there an estimated release date for clojure 1.7?
20:55amalloyTEttinger: i actually hadn't even been certain it was spanish, because it's always "hooy", rather than "hoy"
20:56kenrestivoheah it means "only today". i take it to mean "HURRY ACT NOW!" or some such spammy thing, given the context
20:56kenrestivoor, given the spelling, "hurry act noooooooow!"
20:56amalloyyeah, apparently so
21:03arrdemoh right amalloy has ops now
21:03amalloyarrdem: indeed. tread lightly, lest you feel the back of my hand
21:27andyfMorgawr: No estimated release date for Clojure 1.7 that I have heard. Wouldn't be surprised if it were in the 2-5 months from now range.
21:28andyfYou can use 1.7.0-alpha4 release if you like
21:28hydoanything amazing and awesome coming in 1.7?
21:28arrdemTransducers, feature expressions
21:28hydoI mean aside from *sparkle*a new release*sparkle*
21:28hydooh yea, I need to watch that video.
21:29arrdemthere were noises about lean clojure or profiles, but those noises seem headed in the direction of 1.8
21:29Morgawrandyf: alright, thanks :) I'll give a look at it but not using it yet for "real" work
21:35justin_smithnicferrier: hey! when you use ProcessBuilder, it should be returning a UnixProcess which has nice methods that Process does not
21:35justin_smith$javadoc java.lang.UnixProcess
21:46arrdemjustin_smith: "nice methods" (.nice p)
21:47justin_smithhah
21:56wildnuxhi
21:56wildnux,(map #(repeat 2 %) [1 2])
21:56clojurebot((1 1) (2 2))
21:57wildnux^^ that changed from my [1 2] (vector) to sequence/list
21:57wildnuxhow can i preserve the type of collection when we use functions like this
21:58wildnuxhow can i make it such that it gives me [[1 1] [2 2]]
22:00arrdemwildnux: is there a reason that you care about concrete type?
22:00wildnuxarrdem: i am going though 4clojure
22:00arrdemwildnux: also why would you expect that behavior from those two functions which are documented to return seqs
22:00arrdemwildnux: ah. oh. my b.
22:00wildnuxarrdem: i want to use the same function which can return same type
22:01arrdemwildnux: ##(= [:a :b] (quote (:a :b)))
22:01lazybot⇒ true
22:01arrdem##(= [[1 1] [2 2]] '((1 1) (2 2)))
22:01lazybot⇒ true
22:02amalloywildnux: you mostly should not worry about preserving the types of your collections
22:02wildnux,(flatten (map #(repeat 2 %) '([1 2] [3 4]))
22:02clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
22:02amalloythey will tend to be lazy seqs most of the time, and that will be fine
22:03wildnux,(flatten (map #(repeat 2 %) '([1 2] [3 4])))
22:03clojurebot(1 2 1 2 3 ...)
22:07wildnuxarrdem: found it ;)
22:07wildnux,(mapcat #(repeat 2 % ) [[1 2] [3 4]]
22:07clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
22:07wildnux,(mapcat #(repeat 2 % ) [[1 2] [3 4]])
22:07clojurebot([1 2] [1 2] [3 4] [3 4])
22:07cursivecodeyogothosjaway: ping
22:11arrdemwildnux: sweet!
22:15arrdemalright... core.logic patching time
22:21hydotransducers are interesting.
22:23hydoI'm at 30:45 of the strangeloop video and he hasn't mentioned monads yet, except for the image of a burrito.
22:31sm0kecheshire should have a json to xml converter
22:37arrdemshouldn't be too hard to hack one up...
22:40sm0kehurm jackson seems to have some support builtin
22:41sm0kehttps://github.com/FasterXML/jackson-dataformat-xml
22:45justin_smithsm0ke: and jackson is what cheshire uses iirc
22:45sm0keyes right
22:46sm0kei am thinking of forking cheshire to hack xml support
22:47sm0kei think the support for xml would make sense in cheshire i.e. to from json
23:03seajamesIs there a way to destruct a vector and map? I'm trying this but it isn't working (let [[[foo bar] {:keys [other thing]}] ["Hello" "World"] {:other "Good" :thing "bye"}] (println foo))
23:03crack_userhello guys
23:05justin_smithseajames: ##(let [[foo bar {:keys [other thing]}] ["hello" "world" {:other "good" :thing "bye"}]] foo)
23:05lazybot⇒ "hello"
23:06justin_smithseajames: your nesting was weird (and not even valid for a let block)
23:06crack_usersome one knows a sql lib which a can write queries in more clojure way?
23:06crack_userlike (take 2 users) or (filter #(> :age 21) users)
23:07arrdemso I'm parsing XML by doing what amounts to a recursive reduce over the nodes in the tree carying forwards a state value.
23:07arrdemideas for how to implement progress tracking on the reduction?
23:07seajamesjustin_smith: thanks, first time trying this
23:08arrdemI figure it's probably easty to count leaf nodes and track the number of leaf nodes processed, but I'm not a great fan of doing IO from this otherwise pure parser.
23:08justin_smitharrdem: reductions and carry some updated progress state alongside the accumulator?
23:08sm0kearrdem: isnt counting leaf node as expensive as paring it?
23:10arrdemsm0ke: shouldn't be.. I'm doing some relatively heavy lifting in the "parser". really I'm using data.xml to parse, then walking it with a slow importer that I refer to as a "parser".
23:10arrdemjustin_smith: yeah.. that could work.
23:11sm0kecrack_user: strange idea
23:12sm0kea nice one though
23:12justin_smithsm0ke: crack_user: there's datalog (including datomic), but it doesn't look like normal syntax
23:13crack_userjustin_smith: I see datalog
23:13sm0kecrack_user: justin_smith i'd say korma would be closest to it
23:14crack_userI like the ideia to treat my database as clojure data structure
23:14crack_userin some cases it can be useful
23:15arrdembytemyapp and cbp's revise mongodb wrapper has an interesting query structure
23:15arrdemit gets close to "normal" clojure code
23:15arrdems/mongodb/rethinkdb/
23:16sm0kecrack_user: what you want can be done simply via java.jdbc over the query-seq
23:16sm0kebut what one would ideally want is to to push the filters etc to db
23:17sm0kee.g. (take 2 user) should translate to select * from user limit 2
23:18crack_usersm0ke: something like it
23:18sm0kei am not sure how that can be implemented
23:18warzmaybe something line LINQ-to-SQL can be an inspiration?
23:19sm0keobviosly not everything will work, eg. (filter my-fancy-func user)
23:19justin_smithwell, clojure.java.jdbc returns a lazy query seq over the transaction, so if you take 2 from the seq it gives you, only that much is grabbed from the db.
23:19sm0keso i would say it would be very very hard to implement
23:19sm0kejustin_smith: what about filters?
23:19justin_smithsm0ke: that would have to happen on the clojure side unless you are willing to translate
23:20sm0kei was just giving a small example
23:20justin_smithsure
23:20justin_smithjust saying, lazy results and take N is doable now
23:20sm0kejustin_smith: alway finding holes in my comments :D
23:21crack_userjustin_smith: yes, lazy query resolve the take example
23:23hydoIs there a known thing with (instance? thing Class) saying thing can't be cast to a java.lang.Class? I traced my code back just to make sure, but I don't see what I'm doing wrong. I got to where I opted for (= (class thing) (resolve (symbol "class.path"))) but that's just silly.
23:24hydoThough, while silly, it does work correctly... so it has that going for it.
23:24justin_smithhydo: you have the args in the wrong order I think
23:25justin_smith&(instance java.lang.String "hello")
23:25lazybotjava.lang.RuntimeException: Unable to resolve symbol: instance in this context
23:25sm0ke,(doc instance?)
23:25clojurebot"([c x]); Evaluates x and tests if it is an instance of the class c. Returns true or false"
23:25hydo! no way. looking..
23:25sm0keyep
23:25justin_smith&(instance? java.lang.String "hello")
23:25lazybot⇒ true
23:25hydooh my god.
23:25hydoI'm sorry :( I really try to ask intelligent questions. I'm just dumb.
23:25hydoheh
23:25justin_smith(instance? Newb hydo) => true but that's OK
23:26hydototally
23:26justin_smithI make dumb mistakes all the time, and I don't even have an excuse
23:26hydoI make dumb mistakes and then tell everyone on the internet about them. hehe. but I do eventually learn, so I guess that's good.
23:27hydolike "Double check your assumptions before asking irc." Just learned that one today!
23:32arrdem$grim clojure.core/instance?
23:32lazybothttp://grimoire.arrdem.com/1.6.0/clojure.core/instance_QMARK
23:32munderwoHey all. I’ve got some interop code in clojurescript that has three levels of callbacks. I wrote some horrible core.async code to get it kinda working, but Im sure there is a better way to do it. this is what I have so far
23:32munderwohttps://www.refheap.com/94712
23:32arrdemjustin_smith: I owe you a patch to make that conj.io...
23:33munderwodoes anybody have any suggestions on how to make it better?
23:34rritochIn refrence to hydo's issue, I really need to get in the habbit of using the doc function instead of constantly googling to double-check argument order. clojure.string/split is usually the one I use backwards so I always need to double-check it. Some habbits are hard to break.
23:34sm0kemumrah: get-commit makes no sense, as `c` is local
23:35sm0keopps sorry ^ munderwo
23:35sm0keunles (go..) returns a channel?
23:36munderwosm0ke: yeah, when I said this was horrible it really is.. What the code is doing is passing a chan (is his case c) through the callbacks and then blocking until the last callback puts something on that chan. and then returns the output of that into blob.
23:37munderwoim wondering if I can put this all in a go block with a let in it for each step?
23:40sm0kemunderwo: i would say its too much overhead to use a go block for every meta you are trying to fetch
23:41sm0keit does not look very cpu intensive anyways
23:41munderwoahh because I would need a seperate one for each?
23:42munderwoIts not cpu intensive. Its just node.js so everything is async.
23:42sm0keyea well there is a (go..) in every method
23:42munderwohave you dealt with callbacks by using core.async before?
23:43sm0kewell if its already asynchronus you done need to put another layer of asynchrony over it?
23:44sm0kemunderwo: core.async is not really about callbacks
23:44sm0keits more like queues consumers and producers id say
23:45munderworight, but I’ve seen that you can sometimes convert very call back intensive code into core.async and make it more readable.
23:45munderwonot that im having much luck with the last part
23:45munderwo:)
23:46crack_userI think I build a very limited scoped lib of this ideia
23:46crack_userin the worst case it will be a complete waste of time
23:58kenrestivois it weird that i have a preference for using futures for core.async loops instead of async/thread or async/go , and using future-cancel to stop them instead of using a kill channel?
23:58kenrestivoi mean, is that bad?