#clojure log - Dec 30 2011

The Joy of Clojure
Main Clojure site
Google Group
IRC
List of all logged dates

0:20 emezeske: Any clojurescript compiler people in here?

0:38 fryguy: is it normal for "lein repl" to take 5+ seconds to start?

0:39 technomancy: fryguy: yeah, you'll want to see if you can install a client JVM; it starts a lot faster than the server JVM

0:39 fryguy: what is a lot faster in this case?

0:40 technomancy: the time it takes to launch the process

0:40 fryguy: i mean how much faster

0:40 also:

0:40 ~% java -version

0:40 clojurebot: excusez-moi

0:40 fryguy: java version "1.6.0_22"

0:40 OpenJDK Runtime Environment (IcedTea6 1.10.4) (ArchLinux-6.b22_1.10.4-1-x86_64)

0:40 OpenJDK 64-Bit Server VM (build 19.0-b09, mixed mode)

0:40 technomancy: on an SSD with a weak processor I get the repl coming up in about 0.7s

0:43 a weak cpu being a 1.8 GHz core 2 duo

0:43 fryguy: trying to find out how to get a client vm now

0:44 technomancy: you'll need it compiled for 32-bit for starters

0:44 fryguy: there's not 64-bit client vm?

0:45 technomancy: right

0:45 fryguy: that sucks

0:46 technomancy: yeah, I need to put together some docs for that; maybe on the wiki

0:47 it used to be easy to get a 32-bit oracle JDK on ubuntu, but for some reason the openjdk builds are only available as 64-bit

0:49 fryguy: trying to find them for my distro now, PITA

0:50 technomancy: actually sorry; the 0.7s number was the boot time for lein itself; the time it takes to start a repl will be longer

0:50 still, it'll definitely be better than 5s

0:53 fryguy: i guess I can just live with poor start times for now

0:53 not like i'll be starting repls all of the time, if I do this right i'll have my repl up and connected to my text editor and that's it

0:54 technomancy: yeah, that's basically the reason I haven't bothered getting set up with a client JVM; I just don't start a new process very often.

0:55 fryguy: so i've got "clj" as an executable, and lein, will get interaction with text editor next. Hopefully that's all I'll need in the short term to get things done

0:56 amalloy: i suggest deleting clj with a flamethrower. lein repl will just make you happier

0:56 there are people who disagree with me here, but most of the time when you want a repl, use lein

0:57 technomancy: amalloy: there are?

0:57 fryguy: so, here's a silly question, if I do JUST lein self-install, and nothing else, does that give me clojure too? or do I need clojure before I use lein?

0:57 amalloy: i've heard rumblings once or twice, technomancy

0:57 fryguy: i installed clojure from my distro's package repository

0:57 technomancy: rumblings, you say?

0:57 amalloy: i forget from who; some heretics

0:57 technomancy: ~guards

0:57 clojurebot: SEIZE HIM!

0:58 technomancy: fryguy: yeah, that's usually not very useful

0:58 common mistake

0:59 fryguy: so I JUST need lein?

0:59 (and a jdk obviously), nothing else?

1:00 technomancy: plus whatever it takes to make your editor work with clojure

1:00 fryguy: right

1:00 i thought lein would be more analogous to cabal from haskell

1:01 amalloy: does he actually need a jdk? i kinda thought clojure only needed a jre but haven't really investigated

1:02 technomancy: depends on if you want a debugger and/or javca

1:02 *javac

1:02 amalloy: oh right, durn that javac

1:05 technomancy: for some reason people tend to use it

1:05 no idea why

2:09 emezeske: Okay, I've encountered a situation where I can "lein run ..." my project, and it throws an exception.

2:09 Then, if I touch a particular .clj file in my src/ directory

2:10 And "lein run ..." again, no exception is thrown and it works just fine

2:10 (and I mean touch as in the unix command; no change to its contents)

2:10 This is really hurting my brain...

2:20 simonadameit: emezeske: strange situation… though it doesn't sound totally inconceivable to me.. dont those build tools decide, what to recompile based on last modification date?

2:21 emezeske: simonadameit: Yeah, I assume so

2:21 simonadameit: I noted all the timestamps on the *.class files, though, and then touched my special file and reran things

2:22 simonadameit: None of the *.class files were modified

2:22 So I wonder if maybe making the file newer than it's *.class files makes clojure interpret it instead of using the .class file on disk

2:23 The weird thing is, though, that I'm not changing contents of the .clj file, so it should work the same from a .class or interpreted from a .clj

2:27 Weird... it looks like the {:macro true} metadata is not being stored in the class files

2:27 When I run things without AOT, though, the macros have ^{:macro true}

2:30 simonadameit: emezeske: sounds like that could be a clojure bug?

2:30 emezeske: I wish you good luck, gotta go to work

2:30 emezeske: simonadameit: It's beginning to look that way... X.X

2:30 simonadameit: thanks for the input!!

2:32 amalloy: emezeske: whoa, that sounds pretty weird. what was happening that made you start looking at macro meta?

2:32 emezeske: amalloy: uh, I don't remember. I've been digging at this for like 20 hours

2:32 There's problems with using the clojurescript compiler when it's AOT compiled

2:32 sometimes

2:33 And it's due to the way it determines "what's a macro"

2:33 It checks the metadata for :macro=true

2:33 ibdknox: why are you trying to aot compile the cljs compiler?

2:33 emezeske: I'm trying to package it up as an uberjar

2:33 amalloy: ibdknox: i send IRC msgs to my IRC client to ask it to talk to y'all

2:34 ibdknox: amalloy: hm?

2:34 emezeske: Anyway, the {:macro true} metadata is apprently not stored in AOT class files

2:34 amalloy: i was going for a yo dawg thing: compiling the compiler, /msging the irc client...didn't work out that well

