#clojure logs

2012-01-22

00:00phildnolen: yea i might try to do it when i get bitten by perf problems in vecs and maps :)
00:00TimMcalex_baranosky: WORKS_FOR_ME
00:00TimMc(:private (meta (var foo))) was my test
00:01alex_baranoskyI'm getting an exception that the var wasn't private
00:01alex_baranoskylet me check the repl
00:01technomancy_llasram: definitely give me a heads-up if you have issues with the .deb
00:01technomancy_I haven't heard of any trouble with ant
00:03alex_baranoskyTiMc: wth, (:private (meta #'as-validation-error)) => nil
00:03alex_baranoskyhowever:
00:03alex_baranoskyTimMc, however: (:tag (meta #'as-validation-error)) => :private
00:04alex_baranoskywhat version are you using TimMc
00:05TimMcpretty weird, there. 1.3.0
00:05alex_baranoskydo you know what :tag is?
00:05TimMcYeah, it's a return type hint.
00:06TimMcIf you do ^Integer instead of :private, it should give you a :tag Integer
00:06alex_baranoskyahhhh... my repl is in 1.2.0
00:06TimMcs/:private/^:private/
00:06alex_baranoskyhow do I get lein repl to run 1.3.0?
00:07TimMcOh, does ^:keyword not work there? :-/
00:07TimMcalex_baranosky: Create a tmp project.
00:07alex_baranoskyI think it used to be #^:private
00:07TimMcOuch. Have to use the old syntax for compatibility, I guess.
00:07alex_baranoskyhmm wonder if this will mess up backwards compatibility for midje?
00:08alex_baranoskywe recently discovered a bug when using Midje with 1.2.0 I wonder if this is the source of it
00:08philis there a way to change some element in a deeply nested (immutable) data structure without having to have a reference to the root?
00:09alex_baranoskyas I somewhat recently started using the ^:private form
00:09philfor example if every element stored its parent?
00:09philthen went up the parent chain, assocd-in
00:09phil?
00:10TimMcIf I read you right... no.
00:10philbut then when an element changes all children have to update their parent references :/
00:11phili guess thats the problem
00:11philhm... cant this be done with zippers?
00:11RaynesSigh. My biggest problem in live is choosing color schemes for my editor.
00:12Rayneslife*
00:12alex_baranoskyRaynes, you're doing ok then -- I make up much bigger problems for myself
00:12Raynesalex_baranosky: Like whether or not to use defn-?
00:12phil:D
00:13philis defn- or defn ^:private better now?
00:13TimMcalex_baranosky: Eh, it's just one more char.
00:13TimMcphil: Oh, I did misread you -- yes, zippers are great for that.
00:14TimMcand good night.
00:14philTimMc: thx & n8
00:14RaynesSolarized is supposed to be the best thing ever, but it colors parentheses red and makes me want to gouge my eyes out. Tomorrow Night, my go-to favorite has a few issues and an active yet entirely unresponsive author.
00:14RaynesMy life is so hard.
00:14alex_baranoskyRaynes, I don't enjoy solarized
00:15duck1123if we're talking emacs color schemes. I'm a fan of hober
00:15alex_baranoskysupposedly it has some kind of color science behind it but...
00:15philRaynes: if youre using vim, try slate... but i guess most people here use emacs
00:15alex_baranoskyI like tango
00:15Raynesphil: I'm using Vim.
00:16philRaynes: oh then slate is a default theme
00:16alex_baranoskyin Vim I use desert
00:16Raynesphil: Mostly, I like solarized and tomorrow night because they're everywhere and thus can go with me. I like jellybeans, but it's just for Vim (so if I used Emacs again, I'd need to write one myself).
00:16philthough i dunno how it looks on other systems than mac
00:16RaynesAlso on a mac.
00:17philmacvim?
00:17RaynesOf course.
00:17RaynesAll else is blasphemy.
00:17ArafangionI like the 'billw' scheme in emacs.
00:17chewbrancaI'm partial to sunburst, I definitely prefer it to solarized
00:17philyep :) try slate, its build it
00:17philits reallt calming imo
00:17philbuilt in*
00:17RaynesIf by calming you mean eyeball exploding.
00:18philhaha :D
00:18RaynesIt highlights 'with-open' with a white background and red foreground!
00:18phil'doto' too
00:18alex_baranoskyRaynes, what do you think of desert?
00:19RaynesHideous.
00:19philwhat do you propose for a dark theme then?
00:19RaynesI'm pretty picky.
00:19philsolarized? is it dark?
00:19RaynesKind of dark.
00:19RaynesDark or light though.
00:20philah i wanted to try out that one
00:20philwhy dont you like it?
00:21RaynesIt colors parentheses red and is too low contrast even on the highest contrast setting.
00:21phildoesnt vimclojure override paren coloring?
00:22RaynesDoes it? It certainly doesn't paint them red outside of solarized.
00:22philhm i guess not by default, but theres a rainbow paren mode
00:22philwhich i wanted to try out but forgot
00:23Rayneshttp://www.vim.org/scripts/script.php?script_id=2140 is pretty fantastic.
00:24phildoesnt look bad tbh... while we're talking editors, is there any good paredit-like plugin for vim?
00:25Raynesparedit.vim
00:25phil:D
00:25Rayneshttps://github.com/emezeske/paredit.vim
00:25RaynesOur good friend emezeske ripped it out of slimv for us.
00:25RaynesHe is actually a regular here.
00:25philthis is awesome
00:25philthx
00:30IceD^hye
00:30IceD^is this code https://gist.github.com/1655774 idiomatic?
00:30Raynesphil: Try out jellybeans https://github.com/nanotech/jellybeans.vim
00:31philyea, definately better than slate
00:31philwill have to play with color themes tomorrow :)
00:32Raynesphil: Ping me when you do. We can talk about them like teenage girls about boys.
00:33philahaha yea its so exciting :D
00:34philIceD^: im a pretty big noob myself, but maybe take a look at merge-with
00:35IceD^I have good lisp background, but never used clojure much
00:35IceD^now clients asked for clojure client lib ;]
00:35philive started out recently and i like it a lot
00:36philonly thing i miss is pattern matchins as in haskell
00:36philmatching*
00:37philso i have to resort to if?s etc when a simple pattern would show my intent much better
00:38IceD^phil, thnx - merge will be good for me
00:38philnp :)
00:38IceD^(let [defaults (hash-map ...)] (merge defaults hoptions))
00:40RaynesIceD^: Sec. I'm working up an example.
00:41RaynesIceD^: https://refheap.com/paste/377 Only slightly tested.
00:41RaynesThis is what I'd do.
00:41IceD^Raynes, already there ;]
00:41RaynesWell I'm slow.
00:41RaynesSue me. ;)
00:41IceD^ahh yes, {} is syn to (hash-map)
00:42IceD^note to self - at least read intros to new langs
00:42RaynesHaha
00:43philisnt #{} hash-map?
00:43RaynesNo.
00:43RaynesThat's a set.
00:43Raynes&(type #{})
00:43lazybot⇒ clojure.lang.PersistentHashSet
00:43philaah
00:43philyes
00:45IceD^is it bad if I'll ignore clj-http and will use java api instead?
00:52RaynesIceD^: You can if you want to, but it's akin to masochism.
00:53IceD^Raynes, I'd like to keep it small and deps-less
00:53IceD^two questions (nab and not-so-nab)
00:53IceD^1. nab - how to I load code into lein repl?
00:54IceD^2. not so nab - how do I support both clojure 1.2 and 1.3
00:54technomancy_what's "nab" mean?
00:54philnoob
00:55IceD^noobish
00:55technomancy_huh; never heard that
00:55technomancy_IceD^: you should try the lein-multi plugin; it lets you run tests against arbitrary dependency sets
00:55RaynesIf having a dependency on clj-http is a problem, then sure, you can use the Java APIs. If you don't know Java, you could be in for a hell ride though.
00:56IceD^I used to develop in java like 10 years ago
00:56IceD^but that doesn't matter - I have java client lib here and will just copypaste most of the code ;]
00:57RaynesThere was a guy who wrote a pure-clojure http client. Asshole abandoned it for clj-http. I forget his name…
00:57Raynes*cough*technomancy*cough*
00:57technomancy_no such thing as a pure-clojure http client. =P
00:57RaynesClose enough.
00:58technomancy_it was kinda crap
00:58RaynesIt worked for me.
00:58Raynes:'(
00:58technomancy_but if you absolutely can't pull in apache http-client, you could give it a look
00:58IceD^looked of course
00:58technomancy_the only reason we wrote it was that leiningen didn't exist yet at that time, so you really wanted to avoid external deps
00:58IceD^but all I need is to push request and get response
00:59IceD^https://github.com/iron-io/iron_mq_java/blob/master/src/main/java/io/iron/ironmq/Client.java here is all the code
01:00RaynesIceD^: You can just call that code from Clojure. Don't even have to rewrite it.
01:00IceD^ofc, it's possible to use it within clojure, but I don't want to force our customers, which using clojure, to face java calls ;]
01:00RaynesI mean you can call it from your Clojure code.
01:01RaynesYour Clojure code can basically become a wrapper.
01:01RaynesYou can provide a nice little Clojure client that just uses your Java client under the hood preventing a lot of duplication.
01:01IceD^I know ;)
01:02IceD^estimated that - there will be more code to wrap than to write from scratch ]:)
01:08IceD^so - I have lein project and lein repl open - how do I (re)load my sources there?
01:20tavis`IceD^: haven't read all of this thread but you can't use clj-http for some reason there's always the clj-apache-http wrappers. The project seems abandoned though. Here's an update of it to clj 1.3: https://github.com/tavisrudd/clj-apache-http
01:20tavis`er, 'but *if* you can't'
01:21tavis`clj-http is a lot nicer to use
01:21IceD^tavis`, well - main reason why I'd like to avoid any clojure libs - possibility to build for both clojure 1.2 and 1.3
01:22IceD^which is kinda hard with current libs
01:22technomancy_nah, it's easy as long as you don't AOT
01:22IceD^well
01:22tavis`they should work fine with both version
01:22tavis`s
01:22IceD^say, clj-http requires clojure 1.3
01:22IceD^bam, I'm doomed
01:23Raynesclj-http doesn't require clojure 1.3
01:23RaynesAnd doesn't intend to anytime soon.
01:23Raynesdakrone would be staked.
01:23IceD^well - it requires clojure-1.2
01:23RaynesNo it doesn't.
01:23RaynesIt works fine in both versions.
01:23IceD^https://github.com/medSage/clj-http/blob/master/project.clj
01:24RaynesThat's the wrong repo.
01:24Rayneshttps://github.com/dakrone/clj-http
01:24IceD^ :dependencies [[org.clojure/clojure "1.3.0"]
01:24tavis`note it use multi-deps
01:24RaynesAnd the version in the project.clj file isn't really relevant -- if it depends on 1.2 and your project depends on 1.3, your version of Clojure will be used.
01:24IceD^aha
01:25IceD^(my head hurts ;])
01:25RaynesDependency management is hard.
01:25tavis`that really confused me as well at first
01:25tavis`especially when I didn't understand how lein worked
01:26IceD^anyway, I completed my network interaction code already using java calls
01:26IceD^how to test it now
01:26IceD^don't suggest to copypaste to repl please
01:26technomancy_best to use your editor integration
01:26IceD^technomancy_, it's emacs and we had that discussion already
01:26IceD^CL support is more important for me than clj
01:28technomancy_hm; you can use C-u M-x inferior-lisp RET lein repl RET
01:28tavis`missed that convo but you could always to what technomancy_ does and run multiple instances of emacs
01:28RaynesOr just require the namespace from the repl and test away.
01:28tavis`CL support in one and clj in the other
01:28RaynesBut being cocky doesn't help anything.
01:28IceD^tavis`, it was like 6 months ago
01:33tavis`btw, technomancy_ if the Clojure and CL versions of slime are divergent now would there be anything wrong with extending slime.el with Clojure specific goodies? Or is the plan to not diverge too far?
01:34IceD^tavis`, as I'm aware, clojure's swank's using very ancient version of slime (probably patched)
01:34technomancy_no, it's not patched; it's verbatim
01:34technomancy_tavis`: I don't have much of a plan. I've been preferring defadvice so far since it's easy enough.
01:34technomancy_if there were compelling reasons to fork I'd entertain them
01:35tavis`upstream was just too hard to track right? CL assumptions breaking things.
01:35IceD^anyway, it was pain to support both slime for my pretty CL and clojure's slime for one emacs
01:35technomancy_not just CL assumptions; general cowboy coding
01:35technomancy_no attempt at stability
01:35IceD^but yes, technomancy_ had his point why things are this way
01:35RaynesThey are allergic to releases.
01:36tavis`got to run
01:46IceD^java -cp `lein classpath` clojure.main test.clj --- any shortcut for this?
01:47technomancy_sorta; try "lein help run"
01:47technomancy_tl;dr: you need a -main function
01:47IceD^gotcha
01:47IceD^thnx
01:48technomancy_np
02:10IceD^another nab question (can't google it) - got java InputStream - want to read all data from it
02:20IceD^slurp!
03:03IceD^what's actual json lib?
03:04IceD^contrib-1.2?
03:31IceD^https://gist.github.com/1656272 - here we go
03:31IceD^it works, but I don't like one thing in particular - thrown exceptions
03:32IceD^suggest me better way for this usercase (client will call queues etc, not request directly). I do not want to just return empty array, but notify him about problem somehow
04:01manuel__hi
04:09manuel__booksearch.ly
04:09manuel__wrong chan sorry
04:18foobar27join emacs
05:57clj_newbStreamPrintServices supports printing to postscript, but not pdf ... is this right, or am I missing something?
06:13clj_newbHow do I convert a java [] to a Clojure Vector ?
06:13clj_newbI want to convert a Java _array_ to a Clojure _vector_. How do I do this?
06:15manuel__i think you can just seq them
06:15manuel__i'm a noob, but let me try
06:16clj_newbyou're right
06:16clj_newb(apply vector ... ) works
06:16clj_newbthanks :-)
06:17manuel__(seq (make-array Integer/TYPE 4))
06:17manuel__that works
07:11LauJensenFogus made a tool which produced good looking source documentation via some leon plugin, anyone remember the name? Did it reach 1.0 ?
07:17arbschtLauJensen: marginalia?
07:17LauJensenThats the one, thanks
08:10ziltiI persisted a list of byte values using spit and pr-str. Now when re-reading it and do a (byte-array (read-string (slurp filename))) it gives me an error that the data could not be cast...
08:13manuel__which version of clojure is 4clojure running?
08:15Licensermanuel__ try running (*clojure-version*) ?
08:16the-kennyLicenser: clojure.lang.ArityException: Wrong number of args (0) passed to: PersistentArrayMap ;)
08:16raekzilti: you might need to do (byte-array (map byte (read-string ....)))
08:16raeksince the numbers are boxed as longs when you read them
08:17the-kennymanuel__: The REPL linked at 4clojure runs 1.3.0 (evaluate *clojure-version*), don't know if the repl is associated with 4clojure, though.
08:18manuel__yeah
08:19manuel__i have this: http://paste.lisp.org/display/127212 for this: http://www.4clojure.com/problem/73#prob-title and get: java.security.PrivilegedActionException: java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to clojure.lang.MapEntry (NO_SOURCE_FILE:0)
08:19manuel__it works fine in my REPL though
08:19manuel__i have a bit of a hard time parsing clojure error messages
08:19raeksounds like a bug
08:20raek&(conj {:a 1} [:b 2])
08:20lazybot⇒ {:b 2, :a 1}
08:20raekmanuel__: does (conj {:a 1} [:b 2]) work at 4clojure?
08:22Licenserthe-kenny then just *clojure-version* ?
08:22manuel__it's the case
08:22manuel__hmm let me see
08:22Licenserah I see you got it already ^^
08:23manuel__it does
08:23manuel__it's (case (foo) [:x] :x) that's making trouble
08:23manuel__the [:x] part
08:23manuel__btw raek, care to explain your thinking? :}
08:24raekafaik, maps use clojure.lang.MapEntrys as its entries
08:24raekand clojure.lang.PersistentVector implements that
08:24manuel__yeah i was wondering where that map entry was coming from
08:24raek,(class (first {:a 1}))
08:24clojurebotclojure.lang.MapEntry
08:24manuel__so it's from the [:x]
08:25raekbut it doens't seem like you are using maps anywhere
08:26manuel__this breaks in 4clojure; (case 1 [1] 2)
08:26manuel__am i not getting something?
08:26raekcould be a bug in the sandbox code
08:27raekespecially if the problem only shows up at 4clojure
08:27raekhave you tried that in both 1.2 and 1.3?
08:27manuel__yah prolly
08:27manuel__nope will do
08:28raekI don't get that exception in neither 1.2 or 1.3
08:59b6n,(every? true? [])
08:59clojurebottrue
08:59b6nis that intended behaviour?
08:59pandeirob6n: i think only nil and false are false in clojure
09:00raekb6n: sure, true is the unit element of the and operator
09:01b6n,(every? #(= 10 (count %1)) [])
09:01clojurebottrue
09:01raekyou might want to use 'identity' or 'boolean' instead of 'true?', though
09:02raekanother way of saying p(x) is true for every x is to say there isn't any x such that p(x) is false
09:02b6nok, but that (count ... ) thing really astonishes me
09:03raekwhy? the predicate is never called.
09:03raek,(every? #(= 10 (count %1)) [(range 10) (range 1 11)])
09:03clojurebottrue
09:04b6nbecause I'm asking 'has every element in the collection the length 10
09:05raekthe answer is yes, all elements trivially have the length 10 since there are no elements
09:07raekthis is similar to the problem "what is the sum of all numbers in a collection"
09:07raek&(apply + [1 2 3])
09:07lazybot⇒ 6
09:07raek&(apply + [1])
09:07lazybot⇒ 1
09:07raek&(apply + [])
09:07lazybot⇒ 0
09:07raek'true' is for 'and' what 0 is for +
09:09b6nyou're right, it's a bit like multiplying with 0
09:09raekwith 1? :-)
09:10b6nat least it was astonishing to see a unit test succeed with no implementation written :-)
09:11b6nthanks for clarifying this
09:42augustlare there any purely functional web frameworks for clojure? Not sure if I like noirs thread local state etc..
09:42augustlwhere a page gets a request object passed to it and you return a response object
09:46pandeiroaugustl: don't have an answer for you but do you know of any such frameworks in other languages? i'd like to see
09:47raekaugustl: http://brehaut.net/blog/2011/ring_introduction
09:47augustlpandeiro: Rack for ruby works that way, for example
09:47augustlbut rack is a bit lower level than what you want your web framework to be ;)
09:48raekring (a library which noir is built on top of) lets you define your web app as a function from a request map to a response map
09:48pandeiroah i was thrown off by the word 'framework'
09:48raekor maybe that was what you didn't like...
09:48augustlring is similar to rack, it seems
09:48augustlraek: the flow of ring, but more utilities, basically :)
09:48augustlI like defpage etc in noir
09:49augustlnot that hard to write that myself I guess
09:55frankvilhelmsena natural choice on top of ring is fx compojure,
09:55frankvilhelmsen which has a greater degree of abstraction ontop of http
09:55frankvilhelmsenI use compojure into production successfully.
09:59augustlseems what I want is compojure + hiccup + defpage from noir
10:06frankvilhelmsenthis is verly similar to sinatra plus haml in the ruby world
10:06phil__while talking about backends, is there any erlang-like distributed library, ideally running ontop of native clojure actors?
10:10jondothi all, anyone done interop to WEKA or LingPipe for the purpose of deduping with clj?
10:18the-kennyphil__: Maybe die-roboter is something for you
10:20phil__the-kenny: thx, ill check it out
10:39goodieboyi'm playing with destructuring and wondering if there is a way to specify that I want ALL :keys to be let, like (let [{:keys :all} {:id 1}] (class id))
10:39goodieboyand if not... could a macro do something like this?
10:40msapplerwhy do you want to do this?
10:41goodieboywell, really what I'm after is a way to create bindings from a hash-map. I'd like to create a function/macro that takes a string template, and then a hash map for the variable bindings. Just like clojures string interpolation library, but use hash-maps instead
10:41goodieboy(interpoloate "this ~{n}
10:41goodieboy oops
10:42jeremyheileruse the keys function? &(keys {:foo 1 :bar 2})
10:42jeremyheiler,(let [k (keys {:id 1})] k)
10:42clojurebot(:id)
10:43goodieboyjeremyheiler: yeah I tried that, but my macro foo just isn't able to make it work
10:43jeremyheilergoodieboy: maybe post your macro then?
10:52goodieboyjeremyheiler: Here's a simplified version of what I have that should describe what I'm trying to do: https://gist.github.com/1657499
10:54goodieboyjeremyheiler: not sure if you got that last message (gist link) -- bad connection here :(
10:56jeremyheilergoodieboy: i got, am looking at it now.
11:12goodieboyok wow, i think i actually got it! https://gist.github.com/1657499
11:17jeremyheilergoodieboy: nice!
11:19goodieboyjeremyheiler: that only took like, an hour + to do :) hopefully i learned something from that.
11:24jeremyheilergoodieboy: that's always good. you got me thinking about a few things, so it was helpful for me too.
11:28goodieboyjeremyheiler: great! Yeah I think using macroexpand was the key to see what was actually happening.
11:29pdkso
11:29jeremyheilergoodieboy: yeah definitely
11:29pdkfound this old macro
11:29pdkand looking at it i got no damn clue what it's for
11:29pdk;(defmacro dostatic [cls & ms] (cons `do (map #(list* `. cls %) ms)))
11:29pdkand i probably wrote that :\
11:32jeremyheilerpdk: looks like it creats forms like (. foo bar)
11:32pdklooking at it now in that case i dunno why i made it so roundabout
11:34jeremyheilerwell, a sequence of those forms, passing each item in ms into whatever strin cls was.
11:36NarviusHello, I have a question. I use leiningen (1.6.1) for my project, and I have a resource folder called assets (:resources-path "assets" in projec.clj), which in turn contains an images directory. After some searching around I concluded that the easiest way to obtain a list of files within that folder at runtime in an uberjar is to generate a "manifest" file containing a list of all files within that images directory. Is there a way to automat
11:37NarviusSo that it generates that manifest file before uberjar is ran.
11:57TimMcNarvius: You can add an arbitrary map of strings->strings to the manifest using leiningen's :manifest attribute.
11:59TimMcNarvius: FYI, loading the correct manifest at runtime is tricky. This is how I did it: https://github.com/timmc/lein-jit/blob/master/src/lein_jit/loader.clj#L8
12:00NarviusTimMc: Alright, I will look into it. Thanks.
12:05NarviusOkay. Now why does (resource "images") return nil when ran from the uberjar but the correct file URL when ran with lein run? The images folder is in the .jar, I checked.
12:05Narviusclojure.java.io/resource, of curse.
12:05Narviuscourse*
12:06TimMcNarvius: Resource loading is hard. I spent a day or two just making those two little files in that repo I linked.
12:08NarviusAnd there really is no simple way to load something I absolutely for 100% know is in the .jar?
12:09TimMcWell, look at the sample i sent.
12:09TimMcYou can load anything on the classpath, the trouble is knowing whether it's from *your* jar.
12:10TimMcI may be minsunderstanding your problem.
12:12NarviusHm... I'm starting to wonder whether I'd be better off to load the files from outside the .jar. >.>
12:17IceD^https://gist.github.com/1657735 - any comments are welcome
12:17IceD^want it to be idiomatic, but not sure if doing it right
12:26TimMcNarvius: Once you get the classpath stuff sorted out, it shouldn't be too bad.
12:30ericshullq
12:32jsnikeristechnomancy: Are *swank-source-path* and *swank-compile-path* intended to be dynamically rebindable?
12:41alex_baranoskycan one not use a fn defined in a let within a deftype declaration?
12:41alex_baranoskybecause of the macro expansion I suppose
12:42ChousukeI don't see why not :/
12:44alex_baranoskyChousuke, only saying it because I'm getting an error here when I try to put 'normalized-metaconstant' into a letfn -- https://github.com/marick/Midje/blob/master/src/midje/ideas/metaconstants.clj#L13
12:44alex_baranoskyjava.lang.Exception: Unable to resolve symbol: normalized-metaconstant in this context
12:47Chousukehmm :/
12:51alex_baranoskyChousuke, I guess I'll lose this battle today.
13:24kcinvresg'day
13:31dnolenyou know Clojure isn't such a bad language for writing mutable code :D
13:31dnolenthis is epic gross but https://github.com/clojure/test.benchmark/blob/master/src/main/clojure/alioth/nbody.clj, but hey we'll be right there with Java and Scala soon.
14:32trptcolin_is there something in core already to intern a var with all the necessary metadata attached? this little `intern-with-meta` function seems pretty generic (in my case, for bringing a macro in)... https://github.com/trptcolin/reply/commit/d58fb2eb1d4bfffc8cf8e2c3c216caca81969654
14:33trptcolin_and/or am i missing a simpler way?
14:42tufflaxLuyt no, i don't think so. Clojure functions can only return one thing.
14:42tufflaxops, i had scrolled up and didn't check the time stamp. I'm very late :p
14:56kcinvresI'm new to git (among other things) and I'm trying to figure out how to upload my stuff to github
14:58kcinvresI made a website based on noir-blog and now I'm trying to clean it up and put it on github... but I'm not sure if I should just upload the code... or fork the original noir-blog project and then push to that...
14:58Rayneskcinvres: I think either way is fine in this case. Forking it might be better for historical sake.
15:02kcinvresRaynes: Okay, well I've done a fork. but the code is somewhat different now. I renamed the project, renamed some directories... Every file has changed between 5% and 30%.
15:03Rayneskcinvres: That's fine. You can still push it to Github. You can also rename your project to something else (and keep it a fork) in the admin panel.
15:05kcinvresRaynes: Okay. If I push on top of the current fork, will the renamed folder replace the old one? or will then both be there?
15:05RaynesWhat you push will replace what is there entirely.
15:05kcinvresI obviously want the former.. okay
15:06RaynesIt will be a clone of what you have.
15:06RaynesIn a distributed version control system like git, everybody has a complete copy of the repository.
15:07kcinvresokay.. and people don't worry about it because they have all the previous commits
15:08RaynesRight.
15:08RaynesYou can always hop back to some other point in history.
15:08RaynesGit is like a time machine.
15:15raek...with a non-linear time axis!
15:15raek(namely a DAG-shaped)
15:30gfredericksAre there any clojurescript libraries for canvas stuff yet?
15:31brehautgfredericks: for some reason i think pinot provides some?
15:31brehaut(not that ive actually used it at all)
15:34gfrederickshuh; so it does
15:34brehautgfredericks: karma to mostly lazy then :)
15:35gfredericks$inc mostly-lazy
15:35lazybot⇒ 1
15:37gfrederickshuh...looks like it doesn't use the goog libs though. I figured that would be the simplest approach.
15:50brehauthuh, F#'s WebSharper (Web dev stuff with F# -> JavaScript compilation) is now free http://blogs.msdn.com/b/dsyme/archive/2012/01/22/websharper-javascript-html5-mobile-etc.aspx
15:51dnolengfredericks: goog canvas implementation is way broken.
15:56gfredericksdnolen: really? That's disappointing. I haven't yet used a library that abstracted over the various browser differences well. I haven't used much though.
16:02technomancyjsnikeris: I couldn't say; those were from before I started working with swank.
16:04jsnikeristechnomancy: gotcha. They don't jive w/ the convention that vars whose names start and end with '*' should be declared ^:dynamic
16:05technomancyjsnikeris: yeah, swank code is paleolithic. there are places where it uses refs instead of atoms just because atoms hadn't been implemented yet
16:05dnolengfredericks: the canvas implementation is ok for simple drawing - for more complex procedural drawing / animation I would not use it.
16:06kcinvresOkay, so I'm about to push. But my local repository has its own history and the one on github has a few of its own commits. When I push, which will be the canonical history?
16:06the-kennyI tried using the canvas stuff from goog once. Horrible, horrible experience.
16:08gfredericksWell I didn't expect it would be pleasant to use directly, but at least reliable and functional; i.e., would be good once wrapped in cljs.
16:09gfredericksI guess the google docs drawing code must use something else?
16:16ordnungswidrigkcinvres: you can only push if your local branch appends to the current head of the remote branch
16:17koeienebian
16:18koeienwhoops
16:18kcinvresordnungswidrig: How would I know if that is the case?
16:19ordnungswidrigkcinvres: git log −1 shows the head of the branch you're on
16:21kcinvresgit log -1 commit cdb2ec347436ab9fd2f5640af34c67e348f58f4e Author: John Newman <johnmn3@gmail.com> Date: Sun Jan 22 16:07:47 2012 -0500 moving to github
16:22kcinvresdoesn't say master
16:22kcinvresthough doing a "git branch" says master
16:25gfrederickskcinvres: my favorite is git log --graph --all --format=\"%h[%t] %d %an--%s\"
16:26kcinvres! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'git@github.com:johnmn3/qftk-site.git' To prevent you from losing history, non-fast-forward ...
16:26kcinvresso that's what you're talking about
16:30kcinvresgoogle is telling me to do a pull and then another push
16:30kcinvreswon't that wipe out my current changes?
16:31jeremyheilerkcinvres: no, it will merge what it can. then ask you to merge anything that conflicts with you changes.
16:31gfrederickskcinvres: not to mention the commit you're currently on will be part of the history, so you can always go back and see what happened when you merged
16:31kcinvresmost recent file wins?
16:32gfrederickse.g., after the merge you could diff your current commit with the new commit and see exactly what the merge changed
16:33jeremyheilerkcinvres: git will automatically merge any line of code that it knows you didn't change. then it asks you to manually merge anything that you did change.
16:35kcinvresjust did a pull and I'm seeing git comments in the code!?
16:35jeremyheilerkcinvres: that's the code you need to manually merge yourself.
16:40kcinvresthats a lot of code to edit
16:43kcinvresok, so I think I get it : <<< HEAD local stuff ===== remote stuff >>>> 345345345
16:43kcinvresSo I can just go through and delete all but the local stuff
16:44jeremyheilerkcinvres: assuming that you don't want any of the new stuff.
16:45kcinvresI don't
16:46ordnungswidrigkcinvres: http://learn.github.com/p/intro.html
16:48ordnungswidrigkcinvres: in this case git pull -Xours will force your local changes. But use with care
16:48kcinvresordnungswidrig: Okay. Thanks!
16:49clj_newbso I'm writing a WYSIWYG editor in clojure; and I'm getting to the point that lag is a bit intolerant for an interative application. What should I read up on for profiling? (I know nothing abot profiling Clojure or Java code; I only know how to use gprof for C++ code.)
16:49kcinvresjust did it by hand this time. running again to see if it still works
16:50ordnungswidrigclj_newb: yourkit.com is a very good profiler.
16:50kcinvresno, I broke something
16:50kcinvreshow do I roll back one?
16:50clj_newbordnungswidrig: there's nothign like clojure_prof ?
16:51dnolenclj_newb: VisualVM works, YourKit is nicer. Look at test.benchmark for ideas on speeding up the slow spots.
16:51ordnungswidrigkcinvres: git checkout
16:51clj_newblet me rephrase my question: is the optimal clojure profiler just to use the best java profiler?
16:51ordnungswidrighttp://richhickey.github.com/clojure-contrib/profile-api.html
16:51lazybotNooooo, that's so out of date! Please see instead http://clojure.github.com/clojure-contrib/profile-api.html and try to stop linking to rich's repo.
16:51ordnungswidriggrr
16:52jeremyheilerowned by lazybot lol
16:52clj_newblol; lazybot is almost cute
16:52dnolenclj_newb: the JVM profilers are quite nice IME.
16:53kcinvreserror: you need to resolve your current index first
16:53ordnungswidrigclj_newb: it depends. standard java hprof might be sufficient for profiling
16:53ordnungswidrigclj_newb: s/java/jvm/
16:59ordnungswidrigkcinvres: http://stackoverflow.com/questions/101752/aborting-a-merge-in-git
17:00kcinvresk, I fixed the code. Now when I do a "git add ." it says "fatal: unable to stat 'folder/file' : No such file or directory
17:01kcinvresBecause I deleted the directory that got pulled from github
17:02kcinvresordnungswidrig: I think that works, thanks!
17:03ordnungswidrigwhere did io/delete-file-recursively go in 1.3?
17:03ordnungswidrigi mean contrib.io/...
17:04alex_baranoskyordnungswidrig, perhaps fs may contain what you need? https://github.com/Raynes/fs/blob/master/src/fs/core.clj
17:08clj_newbordnungswidrig: purely out of courisity; what does your nick stand for? phonetically it sounds like some word in a langauge I do not understand
17:08ordnungswidrigalex_baranosky: oh thanks.
17:09the-kennyclj_newb: It's German :)
17:09ordnungswidrigclj_newb: it means "contraty to regulations" in german.
17:09ordnungswidrigclj_newb: law / administration term
17:09ordnungswidrigclj_newb: an "ordnungswidrigkeit" is a "minor breach against the law"
17:10tavis`is there a way to force a non-dynamic var to be dynamic in 1.3 - specifically #'clojure.core/read-line?
17:10clj_newbordnungswidrig: ah; german does make sense, it sounds angry
17:11the-kenny:D
17:11hiredmantavis`: it's a compile setting, so if you alter-meta! and set :dynamic to true before the code that calls read-line is compiled it will be compiled as a dynamic var
17:13tavis`so alter-meta! before pulling in the ns that needs to do that
17:13tavis`thanks
17:13hiredmanwell, it will only be accessed dynamically by code that is compiled after you change the metadata
17:13tavis`right
17:14kcinvresuuugh.. still non-fast-forward errors :(
17:14hiredmanok
17:15tavis`hiredman: an if I have a macro that does a binding of read-line it's the ns that uses the macro rather than the ns that defines the macro that I need to worry about, right?
17:16hiredmanI don't follow
17:17hiredmanif namespace A calls read-line, if you change the metdata on #'read-line before A gets compiled you will be able to effect the function that gets called using binding, if not, you won't
17:17tavis`I've got a macro swank.core/with-readline-support: (w-r-s [& body])
17:18tavis`it's the ns that uses that macro that I have to compile after alter-meta! rather than swank.core, I assume
17:18hiredmanit is the namespace you want the dynamic binding to effect
17:19tavis`ok, thanks.
17:26kcinvresOMG, I'm so confused
17:26kcinvresno git won't commit
17:28kcinvres*now
17:28tavis`hiredman: no luck
17:32kcinvresI do a git reset --hard, then delete the files I don't want, then git add ., then git commit -m "update"
17:32clj_newbin Java, am I allowed to assume that \a \b ... \z forms an consecutive increasing sequence; and \A ... \Z forms another consecutive increasing sequence?
17:32kcinvresand then it says "no changes to commit
17:32clj_newbi.e. I want to see if a char is one of \a ... \z or \A .. \Z
17:33jeremyheilerclj_newb: yes
17:33kcinvresugh
17:33kcinvres Your branch is ahead of 'origin/master' by 1 commit.
17:33clj_newbjeremyheiler: what standard that Java conform to that allows me to make this assumption?
17:34jeremyheiler,(< (int \a) (int \b))
17:34clojurebottrue
17:34jeremyheiler,(< (int \e) (int \d))
17:34clojurebotfalse
17:34jeremyheilerconvert the char to an int
17:35jeremyheilerclj_newb: in java, you can do comparasons on char primitives like: if('a' < 'b')
17:35jeremyheilerbut converting to ints work as well.
17:36dnolen,(compare \a \b)
17:36clojurebot-1
17:36clj_newb,(< \a \b)
17:36clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Character cannot be cast to java.lang.Number>
17:36clj_newbahh, compare
17:40clj_newbFound my bug: file had unicode characters; font only supposed ascii characters; weird out of bound cases now resolved. :-)
17:43kcinvresugh, finally
17:43kcinvreshttps://github.com/johnmn3/qftk-site
17:43kcinvreslooks like .gitignore got ignored though, cause I had to do a git push github master --force
17:49clj_newbclojure.org/libraries has a link to a "parsec like" library for cojure. The link is broken.
17:50clj_newblazybot: please fix it
17:56romain_pHi everyone, I have a question about the thread macro (->): given that "gather-words" returns a list of words, what is wrong with this: (-> "http://www.fang.ece.ufl.edu/reject.html&quot; slurp gather-words frequencies #(sort-by second %))
17:57romain_p(the error I get is java.lang.ClassCastException: clojure.lang.Symbol cannot be cast to clojure.lang.IPersistentVector (NO_SOURCE_FILE:17))
17:58dnolenromain_p: -> is pure syntax transformation, it will screw up on the fn literal.
17:58clojurebot'Sea, mhuise.
17:58romain_pand the original, working code was (sort-by second (frequencies (gather-words (slurp "http://www.fang.ece.ufl.edu/reject.html&quot;))))
17:58dnolen(macroexpand '(-> a #())))
17:58dnolen,(macroexpand '(-> a #())))
17:58romain_pdnolen: I am a beginner, and this is chinese for me, could you explain ?
17:58clojurebot(fn* a [] ())
17:58dnolenromain_p: ^ notice that looks weird
17:58romain_pyup :)
17:59dnolen#(sort-by second %) is just not going to work inside ->
17:59romain_pOK, so should I declare it outside or is there an idiom I could use?
17:59trptcolin_if you wrap another set of parens it might :) kind of yucky though...
18:00trptcolin_(-> "http://www.fang.ece.ufl.edu/reject.html&quot; slurp gather-words frequencies (#(sort-by second %)))
18:00trptcolin_threading is all fun and games until you want to switch from -> to ->>
18:00romain_ptrptcolin_: it does work, but I agree with the yuckiness part too :)
18:07brehauttrptcolin_: its easy to switch from -> to ->>; its the other way thats dumb
18:08trptcolin_i guess i haven't ever had multiple ->>'s chained together, come to think of it...
18:09brehaut,(-> 1 (+ 1) (->> (* 3)))
18:09clojurebot6
18:11brehaut(numbers are a terrible example of that)
18:15trptcolin_:) well, + and * anyway, since argument order doesn't matter. for some reason i didn't think of nesting - that's a good idea.
18:15TimMcbrehaut: I think there might be a few implementations of -%> floating around, e.g. (-%> 5 (+ 5 %) (nth % (range)))...
18:16brehautTimMc: huh thats cool
18:16trptcolin_:) that's kind of sweet
18:16TimMcSome people add ,,, where the arg would go anyway; might as well make it real.
18:16dgrnbrghas anyone ever used fleet? Can you explain what it means when I use the fleet-ns macro that "foo.bar.fleet" produces 3 functions: foo, foo-bar, and foo-bar-fleet? What is the purpose of each function?
18:21TimMcdgrnbrg: What is fleet?
18:23brehautTimMc: its a templating engine i believe
18:23SomelauwI prefer letting over ->
18:24brehautTimMc: sort of a rails templating thing for clojure?
18:24TimMcdgrnbrg: You may wish to macroexpand the call to see what it produces, if the docstring is mysterious.
18:27dgrnbrgTimMc, it is indeed a templating engine
18:27dgrnbrgI have read the docs, and the source, but I'm having trouble following along with the call chain
18:27dgrnbrgand seeing where exactly they actually def the new functions
18:28dgrnbrgthe fleet-ns macro takes a directory as an input, inteprets the files as templates, and then defines the templates in a new namespace
18:29brehautdgrnbrg: im curious; why did you choose fleet over enlive or hiccup?
18:29dgrnbrgI want to template verilog code
18:30dgrnbrgFleet seemed to be pretty removed from html-ville
18:30brehautright
18:30dgrnbrgI also want to template vhdl
18:30dgrnbrgthey all have really different syntaxes
18:30dgrnbrgI want something like gsp/jsp or StringTemplate in groovy
18:31dgrnbrgthe fact that fleet lets me write templates as resource files is just gravy, and i apparently may be reimplementing that part myself
18:32brehautcl-format to the rescue ;)
18:33dgrnbrgwat's that?
18:33brehautmagic
18:33brehautclojure.pprint/cl-format
18:33brehautits common lisps format ported to clojure
18:33brehautwith all the crazy that entails
18:34brehaut(it wasnt a serious suggestion)
18:34dgrnbrgwhat makes it crazy?
18:35brehautits quite an involved, yet terse, formatting language
18:35dgrnbrgif all i need is string interpolation
18:36brehautthen plain old format is probably a better choice
18:36dgrnbrgI just want more convenience when templating
18:36dgrnbrgi may need loops or other, more complicated constructs
18:38dnolendgrnbrg: if you like StringTemplate you can use that from Clojure no?
18:41dgrnbrgdnolen, I could, but it seems cleaner to use the clojure lib
18:41dgrnbrgespecially for parameterizing templates with maps whose strings are clojure keywords
18:47trptcolin_didn't the stock clojure repl used to dump stacktraces? i can only seem to get it to print a 1-line exception summary. (i know i can (pst) to get it to print if i really want to)
18:53dnolentrptcolin_: pretty sure it never did.
18:53TimMcamalloy_: Do you happen to know of an implementation of -%>, that threading macro that allows you to explicitly select where the threaded arg goes?
18:55trptcolin_dnolen: yeah, that's what i'm seeing. even going back to 1.1.0 jar... trying to remember why i think stacktraces are so annoying to read when they don't come up by default in-repl.
18:58clj_newbare map/reduce, loop/recur the main constructors for replacing for loops; is there anything else I should be aware of?
18:59dgrnbrgclj_newb, the for macro is really useful
19:00clj_newbdgrnbrg: it does look interesting
19:05dgrnbrgclj_newb, it is a little DSL that's like python's syntax
19:06dgrnbrgso (for [a [1 2 3] b [:a :b :c]] [a b]) gives [1 :a] [1 :b] [1 :c] [2 :a] ...
19:06brehautclj_newb: lazy seqs and loop/recur are the primary _low level_ building blocks of loop replacement.
19:07dgrnbrgclj_newb, you give it some seqs, the names of the given element of that seq, and some filters, and then you get to write the expression that yields the value for the result seq
19:08brehautclj_newb: you infrequently operate with either directly. map, reduce, filter, keep, take etc (ie, the seq functions) are the primary 'loop replacement'
19:09brehautclj_newb: http://clojuredocs.org/quickref/Clojure%20Core have a look at Collection / Sequences > Sequences
19:26trptcolin_so i have this workaround for http://dev.clojure.org/jira/browse/CLJ-909 (configuring LineNumberingPushbackReader's buffer size), but there are places in the clojure reader (LispReader) that depend on "instanceof LineNumberingPushbackReader".
19:27trptcolin_... and the instanceof checks break line-numbering for stack traces. anyone have ideas for further hackery short of getting that patch in?
19:30trptcolin_i should've said, those instanceof checks break line-numbering for traces *when you replace LineNumberingPushbackReader with something else*
19:38wjlroeCan the order of the keys in a PersistentHashMap be relied upon?
19:39brehautno
19:39brehautalthough joy of clojure claims that array-map does have that property though you have to be careful that the array map stays an array map
19:43brehautgiven PersistentArrayMap.cons will return a PersistentHashMap when it reaches a certain size, i dont believe its easy to keep with an array-map
19:45wjlroeI have been getting weird behaviour where the order of the keys in a map is as I wanted (comes from a sql query), but when it gets to a certain number of keys - the order changes, to a different, consistent ordering)
19:45brehautwjlroe: thats the difference between array-map and hash-map
19:46brehautthey both implement the IPersistentMap interface, and the back type for clojures maps
19:46brehautarray maps are used for small maps, and hash maps when they grow too large
19:46brehautwjlroe: for a given set of keys and insertion order hash map is consistent but its not goign to maintain insertion order
19:47wjlroewhat I found is when these maps have over 10 keys - the order is strange
19:47brehauti think the order should be 16
19:47brehauthttps://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/PersistentArrayMap.java#L32
19:48brehautwjlroe: like i said, hash map _does not maintain insertion order_
19:48wjlroewell it's defo smaller than that
19:48wjlroeyeah
19:48wjlroenot very useful when that's what you get from a sql query (Korma) - a vector of hash maps
19:50brehaut,(for [n (range 20)] [n (class (reduce conj (array-map) (map (juxt identity identity) (range n))))])
19:50clojurebot([0 clojure.lang.PersistentArrayMap] [1 clojure.lang.PersistentArrayMap] [2 clojure.lang.PersistentArrayMap] [3 clojure.lang.PersistentArrayMap] [4 clojure.lang.PersistentArrayMap] ...)
19:50brehautrats
19:50brehaut(for [n (range 14 18)] [n (class (reduce conj (array-map) (map (juxt identity identity) (range n))))])
19:50jeremyheilerwjlroe: do your hash maps represent rows in the database? if so, why does order matter?
19:50brehaut,(for [n (range 14 18)] [n (class (reduce conj (array-map) (map (juxt identity identity) (range n))))])
19:50clojurebot([14 clojure.lang.PersistentHashMap] [15 clojure.lang.PersistentHashMap] [16 clojure.lang.PersistentHashMap] [17 clojure.lang.PersistentHashMap])
19:51wjlroejeremyheiler: yup - order matters because the keys in the map relate to the columns in the select query - those fields are ordered in the query and should be in that order in the data that results
19:53brehautwjlroe: why a map and not an ordered collection?
19:53brehaut(eg a vector)
19:53jeremyheilerwjlore: it's easy enough to get around that by maintingin a vector or list of your keys, and iterate over them when you need to pull the values out of the map.
19:53wjlroejeremyheiler: define the same info twice. not very dry
19:54wjlroebrehaut: so yeah that would work - vectors of vectors, which I would have to transform from the results of a query and reorder the keys on the way
19:56jeremyheilerwjlore: don't you have to define the keys (selected columns) in order for a select query to work anyway?
19:57jeremyheilerwhy not just use same vector/list of keys?
19:57wjlroethe problem is, because the SQL library - Korma - returns PersistentHashMaps - I'm gong to have to mess around with that to make it useful, I shouldn't have to do that - it should come out in a sane format that doesn't require re-ordering
19:58wjlroejeremyheiler: the list of columns relates to the tables/subqueries - the list of keys relates to the data returned, they aren't quite the same so would have to define this twice
19:58brehauthuh? i was sure korma returned a vector (or some seq) of maps
19:58wjlroeso the select has a field - :table.column - and then I'd need to fix the returned map by ordering the columsn again [:column :another]
19:59wjlroeit does - exactly
19:59wjlroemaps are the problem
19:59wjlroeit returns a vector of maps - which turn out to be PersistentHashMaps - which doesn't preserve the order of the fields requested in the query
20:00wjlroewhich is borken
20:01brehautfields arent inheriently ordered
20:02wjlroeI don't know what you mean by that - they are in every other language and library I've used sql with.
20:02brehaut,(map {:a 1 :b 2 :c 3 :d 4} [:b :c :d]) ; anyway, trivial to select an ordered subset of the row
20:02clojurebot(2 3 4)
20:03wjlroeif I just wanted the values - yes
20:04brehautwell then, select-keys is also not hard to use
20:05wjlroedoesn't work
20:06wjlroereturns the out-of-order map
20:06wjlroevery bizare
20:06brehautmaps have no order
20:06wjlroeunless they are array maps
20:06brehautwhich you cant rely on
20:07brehautthe interface is what you should be programming to
20:07brehautand the interface has no garuntees on order
20:07wjlroeback to python then
20:07brehautanyway, it sounds like you are doing something pretty bizarre
20:09wjlroethis just means I'm going to have to write a separate function per table/query instead of using the one and being able to rely on a sane data structure
20:10wjlroeI realise hash maps aren't ordered, but it would be nice if there was something reliable which was a map with ordered keys that was sane
20:10brehautlets assume thats true. Why‽
20:11wjlroewhy what?
20:11amroit's a nice plus, but I wouldn't call unordered maps insane
20:11wjlroeunordered maps aren't insane. not having ordered maps is not very useful
20:11brehautwhy do you want the keys and values of the records in a query result to be ordered
20:11brehautlet me rephrase my question
20:12brehautwhat is the problem you are trying to solve
20:13brehauti agree that ordered maps are useful, but i cant see why they would be in the particular case of SQL query results
20:13amroI'll second that
20:13wjlroeI have defined a query - get me these fields from this database - then I wanna display that. Fine. Problem is what I asked for from the database is mangled by the data structure. So I have to monkey with the data to re-order things to match the query I wrote. Perhaps this is a part of SQL that just doesn't match concepts in Clojure - but most times when you write a query in a DSL - the fields come
20:13wjlroe back ordered as you would want
20:14wjlroereally all I need is to tell Korma to return results in a different way
20:15brehaut,((fn repr-record [{:keys [a b]}] (prn-str "a record:" a b)) {:c "abc" :b 23 :a "hello, world"})
20:15clojurebot"\"a record:\" \"hello, world\" 23\n"
20:16brehautor you could (and i dont think this is a particular controversial idea) refer to named values by name
20:17wjlroesure
20:17wjlroeI have a function that prints results - regardless of what fields etc are there - I will have to complicate that rather to take this into account
20:28wjlroeDoes anyone know, when you've run clojure-jack-in from Emacs - how, in your code, you can print to the repl?
20:29wjlroealthough it was better to call (swank.core/break) to find out what was going on
20:29wjlroeso never mind
20:33benares_98,(doc dosync)
20:33clojurebot"([& exprs]); Runs the exprs (in an implicit do) in a transaction that encompasses exprs and any nested calls. Starts a transaction if none is already running on this thread. Any uncaught exception will abort the transaction and flow out of dosync. The exprs may be run more than once, but any effects on Refs will be atomic."
20:33benares_98can anyone tell me what the & means?
20:35gfredericksit means that the function/macro takes varargs
20:35jimdueyIt means that the dosync form takes a variable number of expressions. The value 'exprs' is a list of those expressions.
20:35benares_98thansk
20:35benares_98*thanks
20:35gfredericksit parallels the syntax for actually implementing a vararg function
20:35gfredericksand destructuring more generally
20:40_carlos_hi!
20:48dnolenwjlroe: clojure has sorted-maps, sounds like sqlkorma is missing a feature you like.
20:48wjlroednolen: if that's the case, then yeah
20:50_carlos_in clojure in action book: in concurrency chapter, page 157, just above commute explanation, I cite: "it doesn’t matter in what order you add users. If two threads were both trying to add a user to our system, you wouldn’t care in what order they’re added. Such an operation is said to be commutative". I don't understand why it is commutative, because at the time commute would be called for that example, (inc current-number)
20:50_carlos_outdated version of the id
20:50_carlos_sorry for the long paste
20:51brehautdnolen: sorted-map isnt an ordered-map though
20:51_carlos_btw, the page number printed in the pdf itself is 133
20:52dnolenbrehaut: by that do you mean preserving insertion order?
20:52brehautdnolen: yes exactly
20:54wjlroeI've solved my problem now, just would have been nice if Korma could just output data in vectors maybe so the order can be assumed. I'll ask about it
20:54wjlroe(vectors of vectors - or first elem is field names)
20:54dnolenbrehaut: ah ok. though I think in wjlroe's case he doesn't really care how it's done, as long as he can iterate over the fields in the same order he specified in the query ;)
20:54wjlroeYES
20:54wjlroe:)
20:54brehautdnolen: yeah, i understand that requirement. i just think its wrong ;)
20:55wjlroeI'll just have to stick a sticky note to my screen that says "Don't assume the order of anything. Write more code to be sure"
20:57jimdueywjlroe: you might use juxt to accomplish what you want easily.
20:58brehautjimduey: huh. thats a cunning alternative to map
20:58jimduey((juxt :a :d :c) {:a 3 :b 5 :c 8 :d 1})
20:59wjlroeThat is clever
20:59brehautjimduey, (map {:a 3 :b 5 :c 8 :d 1} [:a :d :c])
21:00cemerickis https://github.com/Chouser/clojure-jna/ the state-of-the-art of Clojure->native goodness?
21:00jimdueyyep. I get to use juxt so rarely that I like to use it when I can to keep in practice
21:00brehautlol :)
21:01dnolenbrehaut: but juxt is so much cooler man.
21:01brehautdnolen: no argument there :)
21:01wjlroe(if (resolve 'swank.core.connection/*current-connection*)) <- for some reason that is true, even when swank.core.connection is not defined - i.e. in production - what mistake did I make?
21:02clj_newbis there a way to generate the charsacters from \a to \z
21:02clj_newbsomething like say \a .. \z, except in clojure
21:02dnolen,(int \a)
21:03clojurebot97
21:03dnolen,(int \z))
21:03clojurebot122
21:03dnolen,(map char (range (int \a) (int \z)))
21:03clojurebot(\a \b \c \d \e ...)
21:03clj_newbdnolen: thanks
21:04brehauti think raynes has a generic range lib somewhere too
21:04dnolen,(map (juxt identity char) (range (int \a) (int \z)))
21:04clojurebot([97 \a] [98 \b] [99 \c] [100 \d] [101 \e] ...)
21:04clj_newb,(println (int \1) (int \9) (int \0))
21:04wjlroeI was going to ask - can you define multimethods for different sorts of ranges - so one acts on characters
21:04clojurebot49 57 48
21:05Rayneshttps://github.com/Raynes/morphin
21:05wjlroenice
21:06chewbrancarange is exlusive though, you'll have to do something like (inc (int \z)) if you want z as well. Is there a better way to do that?
21:06clj_newbwithout the use of flatten, is there a way to change ( [k1 v1] [k2 v2] ... [k_n v_n]) into { k1 v1, k2 v2, ... , k_n v_n } ?
21:06Raynes&(into {} '([:a 1] [:b 2]))
21:06lazybot⇒ {:a 1, :b 2}
21:06wjlroe(into {} [[k v]])
21:06wjlroetoo slow :(
21:07clj_newbwjlroe , Raynes : thanks
21:08wjlroeI used to be so confused by the Ruby way to do that.
21:12clj_newbclojure is so awesome it enlightens its users about other langauges
21:14wjlroewell - except Java - there is no enlightenment there
21:15clj_newbI used to believe Java was utter crap. Now, I know that Java is a great VM + set of libraries, and all it has ever lacked was a decent programming language.
21:15dnolenwjlroe: heh not true, Java Concurrency In Practice is a pretty sweet book.
21:16wjlroednolen: oh well there is that
21:44jeremyheileryeah, the stuff doug lea (et al) has done with the concurrent lib is pretty awesome
22:00brehautive managed to forget (again) where the clj-http repo is hosted
22:01jeremyheilerhere? https://github.com/medSage/clj-http
22:01scottjbrehaut: g site:github.com clj-http
22:02brehautlooks like the right lib. not the repo i previously used
22:02johnmn3.
22:02duck1123https://github.com/dakrone/clj-http
22:02scottjhttps://github.com/dakrone/clj-http
22:02jeremyheilerbrehaut: yea, it's got almost 5x as many forks as watchers
22:02jeremyheilerlol
22:02brehautduck1123, scottj: thanks!
22:02johnmn3g'day
22:18johnmn3looking for a fun clojure project to hack on... any ideas?
22:20RaynesAnything by that Raynes fellow. I hear he's pretty awesome.
22:22dnolenjohnmn3: the core projects here - https://github.com/clojure
22:24johnmn3mmm. I'm a novice... Any low hanging fruit?
22:24brehautjohnmn3: a number of the contrib core projects probably have them yeah
22:27brehautjohnmn3: you could contribute questions to 4clojure
22:27johnmn3this is the canonical contrib list: http://dev.clojure.org/display/doc/Clojure+Contrib ?
22:27johnmn34clojure.. I should try using that too
22:28dnolenjohnmn3: what type of thing would you like to work on?
22:28johnmn3I just did the QFTK/noir heroku thing... had a blog article on it recently
22:29johnmn3based on the noir-blog example
22:29johnmn3Though I've dabbled more in desktop apps in the past
22:32dnolenjohnmn3: too many interesting web related stuff going on these days, noir, korma, ring, compojure, aleph, clojurescript
22:32dnolenjohnmn3: the desktop stuff that I'm aware of is mostly around tooling
22:33brehautdnolen: a core.match based webforms library could be a great little project
22:34dnolenbrehaut: that would be neat! there's a fairly gnarly fundamental issue I'm contemplating - so I'm not encourage people yet.
22:34brehautdnolen: oh yeah?
22:34dnolenwhen core.match hits beta I'll push it more
22:34brehautthat'd be great!
22:35dnolenbrehaut: pattern matching w/o type constriants is pretty tricky.
22:35brehautcore.match works in clojurescript too right?
22:35dnolenbrehaut: yes
22:35brehautah true
22:35dnolenstaticly typed FP languages have it easy, they constrain the types in "column"
22:35dnolencore.match imposes no such restrictions
22:35brehautso it should be possible (once aforementioned gnarl is sorted) to have a great form processing library that works on client and server trivially
22:36dnolenbrehaut: yep
22:36brehautwhat do you mean by 'column' ?
22:36dnolenbrehaut: in FP langs patterns form a pattern matrix
22:37johnmn3are we talking about form validation?
22:37brehautjohnmn3: yes
22:37johnmn3mm
22:37johnmn3big push for non-turing protocols recently
22:38johnmn3I'd imagine match/logic can go a ways in constraining that..?
22:38dnolenbrehaut: somef 1, somef "foo", not allowed in static typed langs as a valid pattern
22:39brehautdnolen: are right. i understand you now. youd have to have something like data Foo = SomeI Int | SomeS String, and pattern matching is trivial then
22:39dnolenbrehaut: precisely, you need to define the sum type ahead of time
22:39brehautdnolen: whereas you need to infer it based on the provide rules ?
22:41dnolenbrehaut: the problem actually arises out of how aggressively we try to optimization pattern matching
22:41brehauti guess you also can never tell if you have a partial pattern too
22:41dnolenbrehaut: we prefer that we never a run a test again.
22:42brehauthuh thats going to be complicated
22:43dnolenbrehaut: sort of ... the designer of the pattern extension has to specify if their pattern can be compared w other patterns.
22:43brehautinteresting
22:43dnolenif it can't core.match creates a backtrack point
22:43dnolenbut we'd rather not do that, cuz then we're not better than case by case
22:43johnmn3hmm, never saw this pass my reader: https://github.com/daveray/upshot
22:43johnmn3"A Seesaw style Clojure API for JavaFX"
22:44dnolenbrehaut: it is pretty interesting. I'm considering disallowing arbitrary guards for example.
22:45dnolenbrehaut: arbitrary fn expressions for guards I mean. since fn comparison is undecideable.
22:45brehautthat makes sense
22:46brehautthats an interesting tradeoff there
22:46dnolenbrehaut: it's a classic tension between, easy to use / optimizeable
22:46brehautyou'd have to create a backtracking point for every fn guard right?
22:46dnolenbrehaut: yep
22:47dnolenso I'm taking my time, I don't want to go beta without these things sorted out
22:47brehautyeah fair enough
22:47dnolenand anything we decide needs to flow smoothly into predicate dispatch
22:48brehautpredicate dispatch if theres no backtracking becomes an extremely quick alternative to multimethods right?
22:49dnolenbrehaut: yes
22:52brehautdnolan: thanks for explaining this stuff.
23:10clj_newbI'm not sure how to expression this in words, but I will my best. Whoever decided to add Keywords to Clojure is a frickin genius. I find myself using them all over the place.
23:11clj_newbI wonder how one manages to invent stuff that previously never existed? (For example, if all humans had only one eye, how would one realize "hmm, having depth info would be imporatnt")
23:11jeremyheilerclj_newb: ruby has symbols, which is equivalent to clojure keywords.
23:12clj_newbah; great artists steal
23:13jeremyheilerclj_newb: but yes, i've wished for a similar concept in java proper.
23:13johnmn3ibdknox: thanks for noir-blog! I used it here: http://qftk.herokuapp.com/view/the-book
23:13clj_newbjeremyheiler: what is this Java you speak of?
23:13jeremyheiler*shurgs*
23:13jeremyheiler*shrugs**
23:13ibdknoxjohnmn3: you're welcome :)
23:13clj_newbI've found that due to proxy and defrecord, I have not writen a _single_ line of Java code
23:14clj_newbwhenever the interop between Java/Clojure needs to change; I just kill more of the existing Java libraries and write more clojure code
23:14clj_newbClojure is like a virus eating through the Java sources.
23:14jeremyheilerhaha
23:15jeremyheilerim currently thinking about how to kill javamail
23:15jeremyheiler(at least the smtp part of it)
23:15TimMcclj_newb: In many Scheme languages, symbols do the same task as Clojure's symbols + keywords.
23:15Xorlevnoir + GSP would be wonderful.
23:15TimMcIt's nice to have the uses separated.
23:16ibdknoxGSP?
23:17ibdknoxXorlev: what's GSP? :)
23:17ibdknoxI assume not an international airport
23:19ibdknoxNoir + the German Space Program
23:19XorlevLike JSP, but with Groovy instead :)
23:19ibdknoxah
23:19XorlevI love Clojure and Noir, but composing pages with functions bothers me (exception: HAML)
23:20ibdknoxXorlev: there are alternatives to hiccup
23:20ibdknoxmustache, enlive, stringtemplate
23:20metajackautodoc and marginalia do a good job for API reference type docs, but what are people using for overview and tutorial type docs?
23:21XorlevOoh
23:21ibdknoxmetajack: github wiki's are the only standard I've seen. For a branded site you'd end up writing your own stuff though
23:21ibdknoxmetajack: I used markdown for noir's docs and a little DSL I wrote for Korma's
23:22metajackibdknox: I was specifically thinking about Noirs docs actually :)
23:22ibdknoxXorlev: so you don't just have to stick with that if you prefer something else :) There are definitely cases where that's necessary
23:22ibdknoxmetajack: the source is on my github :)
23:22metajackin the noir repo?
23:22XorlevMaybe I'll write a few more Noir webservices then
23:22ibdknoxmetajack: https://github.com/ibdknox/webnoir
23:23ibdknoxmetajack: and korma's docs are here: https://github.com/ibdknox/sqlkorma
23:23ibdknoxXorlev: All the cool kids are ;)
23:23metajackAh, i was looking for the special github web branch in the noir repo.
23:23ibdknoxKorma's docs are way cooler than Noir's
23:23ibdknoxhttps://github.com/ibdknox/sqlkorma/blob/master/src/sqlkorma/views/docs.clj
23:24Xorlevibdknox: We have one internally, but we're somewhat hesitant to start writing production webservices in Clojure given about half of our team knows FP and half doesn't.
23:25ibdknoxXorlev: yeah not an uncommon problem
23:25ibdknoxmy goal is to keep making stuff until it's a detriment not to switch ;)
23:25johnmn3I think I hung tryclj
23:25ibdknoxjohnmn3: loads for me
23:26johnmn3ah, we're back
23:26johnmn3the evaluation was hanging
23:26Xorlevibdknox: I like that approach. Someone else in my office tries to push it too but I think he's also realized that writing more stuff in Clojure will eventually just force us to move there.
23:27XorlevIn general, our goal is to improve cross compilation and polyglot systems so that using the right JVM language for the right task is a no-brainer.
23:27ibdknoxhaha I meant making stuff for others, but yes, it's a good guerrilla tactic
23:27johnmn3send it a bad (iterate ... form and it seems to hang up for a while
23:27ibdknoxjohnmn3: it waits for a timeout
23:27ibdknoxcan't remember what he set it to
23:28ibdknoxI have some exciting CLJS stuff that I should be showing soon
23:28metajackibdknox: I like that you separated the code from the docs. Very nice. Perhaps I will try and use orgmode to do something similar.
23:29ibdknoxmetajack: it was very useful doing it that way
23:29ibdknoxmade it much easier
23:31johnmn3ibdknox: care to indulge?
23:32ibdknoxjohnmn3: I've been working on some projects that have complex interactions between visual elements and have many states
23:33ibdknoxjohnmn3: I've been working on a solution for that and I think I might've gotten there last night :)
23:33johnmn3hmm. using goog libs?
23:33ibdknoxinterestingly it's pretty much framework agnostic
23:34ibdknoxit will work with whatever
23:34ibdknoxthough I also got fed up with the goog libs
23:34ibdknoxand have a nice jQuery lib I'll release soonish too
23:35johnmn3nice
23:35ibdknoxit's much easier to work with
23:35ibdknoxand provides a nicer base
23:35ibdknoxthough I'm sure someone will disagree with me :)
23:38johnmn3will it work with pinot?
23:38ibdknoxjohnmn3: it will be the new pinot :) What's there now was just random throwing together of things that I wanted to explore or needed. This will be much more thought out and present a more full solution
23:39johnmn3nice
23:40johnmn3I wanted to try converting the navigation bar on my qftk site to cljs
23:40johnmn3that's probably trivial though
23:41ibdknoxI will say that as I've pieced things together, I've started to like CLJS a lot more
23:42ibdknoxit's definitely not for everything though
23:43johnmn3I still think it'd be rad to be able to do compilation in the browser
23:43johnmn3lifting the whole language into the browser
23:43johnmn3just for dev purposes
23:44johnmn3Then I could develop on the website with just my browser. Though I know I could just point a webified repl to a clojure process on the server
23:45ibdknoxdoing the latter isn't difficult :)
23:45johnmn3still, with an in-browser compiler, we could do things like inspect/manipulate live javascript on random pages, right?
23:46johnmn3And perhaps do interesting distributed computing things
23:48ibdknoxyou don't need it for the latter :) Check this out: http://nakkaya.com/2009/10/04/fractals-in-clojure-buddhabrot-fractal/
23:51johnmn3rad
23:53johnmn3or app-data... forgot what it was called. Not implemented yet, but provides for p2p in the browser
23:54johnmn3the audio/video part is implemented in the chrome canary build
23:55dnolenibdknox: this sounds like exciting stuff!
23:56ibdknoxdnolen: statemachines and some neat helpers around them ftw :)
23:59ibdknoxI've been a bit quiet lately and will be so for the next month I suspect, but I'll have lots of stuff to debut and talk about at ClojureWest :)