#clojure logs

2012-01-23

00:06ibdknoxAlright folks, I'm outta here
00:08johnmn3peace
00:28johnmn3randomly thought the /join #sopa. 358 people in there!
00:29zellioo.O
02:28cemerickI can't believe I hadn't noticed before now that special forms aren't hintable. :-|
02:31muhoohmm that seesaw is interesting. would be cool to have a hiccup/enlive style clojure native syntax for java gui stuff
02:58LauJensenif I have an fn like (defn x [] (if (= "x" (System/getProperty "user.name")) x y) will the compiler optimize that so that the if is not re-run unless the environment changes or is the user.name var polled on every call?
02:59johnmn3I'd guess it stays as the user that started the java process
03:04jowagI think it won't optimize your fn.
03:28amalloyLauJensen: i would be quite surprised if the compiler optimized that, but you can trivially do it yourself: (let [result (if (= "x" (System/getProperty "user.name")) x y)] (def foo (constantly result)))
03:29Blktgood morning everyone
03:42AWizzArdamalloy: though I think that Lau wants it to get evaled if the Properties change.
03:43AWizzArdBasically (if (and (System/propertiesUpdated) (= "x" (System/getProperty "user.name"))) …), but such a static method doesn't exist.
03:57LauJensenamalloy: Right - I was just curious if the compiler would work it out on its own - Would have been sweet
04:22clj_newbI can't find anything interesting on google for "clojure real time audio." Does Java's GC basically make this mpossible?
04:23AWizzArdclj_newb: did you see http://mad.emotionull.com/ or https://github.com/overtone/overtone ? They might deliver what you are looking for.
04:24clj_newbthis is awesome
04:32Kototamahi, is it possible to use compojure with clojure 1.3?
04:33Vinzentyes
04:34augustlcouchdb-lucene seems to include lucene itself, is that correct?
04:34augustlerr, wrong channel
04:39Kototamahow can I use clojure 1.3 with compojure then?
04:39Kototamai'm already using it but the default dependency is clojure 1.2
04:42AWizzArdKototama: you could import the Compojure dependency with an exclusion on Clojure, and manually add Clojure 1.3 as a dependency.
04:43Vinzentit works without excluding too
04:43AWizzArdKototama: For example, in one project I include the Apache XML-RPC Client as a dependency. Unfortunately it comes with JUnit, which I don't want, so I did: [org.apache.xmlrpc/xmlrpc-client "3.1.3" :exclusions [junit]]
04:49Kototamaok thx i'll try that
05:04Kototamawhen alternatives are written as [org.clojure/clojure "[1.2.1],[1.3.0]"], how can I specify which version from Clojure I want?
06:20tsdhWhy is there no documentation for definterface in the Clojure API docs?
06:54jaleydoes anyone know where clojure.contrib.mock was moved to in 1.3? Can't find the info on the wiki...
07:11AWizzArdjaley: sorry, I don’t know that. But one association I have with “mock” is that Midje works in that style very well: https://github.com/marick/Midje
07:12jaleyAWizzArd: ok cool. I was starting to look at Midje actually, I guess I'll carry on down that path
08:34mr_rmis nrepl considered to be the best way to have a remote repl connection in clojure 1.2 and 1.3?
08:35mr_rmthat is: https://github.com/clojure/tools.nrepl
08:36krunaldomr_rm: uh, normal nailgun repl or slime repl should be enough
08:36krunaldomr_rm: also protecting it with a ssh/ssl/vpn/whatever tunnel is recommended
08:37mr_rmsorry, i should have said this is not from emacs. my IDE is eclipse ccw and i'd also like to connect from command line
08:37mr_rmkrunaldo: but good point about the ssl tunnel - understood on that point
08:38krunaldounsure how to proceed actually.
08:39krunaldomr_rm: Do you need to have the repl running inside eclipse?
08:39mr_rmkrunaldo: that is not a requirement.
08:40mr_rmkrunaldo: basically i just want the running clojure program to listen on a port that i can connect to for a repl
08:40krunaldohmm, nrepl seems to be the best one for that
08:48kralhi pals
08:59compjhi, does someone know why a aliased macro with (def ^#{:macro true) name #'other.ns/mac) produces a warning when called after it were aot compiled?
09:00AWizzArdcompj: what is the warning?
09:00compjwarning is: ArityException Wrong number of args (X) passed to <other.ns/mac>
09:01compjcan be tested with the seesaw project https://github.com/daveray/seesaw/issues/73
09:04AWizzArdcompj: they suggest to delete the compiled class files. Can you try a “lein clean” first and then retry your example?
09:05compjyes that is working but I'm wondering, why can't you aot compile such a (def...)?
09:05compjisn't the ^#{:macro true} meta data not intended for this, or is it a bug?
09:09pandeiroanyone use domina (clojurescript dom lib used by cljs one)? is there an easy way to iterate over a collection and output list items that I am missing?
09:16compjhere, mnimal example of the bug (?) http://pastebin.com/n83uWJgu
09:18AWizzArdcompj: can you try to clean and then aot the code and then try your test?
09:19compjthe example I posted works outside a project, just put it in a empty dir, compile it and you can see the warning
09:27kijHey, whats the state of the videos from Clojure/Conj11 ?
09:28bhenrykij: i saw them listed on confreaks.com but they are not available yet.
09:35phil_why doesnt this work?
09:35phil_(deftype Bar [a b c d e])
09:35phil_(def b (Bar 1 2 3 4 5))
09:35phil_#<CompilerException java.lang.RuntimeException: Expecting var, but Bar is mapped to class hs.base.view.Bar, compiling:(REPL:4)>
09:35raekphil_: you are missing a dot: (def b (Bar. 1 2 3 4 5))
09:36phil_raek: ah, did the syntax change?
09:37raekphil_: not since the release of 1.2, at least
09:37kijbhenry, Thanks.
09:37phil_raek: i see, then im looking at outdated examples :) thx!
09:37raekBar is a jvm class, so you use the constructor interop syntax
09:51luciani have a seq of maps, i'd like to split it into several seq based on one value in the map. is there hof i could use?
09:52joegallogroup-by, probably
09:52lucianjoegallo: that's it, thanks
09:52joegalloit's not lazy, though (i mean, how could it be?)
09:53lucianyeah
09:54TimMcjoegallo: It could be partially lazy.
09:54lucianwell, i guess it could be
09:54TimMcThe first time you iterated all the way through an inner seq, the entire source seq would be realized.
09:55joegalloyes
09:55joegalloyou could do that
09:55joegalloquite right
09:55TimMcWait, the result is a map of seqs... no,
09:55TimMcbut if it is a seq of seqs, yes.
09:55lucianit'd work in something like haskell for sure, i think
09:56luciansemantically it's not necessarily fully eager
09:59TimMcYou could write a lazy associative data structure in Clojure. But the first 'get on it for a key that wasn't already known would also cause a full realization.
10:00phil_is it possible to pr-str deftypes?
10:00phil_in the same way that i can pr-str maps for example?
10:01phil_pr-str only returns the java reference, but not the contents
10:03raekphil_: not yet, I think
10:04raeksomething like that is in the works (at least for records)
10:04phil_ok, do deftypes then offer any advantages to self-made polymorphism?
10:05phil_i guess that returning closures for every newly created type may be inefficient :/
10:14stuartsierrapr-str works on defrecords in 1.3
10:15stuartsierraBut not deftype.
10:17phil_there are no defrecords in cjs though, correct?
10:29wiseenHow do I call Java method overload that takes a vararg of byte[] ?
10:29wiseenusually to call overload that takes vararg it's (Foo/bar (into-array type [...])
10:30wiseenbut how do I get byte[] as type ?
10:32AWizzArdwiseen: the Class of it is "[B"
10:32AWizzArdYou can type-hint such objects too: (SomeClass/method ^"[B" my-byte-array)
10:32AWizzArdwiseen: (class (byte-array 0))
10:33wiseenAWizzArd, so (into-array [B [(byte-array ...) ..])
10:33wiseenAWizzArd, so (into-array ^"[B" [(byte-array ...) ..])
10:33wiseen?
10:34AWizzArdbyte-array takes a value-sequence.
10:34wiseenit takes varargs of byte-arrays not a byte-array
10:34AWizzArd,(doc byte-array)
10:34clojurebot"([size-or-seq] [size init-val-or-seq]); Creates an array of bytes"
10:34AWizzArd,(long-array [10 20 30])
10:34clojurebot#<long[] [J@134afa4>
10:34wiseenAWizzArd, yeah I know, but I need an array of byte-arrays
10:34wiseenJava function has : wrappedBuffer(byte[]... arrays)
10:35wiseenthat's one overload
10:35AWizzArdAh okay, then make-array
10:35AWizzArd,(make-array Byte/TYPE 10 20) ; a 10x20 array
10:35clojurebot#<byte[][] [[B@f6f949>
10:35AWizzArd,(class (make-array Byte/TYPE 10 20) ; a 10x20 array)
10:36clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>
10:36AWizzArd,(class (make-array Byte/TYPE 10 20) ; a 10x20 array))
10:36clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>
10:36AWizzArd,(class (make-array Byte/TYPE 10 20)) ; a 10x20 array
10:36clojurebot[[B
10:36Kototamaisn't it more clear that a *variable-like-this* is global? Why did that get deprecated? It's harder to see the difference between local and global variables now
10:37AWizzArdwiseen: note that (make-array Byte 10 20) is the wrapper Byte[][], while (make-array Byte/TYPE 10 20) returns you a native byte[][]
10:37AWizzArdKototama: I would also prefer if one could say: (def ^{:dynamic false} *my-var* 10)
10:37wiseenAWizzArd, so Byte/TYPE is a way to access value type byte
10:37wiseenpacked
10:38AWizzArdKototama: But this way it is very easy to see which are bindable (and thus “slow”) vars.
10:38wiseen*unpacked type
10:38AWizzArdwiseen: yes
10:39TimMcphil_: There's a multimethod you can overload for printing your type, I forget what it is.
10:40phil_TimMc: but no multimethods in cljsc right?
10:40phil_but defrecords work, just tested
10:42pandeirophil_: there weren't but the branch of cljs used by clojurescript one has them
10:42phil_pandeiro: multimethods or defrecords?
10:42pandeiromultimethods
10:43phil_and defrecords?
10:43pandeironot sure about that
10:43phil_they work, but the docs say they shouldnt
10:44phil_is the branch used in cljs one gonna be merged back into the main repo btw?
10:44pandeirophil_: not sure, probably have to ask the crew
10:44phil_pandeiro: allright, thx!
10:57bhenrycan someone point me to a good futures resource? or tell me how to check the status of a future without blocking by deref?
11:01TimMcbhenry: realized? I think
11:02TimMc,(realized? (future 5))
11:02clojurebotfalse
11:03jkkramer,(apropos "future-")
11:03clojurebot(future-done? future-call future-cancel future-cancelled?)
11:04bhenryfuture-done? thanks!
11:05AWizzArdHmm, is the difference between realized? and future-done? more of a subtle nature?
11:05AWizzArdIt seems realized? works for more than just futures.
11:05jkkrameryes, it's more general. also, it's 1.3+ only
11:06LauJensenAWizzArd: Hi buddy, its been a while, is your DB out yet?
11:09stuartsierraThere's also a non-blocking version of `deref` now that takes a timeout argument.
11:10exupero@joe http://en.wikipedia.org/wiki/1967_NFL_Championship_Game
11:10AWizzArdLauJensen: in use, but getting more stable.
11:10exuperosorry, wrong irc
11:10LauJensenAnything on Github or something I can try out?
11:10AWizzArdLauJensen: on BitBucket, but in a private repo :)
11:11LauJensenOh okay - You're really drawing out the suspense on this one :)
11:11LauJensenIn other News, ClojureQL is 1.0.3 and nearly bug free :)
11:12AWizzArdLauJensen: you are right, I am very slow on this. And Grats to the new version of CQL.
11:12LauJensenThanks :)
11:12AWizzArdgtg, l8rs
11:18langmartinI have a namespace in program called platform.util, if I load a file that depends on it (slime + lein), I get the error that the namespace isn't found in the file.
11:19langmartinIf I open the file and load it, the namespace can be found
11:19langmartinif I change the namespace to platform.toolbox, the load works as expected
11:19langmartinus there an issue with a namespace called "util"?
11:20Vinzentare you sure the file is called "platform/util.clj"? if yes, I don't know
11:20langmartinyes, I am sure.
11:21sritchietechnomancy: is there a way to exclude a file from a jar, but keep it around in the uberjar?
11:35Dotan_hi, is there an ubuntu package for clojure for a quick start?
11:37pjstadigDotan_: I think there is, but i'm not sure how recent it is
11:37pjstadigmay be 1.2.1
11:37Dotan_i see, ok, i'll build locally.
11:37VinzentDotan_, anyway install leiningen first
11:38jsabeaudryDotan_, Closest thing to q quickstart that I know of is certainly leiningen: https://github.com/technomancy/leiningen
11:38Dotan_oh. i suspected installing lein first might be better but dismissed that thought
11:39jsabeaudryDotan_, depending on what you intend to do, tryclj.com might be even faster
11:39Dotan_yep thanks, i always like to fiddle locally despite of try* sites :)
11:48Kototamais there a release for math.combinatorics (formerly clojure.contrib.combinatorics) ?
11:51babilenKototama: http://search.maven.org/#artifactdetails%7Corg.clojure%7Cmath.combinatorics%7C0.0.2%7Cjar comes up
11:56Kototamahum okay
11:56TimMcDotan_: In general, Clojure is not reliably available through package managers.
11:56Kototamai looked on clojars
11:56Kototamathanks
11:57Dotan_TimMc, thanks. i went the lein way, very cool.
11:58benares_98:TimMc why isn't clojure reliably available through package managers?
12:00TimMcbenares_98: Lack of maintainers, first of all -- but I think there are deeper problems with that distribution model vis-à-vis Clojure.
12:00TimMc(and that was supposed to be an a-with-grave-accent, but my terminal is fucked)
12:01benares_98lol thanks for the insight
12:01benares_98I was just curious, someone else said not to get clojure through package managers but I didn't ask why at the time.
12:02TimMcThe reason is the unreliability. :-)
12:03stuartsierraThere's a mismatch between the Java distribution model (every app has its own classpath of JARs) and most OS package managers.
12:04babilenWhat would need to be done to change that? What is wrong with clojure as currently packaged? Which libraries/applications need to be packaged most urgently?
12:07dnolenbabilen: communicate to users that they should install lein via their package manager not clojure
12:09babilentechnomancy: ^^^ Could you push a change to leiningen's README to mention Debian/Ubuntu packages? (Arch has packages as well, but I had the impression that they mostly just rely on lein's autoinstall)
12:09wjlroeI seem to have a value of byte[] coming from a sql query - how can I test for that - there's not bytes? method...
12:10babilendnolen: But I am serious -- I am currently working on packaging most of https://github.com/clojure/ + other highly ranked libraries (compojure, ...) and am always open for suggestions.
12:11babilendnolen: My long-term plan is to have everything managed by clojure/core in Debian in the newest version + backports to stable, but this is some work and any comments from the clojure community are welcomed.
12:11algernonbabilen: midje & marginalia would be lovely to have, too.
12:12babilenalgernon: Yeah, those are highly ranked on whatever website was mentioned on clj-user recently that provided a ranking based on dependencies.
12:13stuartsierrababilen: I don't want to denigrate your efforts, but I would not expect OS packages for Clojure libraries to get much use.
12:13babilenalgernon: It's a bit hard to choose and I guess that a lot of developers will just rely on installing libraries via leiningen anyway. My dream would be that most of what is now on "Getting Started with ..." has a corresponding package in Debian/Ubuntu.
12:14stuartsierraSince the "packages" are just source code, there's little benefit to having them managed by an OS-level tool.
12:14stuartsierraAlso, Clojure is a young language and the landscape of libraries and tools is likely to change rapidly for the foreseeable futuer.
12:15babilenstuartsierra: Which is why for now only leiningen and clojure is packaged and I am debating with myself how to proceed. I guess that the real need for packages arise as soon as users really want to install applications written in Clojure.
12:16algernonbabilen: *nod*
12:16stuartsierraIn the unlikely event that desktop applications are written in Clojure, they would probably be distributed as monolithic JARs containing all their dependencies, as many Java applications are toay.
12:16stuartsierra*today
12:17hiredmanstuartsierra: but debian's policy is to take those monolithic jars and break them up again
12:17stuartsierraeh, whatever
12:17hiredmanmuch like I think the debian package of clojure has(or had) asm stripped out
12:18stuartsierranice trick since it was namespaced under the "clojure." package
12:18babilenyeah, but those monolithic JARs can and shouldn't be distributed by distributions -- I am currently trying to get most of clojure/core and other things into Debian and will merely package dependencies thereafter. I think, for example, that being able to "apt-get install clooj" and similar things would ease the life for people.
12:18stuartsierrago for it
12:18babilenhiredman: It is stripped out
12:19hiredman*eyeroll*
12:19babilenstuartsierra: Oh, I will. I just fear that this might end up in a similar situation as the Debian/Ruby disaster (developers being discouraged to use distribution packages) and would like to avoid that.
12:19stuartsierratoo late
12:20babilenstuartsierra: Why?
12:20stuartsierraWe already tell developers to use Lein.
12:20babilenhiredman: Huh? asm *is* packaged in Debian and used by clojure -- It is just not part of the Clojure package.
12:22hiredmanbabilen: sure, but why?
12:22babilenhiredman: Because there is no need to have the same library 10 times on a system.
12:23babilenstuartsierra: Which really makes sense right now. Just like it makes sense to target quite new and unstable libraries at this point. But clojure will (hopefully) settle down a bit eventually. As I said earlier: This will really become important once users want to use user-level applications in clojure.
12:23hiredmanbabilen: sure there is, clojure uses a specific version of asm, other tools may use other versions
12:23stuartsierraOne dream at a time. 'Later dudes.
12:24TimMcIt hink the question at the moment is: Does distribution via uberjars lock us in later?
12:25TimMcAnd I'm not sure what the answer is.
12:25babilenhiredman: Those versions will have to be packaged independently in versioned packages if they are not compatible.
12:25TimMcbabilen: Like Java?
12:25babilenTimMc: For example
12:26hiredmanbabilen: for what gain?
12:26TimMcI could see that.
12:26hiredman(over just taking the existing clojure jar with asm included)
12:27TimMcbabilen: WOuld you have clojure-1.2 or clojure-1.2.1?
12:27TimMcNever mind, that's irrelevant.
12:27TimMcClojure 1.2 breaks API, so it is clojure-1.2 v1.2 and v1.2.1
12:28babilenhiredman: There are a couple of reasons why it is undesirable. I guess the most important one is that it eases security support as you only need to update a single library and all applications that use that library are "patched" as well. If we would ship the same library in multiple packages all these packages would need to be updated.
12:28TimMcoutside of that, you can handle it with OR statements.
12:29babilenTimMc: Right now we have clojure1.2 and clojure1.3 -- I expect a clojure1.4 to emerge after the release.
12:29babilens/the/its
12:30hiredmanbabilen: but any security update is a new a version which may or may not work ith clojure, while the asm distributed with it is always going to work
12:30babilenIf there would be a set of stable libraries for 1.3 and 1.4 that are individually maintained you could expect those to be packaged as something like libclojure1.2-foo -- But those are not versioned right now.
12:32babilenhiredman: In that case the dependencies have not been declared correctly -- software should clearly state that it works with specific versions. (say 1.5 - 1.6 or so) and security updates to a library shouldn't break backwards compatibility. (e.g. 1.6.1 shouldn't break applications written against 1.6)
12:33hiredmanbabilen: "shouldn't"
12:33babilenindeed
12:33hiredmanbabilen: they do all the time
12:34hiredmanbabilen: clojure has no "dependency" on an external package, because the "external" package is not external anymore
12:34TimMchiredman: That takes away the entire point of a security update.
12:34babilenhiredman: Sure there are dependencies (you write those down in your project.clj (for example) all the time)
12:34TimMcNot that you can read this.
12:35hiredmanbabilen: the whole thing is such a knee-jerk stiff-necked forcing of an antiquated C view of the world
12:35hiredmanbabilen: clojure doesn't have any
12:36hiredman(actually clojure doesn't build with lein so there is no project.clj, and even if you have a fork that does build with lein, which I happen to have, it doesn't have any dependencies)
12:36babilenhiredman: I am referring to Clojure-the-ecosystem rather than specifically clojure itself.
12:37hiredmanbabilen: if you want apt to work with the ecosystem the best thing to do would just by to make apt front maven
12:38hiredmanbut that will not work well because apt with apt the default is an assumed single version of a package installed at one time, where as maven/the jvm just don't care
12:39babilenhiredman: We have things like that to ease packaging maven projects -- Please don't get me wrong here as my sole intent is to make it easier for Debian(-based) users/developers to use and enjoy Clojure. I do, however, strongly believe that a more stable development cycle + support for "old" versions will be a good thing in the long run.
12:40hiredmanbabilen: it is already very easy, you bootstrap yourself out of the apt nonsense and just use maven repos
12:42hiredmanbabilen: the ruby community is seeing issues with the apt/C style global global namespace of libraries and has started using tools which avoid that (rvm, bundler, recommending local installs instead of global, etc)
12:45babilenhiredman: Indeed, whereas it works pretty well for Python even though *developers* still use tools such as pip/virtualenv/... during their development.
13:10phil_what is the function to generate an object from a string? im trying (read-string (pr-str object)) but i get an "unreadable form" error message
13:11joegalloyou might need to play some of the ear-muffed variables that affect printing of objects
13:12phil_like atoms?
13:13joegalloi'm thinking like http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/*print-level*
13:13joegallofor instance
13:13joegallodepending on what you're printing
13:13phil_yep (read-str (pr-str (atom 6))) bombs out :/
13:13joegalloi don't think you want to print and read atoms
13:13joegallojust my opinion
13:13joegalloyou might want to print and read the value in the atom
13:14joegallobut not the atom itself
13:14phil_well i was hoping that by reading the atom a new atom will be generated with the same value
13:15joegalloi don't think that atoms are designed to have a readabl toString, so that doesn't work
13:15joegalloyou could probably sneak around it if you really really want to do it that way
13:16phil_yea i guess, but it gets complicated... is there a reason why atoms are deemed unfit for "serialization"?
13:17joegalloours not to reason why, ours not to make reply
13:18Vinzentphil_, there was discussion about that on the group somewhere... Why don't you save the value of your atom?
13:27TimMcI'm not sure what the point is of cloning transactional objects.
13:46technomancyhas anyone had issues generating incanter charts from jdk7?
13:57the-kenny+1
14:12dnolenjkkramer: compj: the-kenny: i see no patch in jira ;)
14:13the-kennyhmm shouldn't be that hard. Do I still need a contributor agreement?
14:15technomancyamalloy_: what's the latest on the data.xml release? still blocked on maven?
14:16dnolenthe-kenny: yep
14:16the-kennydnolen: Gnah. I should finally bring myself to do that :)
14:22compjcan someone tell whether this is a bug? see comment: http://pastebin.com/raw.php?i=2GFGY2NW
14:23TimMccompj: I believe macro fns take some extra args, maybe &env and &form
14:23Bronsacompj: defmacro puts &env and &form as first args
14:23hiredmancompj: it is not
14:24BronsaTimMc: you were faster :)
14:24TimMcI'm on my work computer, which has less lag.
14:24compjbut it works as exspected when I dont compile
14:24jkkramerdnolen: i'll write a patch. think i should bring it up on clojure-dev or just create a jira case?
14:24compjbut if the module is aot compiled this warning is produced
14:25dnolenjkkramer: mention it in on clojure-dev just for record keeping
14:25jkkramerk, will do
14:25dnolenjkkramer: it always hard to tell how quickly people will move on such tickets since it's minor enhancement - so don't hold your breath
14:25dnolenjkkramer: Clojure/core only really works on CLJ on Fridays
14:26hiredmandnolen: really, because I am pretty sure relevence is the one with an open source friday policy, and clojure/core claims not to be relevence
14:27dnolenhiredman: seeing as Clojure/core is mostly relevance + rhickey, the distinction is a minor one
14:27hiredmanwell, I guess that is not true, the website says "Clojure/core is a specialized technical practice brought to you by Relevance, Inc."
14:28hiredmandnolen: right, I just know if you suggest they are the same on the ml you get immediately "corrected"
14:30compjit seems the compiler does not set the macro flag for vars defined using (def #^{:macro true})
14:31hiredmancompj: what version of clojure are you using? #^ has been deprecated for two releases now
14:32nrichardsDoes anyone maintain a list of clojure users groups / meetups? I can't seem to find one
14:32technomancynrichards: there's one on jira
14:32compjI just started using clojure, I''m on version 1.3.0 but learned from older tutorials
14:32jkkramerdnolen: yeah, i know. i figure i shouldn't complain unless i'm willing to actually write a patch, though :)
14:32technomancywhich is not renowned for making things easy to find
14:32nrichardsThe Austin Clojure meetup is starting up, and I was hoping to get some inspiration from what other groups are doing
14:33nrichardsjira? OK. I'll check. thanks
14:33di-csuehsAustin Clojure?
14:33nrichardsyes
14:33dnolennrichards: sweet! I used to live in ATX
14:33technomancynrichards: sorry, confluence
14:34nrichardshttp://www.meetup.com/Austin-Clojure-Meetup/
14:34hiredmancompj: metadata on the var is the only "macro flag" there is
14:34hiredmanbut you also need to stop using single segment namespaces
14:34hiredman~namespace
14:34clojurebotIt's greek to me.
14:34hiredmanclojurebot: jerk
14:34clojurebotyou cut me deep, man.
14:35compjthe single namespace was just for the demo
14:35hiredman~namespaces
14:35clojurebotnamespaces are (more or less, Chouser) java packages. they look like foo.bar; and corresponde to a directory foo/ containg a file bar.clj in your classpath. the namespace declaration in bar.clj would like like (ns foo.bar). Do not try to use single segment namespaces. a single segment namespace is a namespace without a period in it
14:35compjso how do I add the :macro true to a var in 1.3.0?
14:36hiredmancompj: so what makes you think the compiler is not
14:36hiredmancompj: so what makes you think the compiler is not seeing it as a macro?
14:36compjsee the example http://pastebin.com/raw.php?i=2GFGY2NW
14:36hiredmanI see the example, and I don't see anything there that would lead to that conclusion
14:37compji expect no warning when using (mac-alias) since it is marked to be a macro
14:37compjand if i do (.setMacro #'var) it works
14:37compjso my assumptions was the compiler does somehow drop this information
14:37compjwhile it works when you don't aot compile it
14:37Raynescompj: Not that it matters, but refheap.com and gist.github.com (and a couple of other ones) are pastebins that have Clojure-specific highlighting. The first one is even written in Clojure by a couple of really awesome dudes. One whose name starts with an R.
14:38Bronsaoh, i recall there was a problem like this for ^:dynamic
14:38compjraynes: tanks :) I was looking for a clojure paste service but did not find one
14:38hiredmancompj: have you looked at what setMacro does?
14:38TimMcRaynes: Get on that SEO!
14:39RaynesTimMc: Indeed.
14:41compjno, I did not look what setMacro does but I think it sets a var so that the 2 args passed to macro funs are handled in a way the user expects it
14:41hiredmancompj: nope
14:41RaynesTimMc: Looks like "clojure pastebin" is covered in pastebin.com. and thus destroys us.
14:41djh_Can anyone tell me what the significance is of surrounding var declarations wtih *s, e.g. *database-connection*?
14:42di-csuehsugh...why does it require a photo
14:42RaynesThose usually indicate dynamic vars that will be rebound at some point with ##(doc binding)
14:42lazybot⇒ "Macro ([bindings & body]); binding => var-symbol init-expr Creates new bindings for the (already-existing) vars, with the supplied initial values, executes the exprs in an implicit do, then re-establishes the bindings that existed before. The new bindings are made i... https://refheap.com/paste/386
14:42pjstadigdjh_: it generally conveys the fact that your var is meant to be bound dynamically
14:42pjstadigthough in 1.3 you have to specifically add the dynamic metadata
14:43Raynesdi-csuehs: Why does what require a photo? :o
14:43compjhiredman: but you agree the behaviour is not as expected?
14:43djh_pjstadig: thanks, that's all I needed to know :)
14:43compjsince the compiled and non-compiled version differ?
14:43hiredmancompj: I dunno, I haven't checked, and since you are new to clojure I think it is more likely you are making a mistake somewhere
14:44di-csuehsnrichards Austin Clojure meetup
14:44nrichardsdi-csuehs: the group? I think that's a meetup.com thing.
14:44nrichardsI didn't setup the group - but I can ask Sam to look at the configuration. I know he wrote the signup questions
14:45di-csuehsI found one...glad I had my laptop handy. See you there!
14:46compjyes, of course I thought of this option. but I could not find any documentation for this so I think it's possible that this might be a bug
14:46compjthe call to setMacro was just a workaround I picked from the defmacro code
14:47nrichardsdi-csuehs: awesome!
14:47di-csuehsassuming the kids have been good ;)
14:57Bronsachops: fwiw with this patch http://sprunge.us/KZbH it works
14:58chopsBronsa: I think you might be confusing me with someone else
14:58Bronsayeah
14:58Bronsatabfail
14:58chopslol :)
14:58Bronsa*compj
15:00compjBronsa: so it's a bug?
15:00Bronsait's a missing feature i guess
15:00compj:)
15:01Bronsaif somebody with a CA can submit it, it'd be great
15:01compj+1
15:05TimMcBronsa: You'd want to reformat with tabs. (yuck)
15:05Bronsaoh :(
15:16TimMcBronsa: The clojure.core formatting guide is pretty heinous.
15:16Bronsathen i guess http://sprunge.us/bWcc this should be good
15:17RaynesTimMc: Have you actually looked at clojure.core's formatting?
15:17RaynesTimMc: It looks like it was edited by 20 different editors.
15:18llasramRaynes: How so?
15:19TimMclike someone unleashed a whitespace-randomizer on it, I know
15:20Raynesllasram: Well, Emacs indents non-defun-style things with one space if you put a newline before the first argument. `cond` is an example. Vim doesn't bother and puts two spaces. This sort of inconsistency is all over clojure.core.
15:20RaynesI don't actually care about 1 vs 2 spaces. It's just worth noting.
15:21llasramRaynes: Ah, I see. Interesting. I had not noticed that. And also thought you were talking about the clojure.lang Java code for some reason
15:21RaynesI wouldn't dare look at that.
15:22llasramI was put off by it at first, but after poking around, it's not bad. The formatting is unconventional, but largely consistent. There aren't many comments, but most of the code (other than the reader) is pretty clear
15:27TimMcRaynes: Ah, I was talking about the Java stuff.
15:31dnolenTimMc: blame it on IntelliJ
15:35TimMcdnolen: Why? Isn't it configurable?
15:38RaynesTimMc: Yes. It has settings "Ugly, Hideous, and Unreadable."
15:38dnolenPersonally I have few problems with the Java source, weirdly formatted - yes. Unreadable hardly.
15:41llasramI wonder where rhickey (I assume?) got that formatting style from. It's very much like the formatting style McConnell recommends for C-ish code in /Code Complete/ (for pretty concrete reasons, although I still don't see it very often or use it myself)
15:43jkkramerhttp://en.wikipedia.org/wiki/Indent_style#Whitesmiths_style
15:44llasramInteresting.
15:44hiredmanI like to imagine it was just an easy style to generate from a set of cl macros
15:45llasramheh
15:45hiredmanthe only joking part of that sentence is "cl macros" it would of course be generated by cl functions
16:12grim_radicalis there a way to add a docstring via "defmethod"?
16:13grim_radicali see how to do it for defmulti, but i'd like to add some method-specific docs
16:13phil_is there a way in paredit.vim to swap to expressions (or just move an expression to the right / left)?
16:13phil_two*
16:13Vinzentgrim_radical, I don't think it's possible
16:14grim_radicalVinzent: bummer. :(
16:16raekgrim_radical: in defmulti/defmethod there is only one var involved (and therefore only one place for the metadata to go), namely the one that is defined by defmulti
16:16grim_radicalraek: ah, ok
16:17TimMcraek: Is there a way to ask a multimethod for the implementation it would use given an argument list?
16:17brehautgrim_radical: if you used https://gist.github.com/432752 to install the methods so you could define the functions independently so that they each have a var to hang a doc on
16:17grim_radicalbrehaut: neat! i'll definitely take a look at that
16:17raekTimMc: I'm not aware of any public interface for that
16:18brehautgrim_radical: you wont get much advantage over just using a ;; comment
16:18grim_radicalbrehaut: yeah, that's my current fallback
16:20raekthe defmulti docs or the ns docs where the defmethod resides are alternative locations
16:21jsabeaudryIs there a way to comment out "the next s-exp" ?
16:21brehaut,#_ (prn "a") :foo
16:21clojurebot:foo
16:21brehautjsabeaudry: ^
16:22jsabeaudrybrehaut, Excellent! Thanks!
16:22brehautjsabeaudry: use it carefully. its a great way to cause you pain ;)
16:23brehautjsabeaudry: not all syntax highlighters highlight it and the form thats removed as a comment
16:23jsabeaudrybrehaut, Oh ya, clojure-mode doesn't color it :(
16:23brehautindeed
16:24brehautim pretty sure the JS SyntaxHighlighter brush does
16:26brehaut(not that that is useful when writing code)
16:32jondothey guys, i've got a couple of questions while evaluating clojure
16:32brehautjondot: just ask them
16:32brehaut~anyone
16:32clojurebotJust a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..."
16:32jondotfirst, is clj good for handling low level binary structure? something like erlangs pattern matching
16:33jondotsorry my g/f interupted
16:34hiredmanmatch (the pattern matching library) has some facilities for matching binary data, but I don't know how widespread that is in practice (I haven't used them)
16:34brehautjondot: clj inherited some pain from jvm: theres no unsigned primative types which can make unpacking some stuff difficult. but beyond that binary data is fine
16:35compjTimMc: something happenend to the :macro pathc?
16:35compj
16:35compj*patch
16:35hiredmanhttps://github.com/clojure/core.match
16:36jondoti see. well i planned my first project (just to get a feel for the language) to be an implementation of this, for ring: https://github.com/jondot/rack-ping
16:36brehauthiredman: dnolan was suggesting yesterday that people probably shouldnt build ontop of match till it gets to beta because of some gnarly issues still being resolved
16:36jondoti'm wondering, if that is a good fit for a first project - it would mostly be HTTP pipework, regex and imperative style workflow
16:37tmciverjondot: not sure about pattern matching but gloss is supposed to be a good binary data lib: https://github.com/ztellman/gloss
16:37hiredmanbrehaut: I see
16:38TimMccompj: Is it deleted? Bronsa created a new one. http://sprunge.us/bWcc
16:39compjI mean will it be added
16:39jondottmciver: thanks, that looks interesting
16:40TimMccompj: Oh, no idea. I'm not on the Clojure/core team (though I do have a CA), I'm not invested in the issue, and it has an easy workaround (I think).
16:40brehautjondot: what does rack_ping do that needs binary eating?
16:41jondotbrehaut: sorry, i was afraid someone would make the connection. it is unrelated, just me asking question #2.
16:41brehautoh right.
16:41brehautin that case, yeah ring level stuff is a fine place to get started in clojure
16:42brehautjondot: i dont know rack well enough to be able to make sense of the rack ping code though
16:43jondotwell i've also implemented the same code in javascript (node) and c# (.net) any of that make sense to you?
16:43brehauti understand all the langs, but not the libraries ;)
16:44jondotah! well, my question i guess is along the lines of - there is a bit of grunt work there, like opening a HTTP pipe, regex'ing the content, and 3-4 decision points.
16:44brehautjondot: is it just setting up a url that will attempt to test a variety of http resources?
16:44jondotyes.
16:44brehautjondot: thats all trivial!
16:44brehautclj-http takes care of making http connections easily
16:45brehautthink of it as the dual of ring github.com/dakrone/clj-http/
16:45jondotyes, it is very trivial, but my closest background to lisp is scheme (i've never even opened a socket in scheme) :)
16:46brehautive never opened a socket in clojure ;) not directly but ive written some xmlrpc crap which is similar to what you are doing
16:46brehautjust with more mess
16:46jondotwell, great then, i'll give it a try for fun.
16:46brehautjondot: https://github.com/brehaut/necessary-evil/blob/master/src/necessary_evil/core.clj
16:47RaynesI've opened a socket.
16:47RaynesI didn't like what was inside.
16:47jondothehe
16:47Rayneshttps://github.com/Raynes/irclj has some socket stuff, I think.
16:47compjCA is quite a barrier if you just want to make a small contribution
16:48RaynesI agree, but it has been discussed until the end of time and they aren't going to change it.
16:48compjvery sad but they surely have their reasons
16:48brehautjondot: i dont claim that that lib is good code, but its doing the mechanical stuff you want
16:49jondotgood, i think both of those project make a great reading for newcomers (or at least myself)
16:49compjisn't there a simple way to just open a ticket or point to an issue/patch?
16:49jondotah!! and the last question - clj does have tail call right? courtesy of JVM?
16:49RaynesThey use JIRA which… Sorry, I actually have no clue what they use that abomination.
16:49Raynesjondot: It doesn't. But it has 'recur' which works around that.
16:50brehautjondot: nope. it has loop / recur to simulate self calls in the tail position
16:50RaynesWell, you don't need a loop for a recur.
16:50brehautof course. my bad
16:50jondothmm is that JVM's fault? i remember one platform which didn't have TCO that felt very weird to me.
16:50Rayneshttps://refheap.com/paste/388
16:50brehautif you want mutual recursion to be tail recursive you need a trampoline
16:51RaynesThe JVM doesn't have anything for tail calls.
16:51TimMcjondot: JVM might add TCO some day, there was talk of it.
16:51brehautyeah the JVM is to blame. clojure could just do its own tialcalls (like scala does) but that causes problems for interop
16:51TimMcDidn't make it into 7.
16:51Raynesjondot: See my paste above for an example of recur.
16:51jondotoh, well nice to know that scala does it. thanks Rayens - checking it
16:51Raynesjondot: You can basically just replace a tail call with recur and it magically works.
16:52jondoti see, well from my narrow experience, looks like good enough
16:53jondotthanks guys, i've learnt a lot, off to start fiddling around with ring!
16:54technomancyavian has TCO
16:54Raynestechnomancy: And flu.
16:54Raynes~rimshot
16:54clojurebotBadum, *tish*
16:54brehautavian?
16:54technomancyRaynes: how badly do you want it?
16:55RaynesThat sounded dirty.
16:55technomancyclojurebot: avian is an alternate JVM implementation that's capable of running some subset of Clojure with TCO and continuations: http://oss.readytalk.com/avian/index.html
16:55technomancyit also can AOT-compile straight to machine code
16:55technomancyclojurebot: where did you go?
16:55clojurebotPardon?
16:55brehauthuh thats really interesting
16:56RaynesYeah, it's totally stellar, dood.
16:56technomancyclojurebot: avian is an alternate JVM implementation that's capable of running some subset of Clojure with TCO and continuations: http://oss.readytalk.com/avian/index.html
16:56clojurebotRoger.
16:56brehauthows its performance compared to oracle/open jdks?
16:57clojurebotAlles klar
16:57technomancybrehaut: not very good
16:57brehauti guess that shouldnt be surprising
16:57technomancyit's intended for embedding in larger C programs a la guile IIUC
16:58brehautoh right. thats interesting in its own right
16:59arkhis there a why to specify classpath for clojure-jack-in ?
17:00brehautarkh: err, i would guess that you do so in the project.clj for the project you are jacking in to
17:00raekarkh: clojure-jack-in uses whatever classpath leiningen provides it.
17:01arkhI'm specifically running into a problem with clojurescript one and it's dependences that aren't in ./lib
17:02arkhmaybe I just need to look at leiningen but clojurescript one has a shell script that grabs its sundry dependencies
17:09brehautholy crap. international shipping on oreilly books is prohibitively expensive 30$
17:09kedoodekebooks are the future
17:09jodaroand the present
17:11brehautno kidding
17:14arkhhow does one add to what lein builds for a classpath?
17:15technomancyarkh: I think you should try the lein-cljsbuild plugin
17:15schleyfoxhi, I'm having a bit of trouble with proxy. I'm using a lib that requires anonymous classes derived from a class, so I'm proxying it. It's two functions are the same arity and name but different types
17:16schleyfoxI'm type hinting in my proxy, but I can't seem to get the right method called
17:16phil_technomancy: ive been using cljs-watch for now but this looks great
17:20arkhbrehaut, raek, technomancy: thank you
17:24schleyfoxso any ideas on why proxy is ignoring my type hints and proxying the wrong function?
17:24the-kennyphil_: cljsbuild is awesome. I used cljs-watch some weeks ago too, cljsbuild is much better :)
17:24the-kenny(though not perfect)
17:25brehautschleyfox: you'll probably want to paste up an example somewhere (gist, refheap etc)
17:26emezeske_the-kenny: taking suggestions on how to make cljsbuild perfect. ^_^
17:26the-kennyemezeske_: haha :D
17:26the-kennyemezeske_: I'll have to try the newest version first, I'll come back to you :)
17:26muhoodidn't proxy get replaced by something else? reify maybe?
17:26emezeske_the-kenny: cool, thanks
17:27technomancyemezeske_: do you have a version that uses the canonical clojurescript artifacts yet?
17:27brehautmuhoo: not exactly. proxy fills a similar but different role
17:27emezeske_technomancy: yep, the latest version depends on them
17:27technomancygreat
17:27brehautmuhoo: in particular proxy's are fully dynamic (and can be monkey patched!) and allow you to proxy to a class, where reify is only protocols and interfaces
17:27the-kennyemezeske_: One thing which I found slightly annoying was the copying of the .clj files to the cljs dir in order to make crossover compilation possible.
17:28the-kennyemezeske: Also, lein cljsbuild auto didn't watch the crossover source-files.
17:29emezeskethe-kenny: regarding point #2, when you try the latest version, if it doesn't do that, could you open an issue? I thought that worked.
17:29emezeskethe-kenny: regarding point #1, would you prefer they were copied elsewhere? or just used in-place?
17:30schleyfoxbrehaut: https://gist.github.com/1665869
17:30schleyfoxmuhoo: also reify works on protocols and interfaces
17:31schleyfoxI need concrete class stuff
17:31hiredmanschleyfox: type hints like that do nothing for proxies
17:32hiredmanthey work by name+arity
17:32the-kennyemezeske: In-Place. It's too easy to confuse the copy with the original .clj and make changes on the wrong file
17:32schleyfoxhiredman: damn, any way to get that behavior?
17:32the-kennyemezeske: I'll open that ticket when it fails with the newest version :)
17:32hiredmanso you'll need to check if ther argument is an instance of something else and forward via proxy-super
17:33hiredman(if (instance? … …) do-stuff (proxy-super thisMethod …))
17:33schleyfoxhiredman: but from the docs: "they have no other access to protected members, nor to super, as these capabilities cannot be proxied."
17:33hiredman,(doc proxy-super)
17:33clojurebot"([meth & args]); Use to call a superclass method in the body of a proxy method. Note, expansion captures 'this"
17:34schleyfoxyeah, I just did
17:34kmicuemezeske_:cljsbuild support for ":define "goog.userAgent.ASSUME_MOBILE_WEBKIT"
17:34kmicu" in project.clj would be great! :)
17:34schleyfoxcool, thanks
17:34the-kennyemezeske: Sorry, have to go. University is so annoying :(
17:35the-kennyNight!
17:36MenTaLguYhi, so I was reading http://clojure.org/lazy, and I'm not sure I fully understand why the "step" helper function is necessary to avoid a leak
17:37hiredmanthat is old stuff
17:37hiredmanstreams are currently off the table
17:37MenTaLguYeh?
17:37MenTaLguYis lazy-seq being dropped from future versions of clojure then?
17:37hiredmanoh, sorry that is not the streams page, forget I said anything
17:37MenTaLguYoh
17:37hiredmanstreams are something totally different
17:38nickmbaileyoh i saw the streams page the other day and thought it looked interesting, not happening?
17:39broquaintI'm wonder if I'm getting lazy when I consider a lein plugin to add deps to project.clj e.g lein add-dep noir ...
17:41hiredmanhttps://gist.github.com/a1f737bfe0d70a385d4c
17:41emezeskekmicu: is that a cljs compiler option?
17:42kmicuemezeske: yes java -jar compiler.jar --help
17:42kmicuemezeske: more info in Google Closure Definitive Guide
17:43emezeskekmicu: do you know if there's anyway to pass that option via the normal 'cljsc' command?
17:43kmicuemezeske: i try to run ClojureScript One on Android and now I've done several tricks like that option manually :)
17:44emezeskekmicu: I see. Right now, I think the options that can be passed through the clojurescript compiler into the google closure compiler are kind of limited
17:45emezeskekmicu: if you wouldn't mind opening an issue at https://github.com/emezeske/lein-cljsbuild/issues?sort=updated&amp;direction=desc&amp;state=closed , I'd appreciate it
17:45MenTaLguYhmm
17:45kmicuemezeske: no problem
17:45MenTaLguYso is the helper function, "step", really necessary to avoid a leak in the example on clojure.org/lazy?
17:45emezeskekmicu: thanks.
17:45schleyfoxhiredman: ok, so the issue now is that my proxied method only gets called from within the method that I proxy-super to, so my proxy is removed while it executes
17:45MenTaLguYor is that there for some other reason
17:46schleyfoxhiredman: I assume this is now the time to break out my diddling gloves and get real close with RT and java
17:46broquaintThanks, hiredman :)
17:47broquaintAha, it's elisp, time to write me a keybinding.
17:50hiredmanschleyfox: you'll need to gen-class most likely
17:51hiredmanbroquaint: I think that gist may be missing bits like the favorite-libraries and get′
17:52hiredmanbroquaint: https://gist.github.com/e6a92b792d43775ad615
17:57schleyfoxhiredman: thanks for the tips, I think I'm just going to extend the class in java to take a provided IFn and invoke it
17:57TimMcMenTaLguY: It does seem kind of weird, doesn't it?
17:57MenTaLguYyeah, I'm actually trying the example now without the helper fn, and it seems to work fine without any extra memory usage
17:58TimMcMenTaLguY: Actually... how do you write it without the helper?
17:58broquaintThanks again, hiredman :)
17:58MenTaLguY(defn myfilter [pred coll]
17:58MenTaLguY (lazy-seq
17:58MenTaLguY (if (pred (first coll))
17:58MenTaLguY (cons (first coll) (filter pred (rest coll)))
17:58MenTaLguY (filter pred (rest coll)))))
17:59MenTaLguYideally you'd really want to call seq on coll and then save that in a local
17:59TimMcAh, right. I've seen that style all over the place.
18:01lpetitMenTaLguY: when does the iteration stop in your definition ? ^^ :)
18:01phil_is assoc-in copy-on-write in cljs?
18:02acljhi =D
18:02phil_lpetit: i assume (pred) returns nil when (first coll) returns nil
18:02MenTaLguYlpetit: oh, whoops, I forgot a (when)
18:02MenTaLguYyeah, but pred returning nil won't terminate iteration
18:02dnolenphil_: everything except cons'ing on a seq is copy-on-write
18:02dnolenin cljs
18:03lpetitMenTaLguY: a when-let will also store (first coll)
18:03phil_MenTaLguY: if(nil) is false i think?
18:03acljanyone tried to create libs in clojure and import them in android ? how is the performance ?
18:03phil_dnolen: i mean "real" copy-on-write, like vectors etc, i.e. without data reuse
18:04dnolenphil_: maps, sets, vectors all copy-on-write
18:05technomancyaclj: not very good
18:05phil_defrecords? or are they just maps?
18:05lpetitphil_: yes, any data structure provided by clojure, by default (that is, unless explicitly specified otherwise in the doc)
18:06algtechnomancy: i mean, not develop the entire app in clojure, but only a set of lib to import in the java code of the app
18:06technomancyalg: you can't really trim clojure code down below a certain level; it brings the whole runtime with it
18:07phil_lpetit: im not talking about persistence, the problem is that cljs copies the WHOLE vector / map etc whenever something changes, as opposed to the normal clojure data structures where only a small part is created from scratch and everything else is reused
18:07lpetitphil_: oh indeed, (blush)
18:08phil_:)
18:08phil_so im outta luck unless i patch em myself :(
18:09TimMcphil_: a.k.a. contribute a patch
18:09MenTaLguYyeah, I seem to be having a really hard time provoking the space leak that clojure.org/lazy warns about, even without using a helper fn
18:10MenTaLguY(myfilter #(= % 20) (map inc (range 10000000000))) has been running for a couple minutes now, and the resident size and heap size are still flatlined
18:10phil_TimMc: yea, im planning on doing so anyway, just not yet... i heard there is some contributor agreement or something in place?
18:10MenTaLguY(more or less)
18:11algteachnomancy: that's a pity, thanks
18:11technomancyhah; teachnomancy... nice.
18:15TimMctechnomancy: I suppose resource-constrained platforms like Android are an argument against the uberjar distribution model.
18:16technomancyTimMc: I dunno, Android is already absolute crap at code-sharing
18:16TimMcAlthough... maybe two Clojure apps *wouldn't* be able to share a Clojure instance. I don't know enough about JVMs and classloaders.
18:16TimMcAh, OK.
18:16technomancydead-code elimination will likely be much more beneficial
18:16TimMcInteresting.
18:17klutometisAnyone have any idea how I'd quote caret? '^ doesn't work: the reader thinks I'm talking about metadata.
18:18Chousukecaret? as in the character?
18:18Chousuke\^
18:19klutometisChousuke: I'm trying to use it as a symbol, not a character.
18:19Chousukeyou can't.
18:19brehaut(symbol "^")
18:19klutometisI guess (symbol "^") suffices, but it's ugly.
18:19klutometisbrehaut: Thanks.
18:19Chousukeit's an illegal symbol though
18:19TimMcklutometis: Ugly things shold look ugly...
18:20Chousukeso you really shouldn't :P
18:20klutometisTimMc: Oh, Zeus; really? In Scheme, no character is ugly.
18:21TimMcklutometis: Shceme uses symbols differently.
18:21Chousukewhat do you need a caret symbol for anyway?
18:21klutometisI'm defining a regex-like DSL, by the way, where ^ signifies ordered subsets; it's a beatiful pun, I think.
18:21TimMcklutometis: (^ 4 5) is gonna fail.
18:21Chousukeyeah, you can't use ^ for your own purposes
18:21Chousukeit's a reader macro
18:22klutometisTimMc: You're right; that sucks. Ok: maybe `!', then. Though I've got to find something else for `not'. Maybe `~'.
18:22klutometisThanks.
18:22amalloy~ won't make you very happy either
18:22clojurebotHuh?
18:23amalloyfor similar reasons
18:23TimMcklutometis: Use some non-ASCII. :-P
18:23Chousukewell, ~ is not a reader macro
18:23Chousukethough I'm not sure if it works outside `
18:23Chousuke,~
18:23TimMc&(let [~ 4] ~)
18:23lazybotjava.lang.RuntimeException: Unmatched delimiter: )
18:23hiredmanwell it is, but it isn't
18:23clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading character>
18:23Chousukehmm, I suppose
18:23hiredmanlike '
18:24brehauthow about (💩 4 5)
18:24Chousukeso ~ is a reader macro outside syntax-quote but doesn't work :P
18:25TimMc&(let [~~ 4] ~~)
18:25lazybotjava.lang.RuntimeException: Unmatched delimiter: )
18:25amalloyjeez, brehaut, you should hang out with us on the BMP. my font doesn't have a glyph for that one :P
18:25brehautamalloy: BMP ?
18:25TimMcOh, I thought he was suggesting question-mark.
18:25TimMcBasic Multilingual Plane
18:25brehautnope: unicode pile of poo
18:26brehautsorry
18:26TimMcPick stuff from the Emoticons block: http://www.fileformat.info/info/unicode/block/emoticons/images.htm
18:27amalloyi only vaguely know what the basic multilingual plane actually means, but since my client rendered that as a three-byte pile of soggy mess, i think it must be outside the two-byte BMP area
18:28TimMchttp://www.fileformat.info/info/unicode/char/1f4a9/index.htm
18:28TimMcHaha, the spec actually says "poo".
18:28brehautfrighteningly on the mac its rendered with a little colored image and it has eyes
18:30TimMchaha
18:30TimMcIt's from a block that is mostly (all?) from Japanese charsets
18:30brehautthe emoji set?
18:30TimMcHmm, perhaps not...
18:31TimMc"U+1F46F WOMAN WITH BUNNY EARS" <-- well, maybe
18:32brehauthaha
18:32TimMcThere's stuff in there like "blue heart", "green heart"... is this supposed to include color? o.O
18:34amalloyTimMc: you didn't know? unicode uses three bytes to encode RGB color, so the BMP is just all the different colors for "squarish blob"
18:38TimMchaha
19:08solussdlong shot, but does anyone have any idea why my program would blow up when it tries to add a string containing a ≪ to a collection? It works fine in the repl but the same code blows up when executed from a jar
19:17stevesj76debating on the use of futures vs agents when we don't care about the return value. any advice?
19:17stevesj76(sending email in the background)
19:21brehautfutures would be my pick because its simpler
19:21brehautthey both use the thread pool under the hood i believe
19:21stevesj76does that mean that the thread pool works like send for agents?
19:22brehautyeah i believe so
19:23hiredmanno, send uses a bounded threadpool
19:23stevesj76more like send-off then?
19:23hiredmansend-off and futures use a theoretically unbounded pool
19:23stevesj76awesome thanks
19:23hiredmanyes, future uses the same threadpool as send-off
19:32dgrnbrgAre records redefinable within a repl, or are they not conducive to repl debugging?
19:32brehautyou can redefine them
19:35technomancyyou can redefine them, but not retroactively IIRC
19:35brehautexisting instances stay with the old implementation right?
19:35technomancyI think so; instances of the old record definition won't pick up the changes even though they will claim to be of the same class
19:35technomancyor rather, they will claim to be of a class which is visually indistinguishable from the current one, but actually different
19:36brehautsure. that makes sense
19:37brehautthats going to result in potential funny interactions with protocols right?
19:37dgrnbrgbrehaut, technomancy: thanks
19:37dgrnbrgI'm currently using protocols and records and I'm getting lots of class already defined exceptions from the repl
19:38dgrnbrgI just want to develop rapidly, and get away from the need to constantly restart the jvm
19:39dgrnbrgman, there are weird rules for what goes inside (comment) blocks
19:39dgrnbrgNo trailing colon, no number followed by 2 asterisks
19:40hiredmandgrnbrg: it has to be a readable form
19:40dgrnbrgAre those bugs or quirks?
19:40hiredman(comment ...) is a just a macro
19:40hiredmanso the body has to pass through the reader
19:40dgrnbrgIs there a way I can make it shut up?
19:40hiredmanuse ; or #_
19:40dgrnbrgjust totally disable reader input
19:40clojurebotTitim gan éirí ort.
19:40dgrnbrg; would be as effective at that?
19:41dgrnbrgawesome, I can prefix (comment...) lines with ; that have special characters
19:41brehautdgrnbrg: comment is not magic: its roughly just (defmacro comment [& body] nil)
19:42brehaut; is just like a line terminating comment in any other language
19:42dgrnbrgso ; is handled by the reader, while (comment) isn't?
19:42dgrnbrgcomment being a macro
19:43brehautcorrect
19:43brehaut#_ is also handled by the reader, but it behaves different (its still form oriented)
19:43dgrnbrgbrehaut, when do I want #_ vs. ;?
19:44brehautwhere comment results in a nil, #_ skips the form entirely
19:44dgrnbrgah, i see
19:44brehaut,(if #_true false :a :b)
19:44dgrnbrgso comment is an argument to a function potentially?
19:44clojurebot:b
19:44brehaut,(if true false :a :b)
19:44clojurebot#<CompilerException java.lang.RuntimeException: Too many arguments to if, compiling:(NO_SOURCE_PATH:0)>
19:44brehaut,(if (comment true) false :a :b)
19:44clojurebot#<CompilerException java.lang.RuntimeException: Too many arguments to if, compiling:(NO_SOURCE_PATH:0)>
19:44brehautexactly
19:44dgrnbrgahah
19:45dgrnbrgvery interesting
19:45dgrnbrgI really like clojure
19:45dgrnbrgI'm using it to write an fpga programming language
19:51brehautdgrnbrg: clojure is a likable language ;)
19:53TimMcsolussd: Can you give me a minimal testcase with the string?
19:58TimMcI'd like to compare simple version numbers (3, 1.2.0, etc.) -- anyone have a thought on that?
20:00brehaut,(compare [3] [1 2 0])
20:00clojurebot-1
20:00TimMcooh
20:00brehaut:)
20:00TimMcbrehaut: How do I drop trailing zeroes?
20:01TimMcI want 1.2 == 1.2.0
20:01TimMcI guess I could preprocess with a regex. -.-
20:01brehaut,(take-while (complement zero?) [1 2 0])
20:01clojurebot(1 2)
20:01technomancyTimMc: there's a simplistic implementation in leiningen.core.main/version-satisfies?
20:01TimMc,(take-while (complement zero?) [0 0 3 0 1 2 0])
20:01clojurebot()
20:01brehautrats
20:01TimMcIt can't be done in the standard way.
20:02TimMcI mean, in a take/drop way
20:02TimMcWith two reverses it becomes simple.
20:02brehautah yes.
20:02brehauttheres a name for that sort of operation
20:02brehautbut i cant remember it
20:03TimMcdrop-last is close...
20:04TimMctechnomancy: Oh, is that on master?
20:04brehautTimMc: i'd just do the reverse trice
20:05technomancyTimMc: aye, in the leiningen-core directory
20:05TimMcbrehaut: 3 times seems a bit excessive, no? :-P
20:05brehautTimMc: conjugate is the name of that op
20:06solussdTimMc: I've figured out that calling out to libc/stat with a file-path that contains non-ascii characters doesn't work. Unrelated to clojure in every way. thanks though. :)
20:07TimMcsolussd: Heh, OK.
20:10technomancyso... should throwing an exception be treated as a side-effect (something you should do before your return value in a when) or placed inside an if next to the return value?
20:10technomancyI've always done the former but haven't thought about it much
20:11TimMc"when" screams "side-effect". It also simplifies the visual flow of control.
20:12brehaut,((fn [a b] (let [s->v (fn [vs] (vec (reverse (drop-while zero? (reverse (map #(Integer. %) (.split vs "[.]")))))))] (compare (s->v a) (s->v b))) "0.1.3.0" "0.1.3")
20:12clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>
20:13brehaut,((fn [a b] (let [s->v (fn [vs] (vec (reverse (drop-while zero? (reverse (map #(Integer. %) (.split vs "[.]")))))))] (compare (s->v a) (s->v b)))) "0.1.3" "0.1.3.0")
20:13clojurebot0
20:14brehauttechnomancy: i'd treat it as a side effect i think?
20:15TimMctechnomancy: version-satisfies? uses #"\d" instead of #"\d+" -- probably a bug.
20:15technomancyTimMc: oy; yes
20:15technomancybrehaut: yeah, I'm starting to think the only people who'd consider the alternative reasonable would be folks who have been damaged by a runtime that doesn't support exceptions. =)
20:15brehauttechnomancy: lol :)
20:16brehautis there a runtime that doesnt support exceptions?
20:16TimMcbrehaut: Ah, I like [.] instead of \\.
20:16brehautthe robot eye operator
20:16technomancybrehaut: I mean returning integer error codes
20:16technomancyC
20:16brehauttechnomancy: aha right
20:17TimMcbrehaut: I'll end up using \d+ after seeing technomancy's impl.
20:17brehauttechnomancy: some haskell programmers would suggest that exceptions form an implicit sum type and that you can use monads to control the flow without having to do a violent stack unwind
20:17technomancyI believe them; you can do anything with monads apparently.
20:17brehaut(eg using an Either type)
20:18hiredmanexcept the stack unwind is faster
20:18hiredman(on the jvm)
20:18brehauthiredman: sshh!
20:18schleyfoxthat just sounds painful and academic
20:18technomancydidn't realize they could be used to curb violence though
20:18hiredmantechnomancy: in the same way any weapon can be used to curb violence
20:18brehauttechnomancy: only on the stack
20:18tavisbrehaut: something's not Right
20:18dgrnbrgHow do I set the hierarchy that a multimethod uses? I tried writing (defmulti docstring dispatch-fn :hierarchy myhier) but it failed with PersistantArrayMap cannot be cast to IRef
20:19dgrnbrgbut if I remove ":hierarchy myhier" it works
20:19brehauttavis: wait. i thought right was the error path
20:19tavisdepends, are you left handed?
20:20technomancyTimMc: well here's your chance for a sticker
20:20tavisLeft is usually the error
20:20brehauttavis: so it is; apparently ive just always visuallized the type backwards in my head :P
20:21TimMctechnomancy: I think I already qualify.
20:21technomancyoh, nice
20:22tavisbrehaut: well, things are upside down in your part of the world ;)
20:22brehautthats true enough
20:22tavisI lived in Dunedin for 5 years, btw
20:22brehautoh right
20:22taviswas in Hamilton last year
20:22brehautuniversity?
20:22tavisyep
20:22brehauthuh
20:22brehautim in hamilton this year
20:23tavisfigured
20:23technomancywow, NZ is really milking this LOTR thing for all it's worth; naming a city after the Dunedain.
20:23brehautlol
20:23amalloytechnomancy: fwiw, i prefer (... (if (broken?) (throw...) (work))) to (... (when (broken?) (throw...)) (work))
20:23technomancyamalloy: exprain?
20:25amalloyit feels to me like two directions the computation could go: throw an exception, or work. the when-variant reads more like: "i'm going to do work, but first i may need to do this other thing as a side effect to make it work"
20:25technomancyyou mean like ... pre-conditions? =)
20:26technomancyactually I should just use real preconditions for this
20:26technomancyderp
20:26solussdhmm. shouldn't I be able to create a NativeString like this: (com.sun.jna.NativeString. "myString" true), I get an exception: [Thrown class java.lang.IllegalAccessError] any ideas?
20:26TimMctechnomancy: I'll send a pull request, mostly because I need the practice.
20:27hiredmansolussd: my guess is nativestring's constructor is private
20:27solussdhiredman: hmm. docs say public: http://jna.java.net/javadoc/com/sun/jna/NativeString.html
20:28hiredmanwhat does the rest of the stacktrace say?
20:29TimMctechnomancy: Umm... should I be able to run lein 2 using lein 1.6.2?
20:29technomancyTimMc: you should be able to operate on leiningen-core using lein1
20:29technomancyfor the top-level project use the bin/lein script
20:29TimMcgot it, thanks
20:31TimMctechnomancy: Do you prefer people create feature branches, or just work on the target branch?
20:31solussdhiredman: ah ha! com.sun.jna.Native/toCharArray is what I needed. some reason, despite the docs, NativeString is not public
20:32technomancyTimMc: depends on the work. your regex tweak can go on master. =)
20:33TimMcConditional on complexity, got it.
20:38dgrnbrgCan anyone show me code that uses defmulti with the :hierarchy optional argument?
20:38dgrnbrgI tried (defmulti name #(stuff %) :hierarchy my-hierarchy) but it doesn't compile
20:40amalloyyou need to give it a ref of a hierarchy, so that it can be modified when you (derive) something
20:41amalloy&@#'clojure.core/global-hierarchy
20:41lazybot⇒ {:parents {}, :descendants {}, :ancestors {}}
20:41dgrnbrgamalloy, could I do #'my-hierarchy if I def my hierarchy as a global var?
20:42technomancyamalloy: language!
20:42amalloyprobably. i dunno, try it
20:42dgrnbrgso that's not a standard pattern?
20:42dgrnbrgI tried it, it works
20:43amalloysetting up hierarchies for multimethods is not very common
20:43TimMcIt's not deprecated, though.
20:44dgrnbrgok, i see
20:44dgrnbrgwhat's the function like use for namespaces that are already loaded?
20:45TimMcdgrnbrg: refer
20:45dgrnbrgthanks
20:45technomancyyou can just keep doing use though
20:46dgrnbrgIs a hierarchy mutable or immutable?
20:46dgrnbrgOh, I see
20:46dgrnbrgI'm supposed to def an atom for the hierarchy
20:46dgrnbrgmaybe?
20:46dgrnbrgdoes derive have side effects?
20:47dgrnbrgderive doesn't have side effects
20:47dgrnbrgit seems like that should be documented
20:53TimMcdgrnbrg: Of course it does, it changes the hierarchy!
20:54tavisamalloy: I think lazybot just insulted your parents, your ancestors and descendants as a retort to &@#'
20:59TimMcInteresting design decision there.
20:59TimMcThey could have written it so that you had to swap! and explicitly refer to a hierarchy.
21:00TimMcI suppose derive and underive are safely repeatable, though.
21:25TheBusbyQ: Anyone have any experience effeciently serializing seq's of Clojure data structures?
21:26brehautyes someone is bound to
21:26TheBusbycurrently using a combination of pr-str and java.util.zip , but having issues with custom dictionaries for dealing with longs seq's of maps
21:26brehautwhy?
21:26clojurebotWhy is the ram gone is <reply>I blame UTF-16. http://www.tumblr.com/tagged/but-why-is-the-ram-gone
21:27brehaut~botsnack
21:27clojurebotthanks; that was delicious. (nom nom nom)
21:27TheBusbyworking with rather large amounts of data, like 100M records like {:name "bob" :age 44}
21:27brehautTheBusby: building strings rather than using a string builder (or printing to *out*) is inefficient
21:27TheBusbyit all gets converted to byte[] in the end
21:28brehautTheBusby: what do you mean by " issues with custom dictionaries"
21:29TheBusbyjava.util.zip uses huffman encoding to reduce the space needed for common symbols
21:30TheBusbyif I compress all 100M records at once, everything works fine
21:30TheBusbybut if I want to compress a record at a time, you need to provide a "dictionary" (java API term)
21:30TheBusbyso the compression routine knows what is common and what isn't
21:31TheBusbysame even if ":name" only appears once in each string, the fact that it appears in 100M strings means it's a good candidate for reduction
21:31brehautTheBusby: what is the exact class you are using?
21:31TheBusbyanyways, this was just the road I was currently going down. Curious if anyone else had encountered similar issues and had other solutions
21:31TheBusbybrehaut: class I'm using for compression? java.util.zip.deflate
21:32TheBusbybrehaut: should I be looking at a different compression library?
21:32brehautTheBusby: if you use an output stream i think you will have more luck
21:33TheBusbybrehaut: that would be compressing all of the records at once though wouldn't it?
21:33brehautTheBusby: i havent done any file IO in a while, but i recall that output streams can be stacked. *out* is an OutputStreamWriter of some description
21:33brehautTheBusby: pass
21:33TheBusbybrehaut: unfortunately I need 100M independent compressed byte[] :(
21:34brehautdoes it have to be defalte ?
21:35TheBusbybrehaut: no another library would work, but I need fast random access of the 100M records/elements
21:35brehautTheBusby: right. zip will let you have random access (each map becomes a file)
21:36brehautTheBusby: and gzip uses adaptive compression so it doesnt need to know the entire contents at once
21:36TheBusbybrehaut: Just FYI, each map becomes a byte[], which is stored in RAM
21:37TheBusbyisn't gzip ~= java.util.zip.Deflator?
21:37brehauthmm. it might be?
21:38brehautim out of my depth sorry
21:39TheBusbybrehaut: any other ideas of how to store a large number of maps in RAM?
21:39brehautTheBusby: i'd store them in a DB of some kind, perhaps with a cache in front of it
21:40brehautfrom the sales pitch, redis sounds like it might be a good choice
21:40TheBusbymost DB's have a significant overheard for each record
21:40brehautthey do
21:41TheBusbyI looked a redis for something else a year or two back and it had an overhead of 10-20B per record
21:41TheBusbythank you for the advice though, I'll double check to see if they've improved things! ;)
21:41schleyfoxTheBusby: to be fair, so do most languages
21:42brehautTheBusby: the reason i would use a DB is that they have already put the hard work into managing memory and caching etc
21:42TheBusbyif you store the whole data set in memory though, typical (non-CPU) caching isn't effective
21:43brehautif you have to store the whole dataset in memory and are concerned about cpu though, compressing each record is going to eat a lot of CPU too though
21:43brehautalso, if its 100MB and i knew it wasnt going to grow fast, i'd just put the whole lot into a map
21:43brehautmap of maps that is
21:43TheBusbydecompression is fairly fast though
21:43brehautand eat the ram
21:43clojurebotNo entiendo
21:44TheBusbyfaster than RAM access in some cases
21:44brehautTheBusby: my preference is always for a simple solution first though
21:45TheBusbybrehaut: I'm a firm believer in KISS as well. Unfortunately that isn't really suitable here. KISS in my case would probably be a Hadoop cluster... :(
21:45brehautTheBusby: out of curiosity, what are you trying to solve?
21:47TheBusbybrehaut: Building graphs to describe entities and then match them together from multiple data sets
21:47brehautTheBusby: do the entities have consistent keys and change infrequently?
21:48TheBusbybrehaut: no fairly static
21:48brehautTheBusby: this is hypothetical, but you might find that records use less ram than maps
21:48TheBusbybrehaut: an example would be taking data sets about people and matching them together (not what I'm actually doing)
21:49TheBusbybrehaut: records or structs would be great, but unfortunately this is fairly schema-less :(
21:49brehautoh :(
21:49TheBusbybrehaut: using the people example, everyone has a name but not everyone has a dog
21:57TheBusbybrehaut: thanks for the input, I'll see if I can put up a gist or a brief blog when I get something going. ;)
21:57brehautTheBusby: id be interested to see that
21:59schleyfoxTheBusby: I know nathanmarz is writing a book basically just about that
22:00TheBusbyschleyfox: I hope to catch him on IRC or at the Conj then. ;)
22:01TheBusbyappropriate link to book: http://www.manning.com/marz/
22:01schleyfoxI believe that's the one
22:02TheBusbyschleyfox: thank you for pointing me to that. I may have to get the MEAP
22:03schleyfoxit's still pretty early stage, but the second chapter does layout a graph type structure that may be along the lines of what you're thinking
22:03TheBusbyat the moment though, I'll see if I can put together a little library for compressing a large seq
22:03schleyfoxvery hadoop/storm oriented though
22:03schleyfoxnice
22:04TheBusbyschleyfox: if my data set was 10x larger I'd be doing that, since I can fit everything into RAM though (< 100GB) I've found it's faster to keep everything on one box since in many cases the data sets are have links to each other everywhere
22:04schleyfoxyeah, that makes sense
22:05TheBusbyclojure's sequence library makes so many operations so convenient. I'd love to stick a compression/serialization library in the middle somewhere just to save on memory usage
22:06TimMcMan, is there any reason why ###{1 1 1} should throw?
22:06schleyfoxthat would be awesome
22:06TimMc&#{1 1 1}
22:06lazybotjava.lang.IllegalArgumentException: Duplicate key: 1
22:06dgrnbrgTheBusby, fyi, you can add keys to records that you didn't initially declare on them and they'll go into an augmentation map thingy
22:07dgrnbrgTheBusby, so if you have some common data, they can sit in records, but you can use it just like a map otherwise
22:07TheBusbyOoooh that sounds very valuable!
22:07phil_TimMc: a hash set with duplicate keys doesnt make sense :/ or am i misunderstanding something?
22:08TheBusbydgrnbrg: Wouldn't I still need to serialize and compress though if I have many strings?
22:08dgrnbrgYes, but for RAM utilization, you wouldn't need MapEntries for the common data
22:08dgrnbrgit depends on whether each record has 4 fixed keys and 100 variable keys
22:08brehautTheBusby: is it possible to have keywords instead of strings? keywords are already interned for you so much lower ram usage
22:09dgrnbrgor 4 fixed keys and a handful of non-fixed
22:09TheBusbysorry, I meant strings as values not keys
22:09dgrnbrgstrings are also interned, often
22:10dgrnbrgyou can call String.intern() to get the interned version for certain
22:10TimMcphil_: Sets don't have instance count semantics, so it shouldn't matter if you specify something twice.
22:10tmciver,(set [1 1 1])
22:10TheBusbygoing off to read about String.intern() be back in a bit. Thanks all!
22:10TimMc(element count, whatever -- I'm making up a phrase)
22:10clojurebot#{1}
22:10apwalk,(into #{} [1 1])
22:10clojurebot#{1}
22:11TimMc,(hash-set 1 1)
22:11clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Duplicate key: 1>
22:11phil_,(into #{1} [1])
22:11clojurebot#{1}
22:11TimMc(let [x ___] #{1 2 5 x 9}) ; might fail, who knows?
22:12jeremyheilerTimMc: looks like insertion is different that instantiation.
22:12phil_TimMc: yea, but (int #{} [1 2 5 x 9]) won't
22:12phil_into*
22:13TimMcRight, there are easy workarounds, but it shouldn't even be a thing you have to think of.
22:13phil_but it shouldnt bomb out when making a new instance
22:13phil_its unexpected
22:13phil_yea
22:13jeremyheilerit's interesting
22:14apwalkis the expected way to handle it, to wrap it in a try?
22:14TimMc,(import clojure.lang.PersistentHashSet)
22:14clojurebotclojure.lang.PersistentHashSet
22:14TimMcapwalk: Nah, just create it a different way.
22:14phil_apwalk: that would be insane (if it was expected)
22:14TimMc,(PersistentHashSet/create 1 1)
22:14clojurebot#<CompilerException java.lang.IllegalArgumentException: No matching method: create, compiling:(NO_SOURCE_PATH:0)>
22:15TimMcah, that's a varargs...
22:15TimMc,(PersistentHashSet/create (to-array [1 1]))
22:15clojurebot#{1}
22:16TimMc,(PersistentHashSet/createWithCheck (to-array [1 1]))
22:16clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Duplicate key: 1>
22:16phil_the reader bombs out, not the class itself
22:16phil_(i think)
22:16phil_ah
22:16TimMcNah, the reader is calling createWithCheck
22:16phil_ok :D
22:16TimMcbut why?
22:17phil_ maybe "fail fast" philosophy?
22:18TimMcBut it's a set!
22:19phil_yea, somebody thought adding the same thing twice to a set might be an indication of a bug
22:19phil_i guess
22:19brehautcertainly for literals
22:20brehautalthough more so for maps than sets
22:20dnolen,{1 2 1 2}
22:20clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: Duplicate key: 1>
22:20TimMcThe semantics of (apply hash-set [x y z]) should be precisely identical to (into (hash-set) [x y z]).
22:20jeremyheilerphil_: the exception only goes off if the element failed to be added
22:20brehautdnolen: i think (1 2, 1 3) is a better example
22:21phil_are defrecords hashmaps?
22:21TimMcMy first thought was, "Oh, someone is trying to be clever and use the provided collection directly, and is checking it first to make sure it is safe." But that's not true, it's all conses under the surface.
22:22dnolenphil_: not quite, you have optimized access of declared keys, an internal extension map for those that aren't
22:23brehautphil_: map? says yes
22:23brehautwell, it says they are maps, but not necessarily hash maps
22:23tmciver,#{[1 2] (1 2)}
22:23clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: Duplicate key: (1 2)>
22:24tmciverHmm, page 94 of JoC shows that to work.
22:24phil_any cljs specific differences?
22:24brehauttmciver: that are in the same equality partition, so it shouldnt
22:25brehauttmciver: but you are right that it does show that
22:25tmciver"Given two elements evaluating as equal, a set will contain only one, independent of concrete types."
22:25tmciverbrehaut: it shouldn't what, fail?
22:25brehauttmciver: joy of clojure is wrong
22:26tmciverBut it's right here in black and white!
22:26brehautit probably slipped through from an older clojure where the reader didnt check keys
22:26TimMc~guards
22:26clojurebotSEIZE HIM!
22:26TimMcargh, bad timing
22:26brehaut1.1 i believe
22:26tmciverslow connection? ;)
22:27tmciverI agree with TimMc, it seems like it shouldn't throw.
22:27tmciver(to me)
22:27brehautsets at runtime shouldnt, but set literals, the ones that are baked into your source should IMO
22:27brehautimagine you have
22:28brehaut#{1 2 3 4 5 6 7 8 9 … 1}
22:28brehautlater you realise you shouldnt have 1
22:28brehautso you remove it from the end of the set
22:28brehautnot realising its there at that start too
22:28brehautthats just become an annoying bug that could have been avoided
22:29dnolenphil_: not beyond the slower performance of extending with non-specified keys
22:30dgrnbrgWhere can I find a tutorial explaining how to use tests with leiningen? I seem to be doing things wrong in a very basic way.
22:30phil_dnolen: so the extension map is a hashmap and theres some other, more optimized map for declared keys?
22:31amalloy"should" is a pretty strong word in this context, brehaut. i'd phrase it more like "given my cursory exploration of the topic, i'd be happier if ___". if sets behave the other way, the bugs that sneak in aren't eliminated; they're just replaced by different ones
22:31dnolenphil_: no map, the host type
22:32amalloyphil_: conceptually it's a more optimized map, yes: a java class with declared instance fields
22:32phil_dnolen: but there are no host types in cljs
22:33dnolenphil_: think a bit more about that :)
22:34phil_dnolen: well, everything is a hashmap in js
22:34tmciverbrehaut: I think I agree with you. literals are called that for a reason, after all. The behavior that I was expecting is achieved with the set function.
22:34phil_dnolen: or do you mean the "optimized" hosttype is a js hashmap while the extension map is a cljs hashmap?
22:34brehautphil_: everything is a hashmap with an associated constructor function
22:35brehautphil_: if there were no types in js,then the instanceof operator would always evaluate to false
22:35phil_brehaut: yes, but why is the ctor optimizing access to the keys?
22:37dnolenphil_: if JS objects were really hashmaps, JS would still be dog slow.
22:37phil_i think i understand
22:38dnolenphil_: I think it's better to think of JS Objects like Self objects, you can create slots on the fly.
22:38dnolenphil_: the fact that JS Objects inherits slots from prototype makes the hashmap analogy even more weak
22:39brehautphil_: if you can portion off ad hoc properties in a javascript object into their own object and leave a consistent set of properties for the main type (ie, like a record does) then you maintain the 'shape' that the runtime inferencer can see, so it doesnt need to keep generating underlying types
22:39brehaut(because generating new underlying types also throws guards onto slow paths and causes rejitting to occur)
22:40phil_so defrecord is creating a js prototype underneath?
22:40dnolenphil_: deftype/defrecord both create constructors functions
22:41dnolenphil_: when you extend a type/record to a protocol, this is done via the constructor fn's prototype property
22:41phil_dnolen: ok, this clarifies things
22:43dgrnbrgIs there a function to check if 2 seqs are equal, or do I do a map/reduce?
22:43dnolendgrnbrg: just use =
22:43dgrnbrgthat'll work for seqs
22:43dnolen,(= '(1 2 3) '(1 2 3))
22:43dgrnbrg?
22:43clojurebottrue
22:43dgrnbrg,(= '(1 2 3) [1 2 3])
22:43clojurebottrue
22:43dgrnbrgoh
22:44adam__has anyone seen, https://github.com/globulon/sicp-in-clojure ?
22:44adam__i was wondering if it maps to SICP well, or if its imcomplete
22:45dnolenadam__: I've said it once and I'll say it again. I love SICP. It's a terrible way to learn Clojure.
22:45adam__okay, I have some experience with clojure, and noticed clojure does a lot of the things that SICP teaches
22:45adam__like lazy sequences
22:46adam__thanks
22:55JanxSpirithey I imagine you guys are familiar with 4clojure?
22:55JanxSpiritI'm doing this one: http://www.4clojure.com/problem/21#prob-title
22:56JanxSpiritI came up with a function that does it
22:56JanxSpiritbut I'm just not sure what the problem wants in terms of input
22:56JanxSpiritit won't let me do a (defn ...)
22:57tmciverJanxSpirit: you can do a (fn [] ... or a #() instead.
22:57JanxSpiritOK - I probably need to go look this up but what's the difference fn/defn?
22:58tmciverdefn is a macro that def's a var, which you can't do in the 4clojure solutions
22:58tmciverfn returns a funtion object which can be called directly.
22:59JanxSpirithmm...OK - thanks!
22:59tmciver,(doc defn)
22:59clojurebot"([name doc-string? attr-map? [params*] body] [name doc-string? attr-map? ([params*] body) + ...]); Same as (def name (fn [params* ] exprs*)) or (def name (fn ([params* ] exprs*)+)) with any doc-string or attrs added to the var metadata"
22:59tmciversure
23:01brehaut(comp first (partial apply drop) (comp reverse vector))
23:01brehautworst nth ever
23:01brehaut(comp first (partial apply drop) rseq vector) ; slightly better
23:05tmciverbrehaut: ha! you haven't seen my solution!
23:05brehaut,((comp first (partial apply drop) (juxt second first) vector) [:a :b :c :d :e] 3)
23:05clojurebot:d
23:05brehautthats the winning solution there
23:05brehauttmciver: i have not :)
23:06tmciverit's better that way.
23:06brehauteverything is better with juxt ;)
23:09phil_,((comp first (partial apply drop) (juxt second first) vector) [:a :b :c :P :e] 3)
23:09clojurebot:P
23:09tmciverThat's a cool solition. It's taken me this long to understand it.
23:09tmcivers/solition/solution
23:09brehautits the too much haskell coolaid solution
23:09tmciverha!
23:10brehaut(which is to say i know enough haskell to be dangerous but not enough to be useful)
23:10adam__yeah, i learned enough haskell to be able to understand books on functional programming written using haskell
23:11brehautthat amount is worth the effort
23:11adam__there is a lot of great material written on FP that uses haskell from a pretty large academic community
23:12adam__not all of it applies though, but a lot does
23:12phil_yea but they lose me when they start using transformers on monad transformers :)
23:12brehauthaha
23:12brehautmonad transformers are much easier to grasp in clojure
23:12adam__ha, learning monads is on my news years resolution list
23:12brehautless type system syntax and magic to wrap your head around
23:13adam__i will tackle concurrency first, then go into monads
23:14phil_ive looked at clojure monads only superficially, but i have a gut feeling ill have t o adjust to working with monads without explicit types
23:14phil_(not that ive done so much with monads)
23:14JanxSpiritwhat languages do most Clojure users come from?
23:15adam__wasn't there a survey going around a couple weeks ago?
23:18dnolenhttp://cemerick.com/2011/07/11/results-of-the-2011-state-of-clojure-survey/
23:18dnolenlast survey - mostly Java / Python / Ruby
23:18adam__i think its a good thing that most people are coming from imperative langauges
23:19adam__no way clojure could bloom if it stayed in the lisp community
23:19fbru02_hey all ! how do i do a get-in to look for a key but i don't know the intermidiate keys to get there ?
23:19dnolenadam__: most people in the older lisp communities either don't care or are hostile
23:19pdklisp world can only grow so much from within itself
23:20pdkalso cl guys tend to hate clojure
23:20JanxSpiritreally? old school Lispers don't like Clojure?
23:20phil_didnt think so much java programmers are so open minded tbh :)
23:20dnolenbut cl guys tend to hate everyone even cl people
23:20JanxSpiritI come from Java/Scala
23:20JanxSpiritmy first Lisp and it's very interesting - good exercise for the brain :)
23:21adam__yeah, it really has opened my mind to what it is I am doing when I write a program
23:21phil_JanxSpirit: wait till you come to haskell, THEN youll have an excercise for your brain :)
23:22JanxSpiritI read a chapter or so of my Haskell book, but it was pretty intimidating to jump into
23:22adam__in Haskell, implemeting state can be a phd level topic
23:22JanxSpiritgot Clojure doing some things right out of the gate which has been fun
23:23phil_adam__: yea, you cant really do anything in haskell besides small 3 liner teasers without having understood monads at the very least
23:23schleyfoxI did a lot of stuff in erlang, Clojure is nice because compiling and starting code using a few dependencies isn't a week long adventure during which I feel like the Swedish Alexander Graham Bell
23:23brehauti disagree http://haskell.org/haskellwiki/Simple_unix_tools
23:24phil_schleyfox: rly? i found erlang very easy to set up and jump into
23:24schleyfoxphil_: oh it is. then try to use a couple libs outside of the standard distribution
23:24fbru02_related : what's the best way to walk over a hash?
23:25jeremyheilerfbru02_: What do you need to look at?
23:25phil_schleyfox: i was only using mochiweb and it wasnt such a problem to set up but cant talk about more complex project setups
23:26schleyfoxyeah, and rebar has helped a lot
23:26phil_yea rebar was awesome
23:26fbru02_jeremyheiler: i have a deep nested hash and need to find a specific key that should be at the any of those sub-hashes of any given depth
23:26schleyfoxbut compared to leiningen or anything of that nature, it's basically the worst
23:27metajackerlang works the same as python and ruby. there's just a path to dependent libraries.
23:27phil_schleyfox: yea ive been very pleasantly surprised by clojures eco system
23:27metajackall rebar does it set it up in a nice default way and fetch the dependencies based on git urls
23:28metajackin a way, clojure seems weird to me because it deals with build artifacts as dependencies. haven't really dealt with that since i spent most of my time in C
23:29schleyfoxmetajack: yeah, I mean, it's not too bad, but it just always bites me when I try and distribute applications to servers and such
23:29metajackif you use releases, it's kind of like an expanded uberjar.
23:29metajackrebar now makes that easy, but otherwise it can be a pain, sure
23:29metajackeven easier than java, since erlang releases include the entire runtime.
23:29schleyfoxyeah, I mean I stopped doing much erlang about the time rebar started to actually get decent
23:30metajackriak is a good example of releasable erlang code. you just unzip and type riak start. no muss no fuss.
23:31schleyfoxyeah, I agree
23:32adam__Erlang looks pretty interesting, but Clojure STM is alot better for me than the actor model
23:33schleyfoxI feel like if erlang just had a bigger ecosystem, it would just be awesome
23:35metajackerlang could use data structure literals like clojure has :)
23:35schleyfoxerlang could use a lot of syntactic/modernization type things that clojure has
23:37phil_adam__: but clojure STM aint distributed
23:38phil_there is a lib though
23:38dnolendamn I love logic programming
23:38dnolenhttps://gist.github.com/1667847
23:38phil_https://github.com/technomancy/die-roboter
23:38icylisperschleyfox: There is a nascent project on an Erlang-Clojure bridge using Chas Emerick's nREPL protocol. https://github.com/icylisper/isthmus
23:39schleyfoxicylisper: nice
23:39schleyfoxI think the extent of my clojure-erlang bridging though these days will be reading and writing to riak
23:40adam__does anyone here have experience on using clojure's concurreny along with sun grid engine ?
23:43nighty^pyr! ping
23:48brehautre:distributed stm http://avout.io/
23:48brehautadam__, phil_: ^
23:49phil_brehaut: this looks very interesting, bookmarking
23:49adam__brehaut, so this would allow me to distribute concurrent jobs across cluster nodes?
23:50brehautadam__: i dont know the details sorry
23:50adam__thanks for showing me, i'll have to read more into it!
23:50metajackteh think relevance podcast has an interview with the author of avout
23:50brehautavout is quite new
23:50metajackyou might start there
23:50brehautmetajack: good point
23:59jeremyheilerfbru02_: some questions: is the key in the nested structure more than once? is the value of the key another map?