2:35 ibdknox: haha

2:35 :p

2:35 emezeske: I guess the metadata is not stored at all, and just the basic stuff is regenerated when loading the class files?

2:35 (by basic stuff I mean line no, file, etc)

2:35 Wait, that doesn't make sense... The line-no/file would need to be stored...

3:34 kral: morning

3:35 Scriptor: marnin

5:47 przemek_: Hi, I have a question. I'm wondering what is the idiomatic way to create a new map out of some other map in a way that we want to modify some of its values.

5:48 say we have a map {:a {:foo 1 :bar 2} ... } and we need to modify :foo for some entries and we want to produce a new map

5:49 in Scala there is something like "yield"

5:49 so I can get to entry k/v and can yield value(s) so at the end it is the final new map

5:50 no idea how to accomplish this simply in Clojure

5:51 any ideas highly appreciated :)

5:51 raek: przemek_: check out the *-in functions: update-in, assoc-in, get-in

5:52 ,(update-in {:a {:foo 1}} [:a :foo] inc)

5:52 clojurebot: {:a {:foo 2}}

5:53 przemek_: yeah

5:53 thanks a lot!

6:02 raek: przemek_: it's usually simpler to answer a "how do I ___?" question if you can show an example input and an example of the desired output

6:06 przemek_: ok

6:07 actually it still does not seem simple to me

6:07 Given: {"foo" {:x ... :y ...} "bar" {:x ... :y ...} ...}

6:07 I want to have all entries that match some predicate to have :x value modified, say changed to 1:

6:07 {"foo" {:x 1 :y ...} "bar" {:x 1 :y ...} ... }

6:07 note I don't know the key name/position

6:08 have read http://clojuredocs.org/clojure_core/clojure.core/update-in and still not sure...

6:12 raek: I think this is easier to do if you break down the problem into smaller pieces

6:12 przemek_: surely, but still it is just 1 level of nesting and a simple map

6:13 raek: (defn update-outer-map [m] (into (empty m) (for [[key val] m] [key (update-inner-map val)])))

6:13 (defn update-inner-map [m] (if (pred? (:x m)) (assoc m :x 1) m))

6:13 mageslayerden: Hi guys. I am trying emacs+slime+clojure. And something breaks :). Maybe someone knows the magic spell? I see only - error in process filter: Elisp destructure-case failed: (:write-string "2 " :repl-result)

6:14 it's when I am trying to eval (+ 1 1)

6:14 przemek_: it kinda makes sense :) I will check that out

6:14 mageslayerden: I am using slime from macmalade repo :)

6:17 raek: przemek_: but of course you can do all this in one function. just inline update-inner-map into the for

6:18 in this case update-outer-map could also have been written (defn update-outer-map [m] (zipmap (keys m)) (map update-inner-map (vals m))))

6:18 since you only want to change the values of the outer map

6:35 mageslayerden: make sure you don't have slime installed in your OS package manager (e.g. apt-get) and that you don't have slime-clj, swank-clj, and swank-clojure installed in emacs

6:36 mageslayerden: I uninstalled official slime. The problem is without swank-clj - slime does not start, just emits another error

6:36 raek: the only clojure related elisp package you should have in a basic setup is clojure-mode (and if you don't use clojure-jack-in: also slime and slime-repl)

6:37 mageslayerden: slime and slime-repl have been installed from elpa as well

6:37 raek: mageslayerden: swank/slime-clj is an alternative implementation of swank and slime. do not mix them with the usual ones

6:38 that project has been renamed, but the versions with the old names are still available

6:38 mageslayerden: Ok. I got it. btw. is it possible to unload slime-clj without restarting emacs?

6:40 raek: basic setup: clojure-mode (and possibly slime and slime-repl) on the emacs side and swank-clojure on the leiningen side

6:41 antares_: vijaykiran: hey

6:41 mageslayerden: ok. I'll to restart emacs to test it now. Thanks a lot

6:41 raek: starting swank-clojure from emacs is a very outdated approach (not counting features that use lein to do it, like clojure-jack-in and various lein elisp packages)

6:43 vijaykiran: antares_: Hi

6:43 antares_: vijaykiran: you had a question in #travis, correct?

6:44 mageslayerden: raek: without slime-clj, I get - byte-code: Symbol's function definition is void: slime-buffer-name

6:44

6:44 vijaykiran: antares_: yeah :)

6:45 antares_: vijaykiran: you problem seems to be what several people had with re-published artifacts

6:45 vijaykiran: on travis-ci.org, dependencies are installed from scratch. Locally it is usually not the case. Try (re)moving ~/.m2 and see if you can reproduce the issue locally, then :exclude clojure dependency like this: https://github.com/michaelklishin/monger/blob/master/project.clj#L7

6:46 mageslayerden: raek: here is my emacs+slime config - http://pastebin.com/UD3rLPhP

6:48 vijaykiran: antares_: oh .. thanks a lot, I don't have any tests but I'll try your tip

6:49 antares_: vijaykiran: hm, what do you mean you don't have any tests?

6:49 vijaykiran: then why put your project on travis-ci.org? :)

6:49 raek: mageslayerden: when you install slime or when you use it?

6:49 it is normal to get these kind of errors when installing

6:49 vijaykiran: antares_: just to "test" :)

6:49 mageslayerden: when? just 2 hours ago :)

6:50 antares_: vijaykiran: ok. Well, one issue is already revealed :)

6:51 mageslayerden: sorry. I misunderstood you. This error is shown when I am starting emacs.

6:54 vijaykiran: antares_: I've another question - do you know if there's an easy way to use test database from travis (Clojure) ?

6:54 raek: mageslayerden: sorry, but I don't know what to do except for trying commenting out lines in the .emacs.d file

6:55 antares_: vijaykiran: we provide mysql, postgresql, sqlite, mongodb, riak, couchdb, redis and some projects download & install neo4j and so on

6:55 vijaykiran: http://about.travis-ci.org/docs/user/database-setup/

6:55 mageslayerden: raek: looks like like it is related to hippie-expand. I removed hippie-expand, but the error with eval is the same

6:55 antares_: vijaykiran: create your databases in before_script, that is usually it

6:56 raek: mageslayerden: I got to go now, but you can read more in the official docs for swank-clojure: https://github.com/technomancy/swank-clojure

6:56 mageslayerden: raek: thanks, I'll try

6:56 raek: if you are going to follow a guide, this is the *only* one you should look at

6:56 vijaykiran: antares_: yes, saw that page. But was wondering if different config is needed for clj apps

6:56 antares_: vijaykiran: no

6:57 mageslayerden: raek: I tried maybe a dozen already :), but thanks :)

6:57 vijaykiran: antares_: okies .. thanks, will RTFM and drop by #travis if I'm stuck!

7:00 antares_: vijaykiran: for example, I have https://github.com/michaelklishin/monger and https://github.com/michaelklishin/neocons on travis. https://github.com/doctrine/dbal/blob/master/.travis.yml is a good example of testing against multiple relational databases.

7:01 vijaykiran: cool, let us know what you think :)

7:18 benoyst: just a stupid question, but why clojure.xml/parse does not accept a string (except as uri) but only files?

7:19 I've a function returning a java.lang.String which happens to be an xml doc but parse refuses to munch it.

7:20 I'm sure it's very basic but I can't get out of this issue.

7:33 cemerick: ,(clojure.xml/parse (java.io.ByteArrayInputStream. (.getBytes "<html></html>" "UTF8")))

7:33 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.xml>

7:33 cemerick: ,(require 'clojure.xml)

7:33 clojurebot: nil

7:33 cemerick: ,(clojure.xml/parse (java.io.ByteArrayInputStream. (.getBytes "<html></html>" "UTF8")))

7:33 clojurebot: {:tag :html, :attrs nil, :content nil}

7:33 cemerick: benoyst: ^^

7:34 benoyst: cemerick: just for the records: big fan!

7:34 this is the offending code: http://maleloria.org/temp/hard-times-with-xml.txt

7:35 oh. ByteArrayInputStream.

7:35 I guess I dit not get something right here.

7:35 (but I thought I did that in my code)

7:37 cemerick: benoyst: what's the actual error you're getting?

7:40 benoyst: cemerick: java.lang.String cannot be cast to clojure.lang.IFn. I guess there are too many () somewhere?

7:41 cemerick: benoyst: from-raw-msg-to-details calls my-saml-xml, which looks to be a string.

7:44 benoyst: oh yes, but (parse-saml-message mysamlxml) throws the IFn error ... before even playing with the from-...

7:44 (I'm converting a base64xml to xml to get some data in it)

7:45 cemerick: benoyst: can you paste the error + stack trace?

7:47 benoyst: sure!

7:54 cemerick: I'm very grateful for your time. I've updated my file here: http://maleloria.org/temp/hard-times-with-xml.txt

7:54 (repl session + strack trace)

7:56 Somelauw: Is there some way to get slime/leiningen/clojure/emacs outside a Java heap space error without restarting emacs?

7:56 I got myself into infinite a recursion without TR.

7:57 cemerick: benoyst: oh: (saml-xml)

7:58 benoyst: (big shame on me in 3, 2, 1...)?

7:58 oh you mean (.getBytes (saml-xml) "UTF-8"))] instead of (.getBytes saml-xml "UTF-8"))] right?

7:58 cemerick: yes

7:59 benoyst: yes.

7:59 big shame in me *now* :)

7:59 on

7:59 cemerick: (foo) invokes foo as a function; since saml-xml is a string, that won't work :-)

8:00 benoyst: yes! can't believe I made that. Sorry. and *many* thanks for your expert eye on that!

8:00 cemerick: You're welcome. no need to be sorry :-)

8:00 benoyst: cemerick: many thanks!

8:05 (much better now!)

8:14 vijaykiran: is there an easy way to see the dependency tree for a lein project ?

8:15 cemerick: vijaykiran: lein pom && mvn dependency:tree, assuming you have maven installed

8:15 Raynes: lein pom && mvn dependency:tree

8:15 chouser: vijaykiran: the best I've been able to do is trace the load function, so you can see which namespaces are loading which.

8:15 Raynes: cemerick: Dude.

8:15 cemerick: A better alternative is incoming

8:15 Raynes: Dude!

8:16 Raynes: I don't know how your latency made that look, but mine made it appear as if we said that at *exactly* the same time. Like, two a microsecond.

8:16 to*

8:16 vijaykiran: cemerick: how do I trace - sorry noob here

8:16 cemerick: trace?

8:16 clojurebot: trace is http://richhickey.github.com/clojure-contrib/trace-api.html

8:16 lazybot: Nooooo, that's so out of date! Please see instead http://clojure.github.com/clojure-contrib/trace-api.html and try to stop linking to rich's repo.

8:17 cemerick: gawd, dueling bots

8:17 Raynes: Hahaha, clojurebot just got told.

8:17 chouser: except they're both wrong

8:18 cemerick: chouser: He lives! I thought you'd abandoned us irc plebs for good. ;-)

8:18 chouser: https://github.com/clojure/tools.trace

8:19 well, I am getting sufficient Clojure fixes at work now.

8:19 cemerick: Oh, so we were just your fling on the side. I get it.

8:19 :-D

8:20 chouser: I don't need IRC to stem the gnawing desperate craving for Clojure discussions.

8:20 cemerick: s'ok, I'm sorta absent these days a bit as well

8:21 chouser: fling? More like I'm selling now, so don't need my old dealer.

8:22 Somelauw: Why is this code not lazy?

8:22 http://pastebin.com/b0QJsDRz

8:25 chouser: Somelauw: why do you think it isn't?

8:25 Somelauw: chouser: Executing it results in an infinite loop.

8:26 Or at least, it hangs.

8:27 And ends in a heap memory error if I don't stop it.

8:27 chouser: (first (primes)) returns promptly for me

8:28 Somelauw: er, my bad

8:29 chouser: That suggests it actually is lazy, but that copmuting some of the later elements of the seq consumes large amounts of time and memory

8:30 Somelauw: I tried writing this prime function. Then got a heap error. I restarted emacs and wrote it all over again and this time I forgot to use the take command.

8:32 chouser: I know this is not the most efficient way.

8:34 thanks

9:00 solussd: is there a more straightforward way to splice in a list of arguments to a defrecord than a macro? e.g. If I have a record call Blah that takes 2 args and I have [arg1 arg2], I need (Blah. arg1 arg2)

9:03 cemerick: solussd: use (->Blah arg1 arg2)

9:04 solussd: cemerick: but my arg1 and arg2 are in a vector, how do I splice them in w/o a macro?

9:04 cemerick: (apply ->Blah arg1 arg2)

9:04 hank_the_hobo: cemerick? I'm a user of nREPL. it says in the docs to contact you on IRC.

9:04 solussd: (apply ->Blah [arg1 arg2])

9:05 this ->RecordType is new to me, is it new to clojure?

9:05 cemerick: solussd: yeah, sorry, typing too fast :-)

9:05 solussd: new in 1.3, discussed here http://dev.clojure.org/display/design/defrecord+improvements

9:05 hank_the_hobo: ut-oh :-)

9:05 what's up?

9:06 solussd: cool thanks!

9:06 hank_the_hobo: @cemerick. why uh oh. it's nifty and useful and many thanks for that.

9:06 1 comment:

9:07 the latest iteration seems to be introducing a dependency on java.awt for some strange reason. not sure what awt has to do with a REPL

9:07 I'm using it on Android which has no AWT. is this something that can be factored out into a separate module.

9:08 cemerick: hank_the_hobo: I think it's more likely that you're doing something to prompt AWT to start up.

9:08 Oh.

9:08 Hrm.

9:09 hank_the_hobo: it's says java.awt.RenderedImage somewhere in the code if I'm not too tired to tell things apart

9:09 cemerick: hank_the_hobo: so you're using 0.0.6-SNAPSHOT?

9:10 hank_the_hobo: not actively but I did a little look ahead

9:10 cemerick: Yeah. You're right.

9:11 hank_the_hobo: @cemerick I might have to fork it anyway ... the other problem on android is that threads come with very small default stack sizes so I had to change the part where the executor is init'd with the threadfactory

9:11 android has 8k by default which is not enough to eval moderately complex expressions

9:11 so I might fork it anyway

9:12 cemerick: hank_the_hobo: some fairly significant improvements will be coming to nREPL soon that will make the AWT issue go away.

9:12 hank_the_hobo: oh

9:12 ok

9:12 cemerick: I'm not even sure I'm going to put out a 0.0.6 release

9:12 hank_the_hobo: well I'm worried for nothing then.

9:12 cemerick: Probably going to "jump" to 0.1.0 with a new architecture

9:13 hank_the_hobo: thanks keep up the good work

9:14 cemerick: hank_the_hobo: a patch to customize the thread stack size would be most welcome, though.

9:15 I might end up changing what you produce so as to satisfy other configuration requirements as well, but I'd at least know what you need on android.

9:15 hank_the_hobo: @cemerick ok no probs

9:15 cemerick: heh, or you can just file a bug: http://dev.clojure.org/jira/browse/NREPL

9:15 :-P

9:16 hank_the_hobo: ah is that how it works ... couldn't find the bug function on github that some other accounts have

9:16 cemerick: Yeah, nREPL is a contrib project, so everything is in JIRA / confluence.

9:22 solussd: is (into {} (vec my-record)) the best way to squeeze a hash-map from a record?

9:23 cemerick: solussd: just (into [] my-record) will do — though worrying about concrete types like that should be a warning signal.

9:24 solussd: but I want a map

9:24 cemerick: Records are maps!

9:24 TimMc: solussd: There are different kinds of maps.

9:24 solussd: right--

9:24 you had [], I wanted {}, which also works. :)

9:24 TimMc: ah, into [] <- got it

9:25 solussd: Yes, (into {} ...) is fine.

9:25 solussd: I'm using (into {} my-record) now, thanks!

9:25 I swear that didn't work before…

9:26 cemerick: TimMc: [] was (another) typo on my part, I still suspect solussd is doing an unnecessary conversion.

9:26 solussd: is (into {} my-record) ok?

9:26 TimMc: solussd: What's the use-case here?

9:27 solussd: I need to pass the contents of a record as a map for :attrs in a map for clojure.xml/emit

9:28 so (clojure.xml/emit {:tag :something :attrs (into {} my-record)})

9:28 TimMc: And it doesn't treat records as maps?

9:28 solussd: i thought it didnt-- but then, i also thought the into wasn't working.. (testing...)

9:29 goodieboy: anyone here use noir?

9:29 solussd: that works… :D

9:55 why doesn't this work? (. java-array length) ?

9:56 hoeck: solussd: because .length isn't a property or method of java arrays, its java syntax

9:56 solussd: like String.class

9:57 solussd: oh, ok. Do I have to make it a seq then?

9:57 (to get the length)

9:59 jodaro: you should be able to use count

9:59 hoeck: solussd: no, (count java-array) does the right thing for you

9:59 solussd: thanks

10:10 TimMc: I recently found myself annoyed that Java doesn't have a IntegerNumber marker interface on Long, Integer, Short, Byte, and BigInteger.

10:11 (and similar for the floating-point numbers.)

10:12 Would multimethods (with a derive hierarchy) be an effective way of getting that information?

10:18 $findfn (int-array 5) 5 ; solussd

10:18 lazybot: [clojure.core/count clojure.core/alength]

10:19 TimMc: I think alength would be used when performance was essential.

10:20 solussd: thanks

10:50 jodaro: woop, my first ANN: http://groups.google.com/group/clojure/browse_thread/thread/7ae3e1926f02b20f

11:17 TimMc: "ANN"?

11:18 nvm, announcement

11:40 hoeck: I had no idea that was sugar. Array classes are just one big lie, eh?

11:40 s/sugar/syntax/

11:45 hoeck: TimMc: they are 'special', I don't like that, no one will notice it except when starting to use clojure

11:55 solussd: how do I get a sub-array of a plain java array?

12:10 semperos: solussd: what's your array look like? (gist/pastebin) and do you need to return a Java array, or are you looking to make it a Clojure datastructure?

12:11 solussd: semipros its for a genetic algorithm where I'm randomly piecing together sub-arrays to form 'children'. Don't need to go back to a clojure data structure

12:11 *semperos^

12:11 semperos: ok

12:11 by sub-array, do you mean you have something like [1 2 [:a :b] 3 4] and you need the [:a :b] ?

12:12 solussd: well, it's a java character array created like this: (char-array \a \b \c)

12:12 I might want just the \b and \c, for example

12:12 so, what I need is a sub-array copy function

12:12 in java it is System.arraycopy

12:13 cemerick: solussd: that's what it is in Clojure too ;-)

12:14 ibdknox: cemerick: I'll get you my feedback by tomorrow, sound good?

12:14 cemerick: ibdknox: perfect, thanks :-)

12:14 I saw a commit that looks like it fixed the bug I think I found?

12:14 ibdknox: it wasn't a bug per se, I actually did it on purpose, it was just a dumb decision :)

12:15 wasn't consistent with everything else

12:15 so yep!

12:15 all fixed

12:31 TimMc: solussd: Why are you using arrays instead of vectors?

12:32 solussd: performance I guess

12:32 ibdknox: I missed the beginning of that conversation so I didn't respond with ##(doc subvec) ;)

12:32 lazybot: ⇒ "([v start] [v start end]); Returns a persistent vector of the items in vector from start (inclusive) to end (exclusive). If end is not supplied, defaults to (count vector). This operation is O(1) and very fast, as the resulting vector shares structure with the original and no trimming is done."

12:32 ibdknox: hard to beat constant time "copies"

12:33 if copying is the main overhead

12:33 solussd: I doubt it is though..

12:33 ibdknox: huh?

12:33 oh

12:33 yeah, I have no idea what you're doing :)

12:35 solussd: out of curiosity, did you benchmark the difference between an array solution and a vector one?

12:35 TimMc: solussd: "performance I guess" <-- if you haven't profiled your code, don't try to optimize

12:35 ibdknox: that's what I was getting at ^^

12:35 solussd: simple example: two parents: 'abcdef' and 'uvwxyz' would make children like: 'abcxyz' 'xyzdef', etc. Need millions of these where I'm taking sub-arrays from each parent and concatenating them together into a new array

12:36 ibdknox: copying is definitely the overhead then :p

12:36 solussd: well, the vector solution runs terribly.. looking to try a straight java-array approach

12:37 ibdknox: are you using seqs? Vectors are really fast, seqs are really slow

12:37 solussd: well I start with strings that are 'cast' to vecs and then back to strings… that might be part of the problem

12:37 ibdknox: ah

12:38 that could do it

12:38 ,(source subs)

12:38 clojurebot: Source not found

12:38 ibdknox: I assume that is really fast ^

12:39 do you really need them to be vectors? if you're just doing crossovers, it seems like that would be unnecessary

12:39 TimMc: solussd: Just keep in mind that subvec and substring hold a reference to the original, preventing garbage collection.

12:40 ibdknox: that might actually be more memory efficient in the long run if all patterns are just parts of some base set

12:41 you'd only define that set once, assuming subvec does the smart thing

12:41 solussd: hmm

12:42 it's only the original string that isn't ever collected, i can live with that

12:43 ibdknox: It'd be easy to find out :)

12:44 solussd: thanks

12:46 choffstein: Hello everyone! This is a real, real shot in the dark -- and I know it isn't the right place to ask -- but does anyone have experience in developing a REST API for services that don't have cookie storage (and therefore can't rely on regular session authentication methods)? I could really use some resources on how to implement a secure "authentication key" system.

12:46 Security isn't my forte -- and so far, I am just giving each client a unique key and having them just connect over https with their unique key to identify themselves

12:47 flazz: is slime-repl for clojure supposed to 'use' clojure.repl?

12:47 technomancy_: flazz: most (all?) of the stuff in clojure.repl is obsoleted by slime functionality

12:48 flazz: technomancy_: what about doc?

12:48 technomancy_: flazz: C-c C-d d will handle that

12:48 not obsoleted exactly... overshadowed maybe?

12:48 flazz: technomancy_: omg, nice, thanks

12:48 technomancy_: there's a nice reference in the swank-clojure readme

12:50 ldh: i'm trying to use clojure.test to check existence of all elements in a collection against a set: (are [v] (my-set v) my-collection). however, 'are' wants discrete values and not an explicit collection. how can i expand my-collection to work here?

12:51 technomancy_: ldh: (is (every? my-set my-collection))

12:53 ibdknox: ldh: (is (every? my-set my-collection)

12:53 darn

12:53 beat to the punch :p

12:53 ldh: great, thanks guys

13:09 rangen: hi. the screencast about sequences is broken, it only shows for few seconds: http://blip.tv/clojure/clojure-sequences-740581

13:13 tmciver: choffstein: I'm a http security newb myself but since you are using SSL, you could use http's Basic Authentication, I think.

13:13 choffstein: I intend to do something like this in a web app I'm working on.

13:14 choffstein: of course the problem with that is there's no good 'log out' mechanism, to my knowledge.

13:15 technomancy_: rangen: there's a thread on the mailing list about how to get downloadable versions of the videos from a few weeks ago

13:18 choffstein: tmciver: Yeah -- yeah, that's an interesting though. But I would definitely want some sort of session timeout

13:18 tmciver: I'm currently in #security where I am getting lots of interesting ideas about using certs for client auth and that sort of stuff

13:19 tmciver: choffstein: cool

13:20 choffstein: you'll have to let me know what you find; they won't let me in! :(

13:20 choffstein: No?

13:21 tmciver: Yeah, I tried to join #security on freenode. says you need to be invited.

13:27 TimMc: haha

13:28 tmciver: I bet you need to register your nick first.

13:38 rangen: technomancy: found it, but still no luck. that episode is borken also on itunes version

13:38 technomancy: rangen: might want to post on the mailing list about it then

13:38 I'd be happy to get off blip.tv

13:43 rangen: there was a post about this issue in september, but no replies

14:00 juhu_chapa: Is there a modular contrib project related to network sockets programming?

14:15 ssideris: hello

14:18 solussd: how do you tell emacs to compile every form in a file (working in emacs/slime). I usually compile each form using c-c c-c

14:19 TimMc: Compile?

14:19 You mean eval in REPL?

14:38 axle_512_: anyone know why incanter charts would be plotted with jagged lines?

14:38 ssideris: solussd: c-c c-l

14:38 while in the relevant buffer

15:24 cemerick: FYI: Mostly Lazy Episode 0.0.3: Chris Granger (@ibdknox) at Clojure Conj 2011 http://wp.me/p1Y10D-M

15:25 jonasen: EU överväger att utvidga sin Atalanta-operation till Somalias kust, uppgav Tyskland på fredagen. För tillfället opererar EU:s antipiratstyrka i farvattnen mellan Somalia och Jemen och på Indiska oceanen.

15:26 sorry

15:33 TimMc: cemerick: Nice!

15:33 hugod: v

15:40 ibdknox: latest Mostly Lazy Podcast submitted to HN: http://news.ycombinator.com/item?id=3409001

15:46 jodaro: rad

15:53 solussd: can I still use clojure.contrib.lazy-xml in 1.3?

16:08 society__: does anyone have any ideas for utilizing json-str with bson data from mongodb that contains and ObjectId key which isn't recognized by the standard implementation?

16:08 Bronsa: cemerick: ping

16:09 cemerick: hi :-)

16:09 Bronsa: in mostly lazy episode 0.0.3 the link to Noir is mistyped, should be webnoir.org, you wrote webnoir.com

16:10 cemerick: Thanks, fixed. I always do that.

16:11 Bronsa: great interviews though

16:11 ibdknox: nobody wants to go there anyways ;)

16:11 it's an evil place.

16:19 cemerick: ibdknox: I've never understood what it is — a splash page with a tune, and that's it?

16:20 ibdknox: I meant my website lol. But yeah... I have no idea

16:20 even weirder are some of the links off of it: http://www.webnoir.com/bob/sackson.htm

16:26 mcrittenden: man there's all kinds of good stuff in there. http://gog.is/site:webnoir.com

16:27 ibdknox: so weird

16:36 cemerick: ibdknox: they've gotten more traffic in the past 6 months than in the past 6 years! ;-)

16:36 ibdknox: haha

16:36 cemerick: It's my gift to them ;)

16:54 mcrittenden: decent way to remove non-ascii chars from a string, anyone?

16:56 jodaro: mcrittenden: i had a function that would tell me if a string contained non-ascii characters somewhere

16:56 didn't remove them, though

16:56 let me find it

16:56 mcrittenden: that would definitely be helpful jodaro

16:57 TimMc: mcrittenden: A regex with [^[:ascii:]] or some such would do it.

16:57 raek: mcrittenden: perhaps you could use clojure.string/replace and a regex for non-ascii chars?

16:58 (str/replace the-string #"[^\u0000-\u007F]" "")

16:59 ,(clojure.string/replace "abcåäö" #"[^\u0000-\u007F]" "")

16:59 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.string>

16:59 TimMc: mcrittenden: Do you want ASCII control chars removed too?

16:59 mcrittenden: TimMc: yep, if possible

16:59 TimMc: and tab? :-)

16:59 mcrittenden: yep

17:00 raek: ok, make that \u0020-\u007E

17:00 jodaro: all i was doing was checking to see if the character arg was in the 32-127 range

17:00 mcrittenden: awesome, thanks all

17:00 raek: ascii chars 32 to 126 are printable

17:00 127 is a control char

17:01 jodaro: crap, it might have gone away with a botched repl

17:01 sorry, right, 126

17:01 raek: mcrittenden: you need this to generate a URL or sometihng?

17:01 TimMc: mcrittenden: Writing a hex viewer? https://github.com/tmciver/hexdump/blob/master/src/hexdump/core.clj

17:01 raek: consider the case where a string contains only non-ascii characters (e.g. russian)

17:01 TimMc: Wait, you're removing them, not replacing them.

17:02 raek: a hex viewer should operate on bytes, not character

17:02 s

17:02 TimMc: (^ not my repo)

17:02 mcrittenden: raek, nope, I just have a bunch of txt files with nonprintable chars and i was hoping to write a clj script to clean them up

17:03 raek: why are there "nonprintable chars" there in the first place? mixed binary and textual data?

17:04 mcrittenden: tbh I'm not sure, seems to be maybe fancy chars like curly quotes that someone's editor screwed up at some point

17:04 at least that's my guess

17:04 jodaro: tr -cd "[:print:]" < file1

17:04 man tr

17:05 that might be what you want

17:05 TimMc: mcrittenden: And your text editor is barfing?

17:06 mcrittenden: TimMc: nope, I'm importing these txt files into a CMS which is barfing

17:06 jodaro that's awesome, tr is new to me.

17:07 raek: mcrittenden: you are probably decoding the file with the wrong charset. the best way would be to find out which encoding scheme the file uses, and read it with that

17:08 mcrittenden: sometimes you can use the 'file' command line program to find it out

17:08 TimMc: Or they've been through the charset wringer and no longer have a correct charset.

17:11 mcrittenden: gotta run, thanks again guys

17:37 tscheibl: read-string is damn slow in Clojurescript (except on v8... e.g. Chrome Browser)

18:39 technomancy: if you have written or are interested in writing a leiningen plugin, please read this proposal for a new way to handle plugins: https://groups.google.com/group/leiningen/browse_thread/thread/db4f8336f565d626

18:46 also, did anyone try out that slime-compile-presave hook I posted yesterday?

18:46 I wasn't sure if it was crazy or not, but it's growing on me

18:47 TimMc: technomancy: Nah, it's not hardcore enough. It should run tests too.

18:47 technomancy: aw yeah

18:48 TimMc: (Really, it should be a pre-commit-hook.)

18:48 amalloy: technomancy: fyi i love slime, and i am never-ever gonna try that hook

18:48 TimMc: I think I would use it if it just *told* the file didn't compile, but didn't block the save.

18:49 amalloy: i want to save non-compiling stuff all the time

18:49 technomancy: TimMc: pre-commit hooks that take > 1s drive me nuts

18:49 amalloy: that's what people say about paredit too

18:49 amalloy: yeah but they're wrong and i'm always right

18:50 technomancy: oh yeah; I forgot

18:50 amalloy: seriously though: maybe i'm trying to write something top-down for a while, using functions that don't exist yet. i can't save my thoughts because the computer can't run them yet? it's not supposed to be able to run them

18:51 Raynes: I agree, that hook is useless for me.

18:51 technomancy: turn on auto-declare? ={

18:51 Raynes: I save things *compulsively*.

18:51 technomancy: =)

18:52 Raynes: Like, every two words that I type ends in C-x C-s

18:52 technomancy: Raynes: so write better code, duh.

18:52 basically it forces you to take smaller, more correct steps

18:54 well anyway, it'll never be the default, but I'll probably add it as a swank payload with the defvar set to nil

18:54 TimMc: Can't hurt.

18:54 MenTaLguY: if nothing else you can always put in stubs

18:54 to let things compile

18:55 technomancy: MenTaLguY: what we need is a smalltalk-style debugger that offers to create defns that don't already exist

18:55 actually ... damn.

18:55 we really do

18:55 MenTaLguY: hmm

18:55 technomancy: slime already has customizable restarts, which swank-clojure doesn't use at all

18:56 TimMc: yay condition systems

18:56 technomancy: "This var wasn't found. Would you like to 0) abort, 1) refer it from another namespace or 2) add a defn in the current one?"

18:56 TimMc: "3) DWIM"

18:56 technomancy: or delegate to slamhound

18:56 TimMc: which opens http://www.reddit.com/ in your browser

18:57 MenTaLguY: "It looks like you're trying to reference a var. Would you like help with that?"

18:57 technomancy: hahaha

18:57 TimMc: Yes! We're one step closer to vim-clippy.

18:58 MenTaLguY: so I've got a bit of code that I've been trying to make not ugly

18:58 anyone want to have a look and make suggestions for expressing it in a more lucid way?

18:58 amalloy: ~anyone

18:58 clojurebot: Just 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 ..."

18:59 technomancy: I need to take off, but if you bring it by next Thursday I could. =)

19:00 MenTaLguY: not sure if i'll make it to Seajure or not

19:00 but thanks

19:00 this is the bit I'm wrestling with at the moment if anyone else wants to have a look:

19:00 https://gist.github.com/1542110

19:01 basically I've got a bunch of maps which describe transitions in an NFA

19:02 with the :default key in the map, if present, providing a default transition

19:02 amalloy: well, lookup-edge is (some edges [label :default])

19:02 MenTaLguY: okay, that helps a bit

19:03 hm

19:04 actually it really needs to be (get edges label (edges :default)), I just realized

19:05 since you can still have an explicit edge to the error state even when there's a default

19:06 anyway, merge-nfa-edges is the really ugly part (to me)

19:07 amalloy: indeed. i think you'd be happier if you threw away most of the lets, and all of the maps, and replaced them with a for

19:07 (let [labels (...)] (into {} (for [[k v] labels] [k (whatever v)])))

19:09 MenTaLguY: hmm

19:26 amalloy: hm, well, this seems a bit better: https://gist.github.com/1542110

19:32 amalloy: personally all the defn-s make me sad. i don't care for defn- most of the time anyway, but in particular here you're making the functions *so* small that like a third of the screen space is taken up by giving names to snall ideas

19:33 and passing around arguments (eg edges-map) when you could just be using the one in the local scope if you inlined the functions

19:38 MenTaLguY: lookup-edge actually gets used elsewhere, so that's factored out for th sake of DRY

19:38 I guess I see your point about merge-nfa-targets

19:38 but the indentation was getting quite deep

19:40 amalloy: well, you can do other things to combat that, if it bothers you

19:40 eg, don't (let) the labels - inline that into the for initializer

19:41 toss in some more liberal newlines, trading vertical for horizontal space

19:42 https://gist.github.com/1542246 doesn't get very wide, for example

19:43 MenTaLguY: yeah, that's not too bad

19:48 jodaro: hrm

19:48 MenTaLguY: so the last thing I need to do here is if all of the targets for a particular label are nil, the resulting target should be nil, and not the empty set

19:48 jodaro: Can't set!: *ns* from non-binding thread

19:50 MenTaLguY: IOW (merge-nfa-edges {\c nil, \d #{2} :default #{3}} {\c nil, :default #{4}}) => {\c nil, \d #{2}, :default #{3 4}}

20:01 amalloy: thoughts on this approach? https://gist.github.com/1542110

20:02 amalloy: (if (empty? x) nil x) is (not-empty x)

20:03 MenTaLguY: great, thanks

20:03 amalloy: which means you no longer need the (let) either

20:04 TimMc: &(doc not-empty)

20:04 lazybot: ⇒ "([coll]); If coll is empty, returns nil, else coll"

20:04 TimMc: That's an odd one.

20:05 amalloy: TimMc: for when you want to (seq x) but without destroying its type

20:05 ie, test for emptiness

20:05 TimMc: sweet

20:06 MenTaLguY: this kind of case, basically, I want either nil or a non-empty set

20:17 amalloy: all right, I think I have something I feel better about now; thank you

21:18 lnostdal: i think i've asked about this before -- i've probably forgotten the answer .. but what's up with futures and exceptions? .. sometimes they "creep through" and sometimes they only show themselves when i deref the future

21:20 technomancy: they shouldn't ever escape the future thread until they're derefed

21:20 TimMc: lnostdal: Is something printing stack traces of intermediate exceptions?

21:20 lnostdal: ok, perhaps something is derefing them when printing the result

21:20 technomancy: though it could be derefed in surprising ways, like pr-str

21:21 lnostdal: ..or when showing a printed representation of the future object

21:21 right, ok, makes sense again then

21:22 ,(let [it (future (/ 42 0))] (Thread/sleep 100) it)

21:23 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.ArithmeticException: Divide by zero>

21:23 lnostdal: that'll fail every time .. i.e. not racy

21:23 (..not racing with :pending status..)

21:23 there are so many things that can go wrong .. heh

21:24 ..i don't think printing should "be the same" as dereffing here

21:24 ..because the proper handlers (catch blocks) aren't in place everywhere

22:14 jodaro: so

22:14 for better or worse

22:14 i have a function that uses in-ns

22:14 that function gets called by something else in a future

22:14 and that, apparently, doesn't work

22:15 giving me an illegalstateexception

22:15 with the error Can't set!: *ns* from non-binding thread

22:18 technomancy: wow, in-ns used inside a function?

22:18 amalloy: jodaro: it's pretty weird to be changing what namespace you're in at runtime

22:19 jodaro: yeah, i figured i was doing something wacky to begin with

22:19 it was working great in the unit tests

22:19 its all related to protocol buffers

22:20 trying to protobuf-load dynamically based on a string that has the protobuf type

22:20 using like

22:20 (deref (resolve (symbol protobuf-name)))

22:22 but i had to in-ns to the ns where i call defprotobuf

22:25 amalloy: i mean, it seems like something you can do at compile-time instead of runtime. but you can easily enough just do like...(binding [*ns* whatever] (...stuff...)) instead of using in-ns

22:27 emezeske: hmm, is there a standard way to force non-laziness like "doseq", but to still collect the results like "for" ?

22:28 or does one just have to use (doall (for ...)) to get that behavior?

22:53 chipdude: transient objects are marked alpha, but data.json uses them. is this OK because the transient doesn't escape the interface?

22:53 akhudek: emezeske: lookup doall

22:53 jodaro: amalloy: that works, thanks

22:53 technomancy: chipdude: transients crossing API boundaries would be super-sketchy even if they weren't alpha

22:54 chipdude: ok

22:54 that said, my question's answer is yes?

22:55 emezeske: akhudek: yeah, I saw doall; what I want is essentiall (doall (for ...))

22:55 akhudek: I just wondered if there was already a combo macro

22:55 akhudek: I just wrote my own called "dofor"

22:55 akhudek: you have the solution, there is no precanned macro or function

22:56 emezeske: cool, that's what I wanted to know, thanks

23:26 TimMc: technomancy: They *claim* to be alpha...

23:27 They've been there for two versions of clojure.core and they're recommended all over the place for performance-requiring stuff.

23:28 technomancy: heh; yeah I just realized promise/deliver is alpha and has been around even longer

23:35 amalloy: at least in 1.3 some of the alpha notifications have started going away

23:35 TimMc: amalloy: Which ones?

23:36 amalloy: juxt is the one i know about, but there are more

23:36 TimMc: Haha, juxt was "alpha"?

23:37 amalloy: as late as 1.2.1

23:37 TimMc: Maybe the vec vs. lazy seq decision was alpha, but there's no way it would have been removed.

23:39 emezeske: Wooo, my new lein plugin for compiling ClojureScript is done! http://github.com/emezeske/lein-cljsbuild

23:41 If you use cljs-watch or lein-clojurescript, you may want to check out lein-cljsbuild

23:50 fryguy: wow, nailgun with VimClojure is a pain in the ass

23:55 adiabatic: hi, I'm doing https://www.4clojure.com/problem/21 and I"ve been able to come up with (fn [coll index] ((first (drop index coll)))), but I'm getting a java.lang.ClassCastException saying that it can't cast a java.lang.Integer to a clojure.lang.IFn. My first guess is that I transposed the two arguments (I'm reimplementing nth), but everything looks OK. Can someone give me a hint as to where I messed up?

23:59 amalloy: too many parens

Logging service provided by n01se.net