#clojure log - Sep 20 2011

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

0:01 mindbender1: technomancy: there's a similar complaint here: http://groups.google.com/group/clojure/browse_thread/thread/22139531e3abc663

0:09 technomancy: sure, but no mention of contrib there

0:14 mindbender1: technomancy: thanks for you help but is there a way to uninstall and start afresh?

0:15 technomancy: see if it works on a fresh project from "lein new foo"

0:15 if you still have trouble there you could try removing ~/.lein

0:20 pushed a new swank-clojure snapshot to clojars that does alter-var-root on *out* so it all goes to the slime repl buffer even from threads

0:20 plz to try

0:21 icefox: In clojurescript is it not allowed to recur inside of a case statement ?

0:25 amalloy: icefox: it should be allowed, but it's possible that wasn't implemented. looking through the cljs source, i don't even see (case) being implemented anywhere; does it work?

0:26 icefox: case compiles, but if I put a recur inside of it produces a compiler error. Haven't honestly run it yet. Mostly fumbling around while putting off reading Programming Clojure :)

0:27 For example just dumped this into the hello.cljs sample http://rosettacode.org/wiki/Execute_Brain****#Clojure

0:30 technomancy: wow, storm is on the top watched of the month even though it's only been public a day.

2:32 mindbender1: how do i abort an REPL session in emacs

2:35 because I get : "Starting swank server...

2:35 error in process filter: Symbol's value as variable is void: Process [2 times]" when I try to reconnect after disconnecting with quit()

2:41 tomoj: quit()?

2:54 amalloy: hiredman, technomancy: at least one of you has some kind of scheduled-repeated-execution library, right? like, "do this every N seconds"?

2:59 die-giester looks like it's not going in exactly that direction

3:02 raek: amalloy: what about a ScheduledExecutorService?

3:02 amalloy: raek: yes, i'm writing the code to do that myself at the moment

3:02 but if someone can save me the trouble...

3:06 raek: (def exe Executors/newScheduledThreadPool) (.scheduleAtFixedRate exe #(println "hello") 1 TimeUnit/SECONDS)

3:07 I think that basic usage could be as simple as that

3:08 ...modulo errors in my example (the factory method takes an additional arg)

3:08 amalloy: raek: yes. i'm not really happy with that level of detail; i've written it so i can write (schedule-task #(println "hello") 1 :s), and it uses the namespace's threadpool

3:08 but of course it's not hugely burdensome either way

3:09 raek: I see. :)

3:10 amalloy: and it seems like the kind of simple wrapper someone would have written already

3:44 clgv: Where can I set the size of the history for "lein repl"? I think it must somehow pass it to rlwrap.

3:47 dbushenko: how is android? is clojure or clojurescript ready for android?

3:50 clgv: dbushenko: there was some talk on adjusted clojure for android. but you have to google for it.

3:50 dbushenko: thanks

3:57 michaelr525: hey

4:10 clgv: where in the leiningen source do I find the invocation of JLine or rlwrap? I didnt find anything when searching.

4:13 raek: clgv: it's probably in the lein shell script

4:14 clgv: raek: where do I find that one?

4:16 btw. thats one of the things that really needs to be documented

4:18 raek: https://github.com/technomancy/leiningen/blob/1.x/bin/lein

4:19 clgv: oh its not in the regular git repo`

4:25 terom: clgv: you could try something like set history-size 500 in ~/.inputrc (if rlwrap supports that)

4:27 clgv: terom: I can. but I dont know if that will work

4:30 terom: I have to find the history file it uses to check if that had an impact

4:43 terom: no it does not seem to work

4:44 terom: clgv: ah, too bad. Then you just probably have to hack lein script. Options for rlwrap are defined around line 218.

4:45 clgv: terom: hm yeah, but it'll get lost when performing an upgrade, I guess

4:47 terom: clgv: yes, probably. Maybe send a patch?

4:48 clgv: terom: then I would have to find out how to make it a general option for lein - it looks as if it cant be done via project.clj

4:49 terom: clgv: true, since it's before the invocation of JVM...

6:35 pauldoo: what's the syntax for specifying the type of a local in a let binding?

6:37 khaliG: pauldoo, #^type

6:37 pauldoo: (let [x #^java.lang.String "foobar"] .. )

6:37 ??

6:37 lazybot: pauldoo: Definitely not.

6:38 khaliG: (let [#^java.lang.String x ...] ..)

6:38 although in your example it's redundant cos the compiler can see its a string :P

6:39 pauldoo: khaliG: yes - it's an example

6:39 thanks

6:39 khaliG: np

6:43 pauldoo: hm - it doesn't fail if the type is incorrect

6:43 khaliG: yea it's a hint not a type check

6:43 pauldoo: ahh - ok

6:44 what's the idiomatic way to do a type check? (us a pre-condition?)

6:52 cfa: hi all

7:00 i have a style/idiom question re: macros -- is anyone around?

7:03 thorwil: cfa: don't ask to ask, just ask and you may see ;)

7:04 clgv: pauldoo: you can use instance? if you really have to. ##(doc instance?)

7:04 lazybot: ⇒ "([c x]); Evaluates x and tests if it is an instance of the class c. Returns true or false"

7:05 clgv: pauldoo: or 'cast if you want the check-and-fail behavior. ##(doc cast)

7:05 lazybot: ⇒ "([c x]); Throws a ClassCastException if x is not a c, else returns x."

7:07 cfa: thorwil: heh, okay

7:07 (wasn't sure whether anyone was around)

7:07 say i have something like this: http://pastebin.com/DPdeYGvZ

7:08 is this considered good practice? since i'm def'ing in the macro, i need to unquote 'dir' in the doseq

7:09 clgv: cfa: you can do that - but why dont you use defn?

7:10 cfa: clgv: i had that originally, was just messing around here

7:10 clgv: cfa: ok then better stick to defn. Rule #1 of the macro club, dont write a macro. Rule #2 dont. ;)

7:11 thats from "Programming Clojure" if I remember correctly.

7:11 cfa: ha ha

7:11 clgv: cfa: You should only use macros if you really need their features: deferred evaluation of params or code generation...

7:12 cfa: right

7:12 clgv: if you are just starting with clojure, then simply dont use macros now ;)

7:12 cfa: and since here my caller actually wants normal evaluation of the argument, macros are from the outset a bda idea?

7:12 clgv: i used to write quite a lot of (common) lisp

7:12 so i'm familiar with macros, though quite rusty

7:13 (sidenote: this example isn't for a "real project", it's just to dig into clojure's macro syntax)

7:13 clgv: cfa: I guess it's quite similar in CL with the suggestion to only use macros when your really need them

7:13 cfa: sure

7:14 clgv: if you want to learn about clojure macros it's usefull to use them in examples ;)

7:14 but your example looks like a poor defn replacement

7:14 cfa: let me rephrase the original question, then: if i were insane and decided to use a macro here, would my eval + syntax-quote approach be the sanest way of going about this?

7:14 clgv: yeah, for sure

7:15 (and i haven't overlooked your answer to my 'idiomatic' question, btw -- noted)

7:15 clgv: I guess I wouldnt use eval.

7:15 I would write another macro for the looping the just gets the seq '(north south east west)

7:16 s/the just/that just/

7:16 lazybot: <clgv> I would write another macro for the looping that just gets the seq '(north south east west)

7:19 clgv: the neat thing about that is that at compilation time the 4 forms are literally written there for the compiler since the macro expanded to those 4 forms

7:19 cfa: hmm, interesting

7:21 clgv: thanks for your help

7:31 clgv: cfa: np

9:40 cemerick: Hi everyone; I've set up a Clojure 'scholarship' fundraiser for ambrosebs, like what helped get Raynes to the Conj last year. Please help if you can: http://wp.me/p10OJi-aX

9:41 michaelr525: cemerick: how old is ambrosebs :)

9:41 ?

9:42 cemerick: michaelr525: No idea :-) Maybe he'll answer, but I'll bet he's not awake at this point.

9:42 ambrosebs: michaelr525: 21

9:42 :)

9:42 michaelr525: good for you :)

9:43 cemerick: ambrosebs: good evening! Here we go, huh?

9:43 ambrosebs: cemerick: phew, exciting!

9:45 i've got a test tomoz so i'll be around for a few hours yet :)

9:46 cemerick: well, focus on that for sure :-)

9:47 $3k is probably going to take a while, so don't spend time hitting refresh on the fundraiser status bar, etc.

9:48 michaelr525: cemerick: where are you located?

9:48 ambrosebs: :) I meant any more questions, just ask i'll be here

9:49 cemerick: michaelr525: at strange loop in St. Louis right now. Usually Western Massachusetts.

9:49 michaelr525: So what time is it?

9:51 cemerick: michaelr525: You mean where I am now? 8:53

9:51 michaelr525: oh

10:28 fhd: I'm not sure if I really want to do it (I.e. if it's the most elegant approach), but can I have instance variables with deftype?

10:28 The thing is, I'm working on an app that supports several database backends, and I'm using defprotocol and deftype for that

10:28 clgv: fhd: you mean mutable attributes?

10:28 fhd: However, some backends need to open a connection initially, e.g. fleetdb

10:28 clgv: Yeah

10:29 clgv: I'd basically like to put a (def) inside a (deftype) and only have it executed if that is instanciated

10:29 clgv: fhd: yes, you can have that#

10:29 fhd: clgv: I kind of need a constructor

10:29 stesla: Should proxies always have unique class names?

10:30 fhd: clgv: How? I guess I could turn that connection into an attribute and instantiate it when I instanciate that type, but it doesn't seem right

10:30 clgv: fhd: see ##(doc deftype)

10:30 lazybot: ⇒ "Macro ([name [& fields] & opts+specs]); Alpha - subject to change (deftype name [fields*] options* specs*) Currently there are no options. Each spec consists of a protocol or interface name followed by zero or more method bodies: protocol-or-interface-or-Object (m... https://gist.github.com/1229252

10:30 fhd: clgv: I read that, did I miss something?

10:31 clgv: you can declare fields mutable. but you could also use atoms or refs as values

10:31 fhd: clgv: Oh sorry, that's clojure-contrib deftype. I didn't check that

10:32 clgv: fhd: no clojure deftype is what I talked about

10:32 fhd: clgv: Sounds good, thanks

10:33 clgv: Hm, then I can't see how I can initialise a field

10:33 clgv: fhd: when constructing the deftype

10:34 you should have a construtor function for it

10:34 fhd: clgv: You mean like this? (MyType. (create-my-field))?

10:34 raek: fhd: the simplest way is probably to have a ref or an atom in an instance field. def will not work since it always defines a global ("static") variable

10:34 (deftype Foo [f]) (defn make-foo (Foo. (atom 0)))

10:35 clgv: fhd: like raek said^^

10:35 fhd: raek: Yeah, I considered passing the thing in. Was just wondering if I could move that logic into the devtype

10:35 raek: Because it seems cleaner to me

10:36 raek: But since that doesn't seem to be supported, I'll take the simple way. Thanks :)

10:37 For the record: clojure contrib has a deftype which supports an attribute map, so I guess I could do it like that. But I don't feel like confusing myself with a non-standard deftype

10:37 clgv: fhd: the factory function is fine. you shouldnt think too oop ;)

10:38 fhd: clgv: Yeah, following the KISS principle usually holds the OOP off :)

11:38 arohner: amalloy_: https://github.com/arohner/clojure-contrib/tree/1.3-compat

11:39 drewr: arohner: sweet

11:41 arohner: drewr: thanks

11:44 TimMc: shiny

11:45 theignorati: how do I split a string by (?

11:47 arohner: ,(doc clojure.string/split)

11:47 clojurebot: It's greek to me.

11:47 arohner: I'm useless without swank in front of me.

11:50 theignorati: I don't really want to write a regex though

11:51 why doesn't (.split "foo" "(") work?

11:51 arohner: theignorati: that calls java's method, which also takes a regex

11:52 theignorati: it works with other characters though

11:52 bhenry: ,(first (.split "?" "foo?bar"))

11:52 clojurebot: "?"

11:52 arohner: right, but ( is a special char in a regex, it defines a grouping

11:52 try \(

11:52 bhenry: ,(first (.split "foo?bar" "?"))

11:52 clojurebot: #<PatternSyntaxException java.util.regex.PatternSyntaxException: Dangling meta character '?' near index 0

11:52 ?

11:52 ^>

11:52 pdk: regexes have control chars that have to be escaped to be used literally

11:53 arohner: ,(.split "foo(?bar" "\\(")

11:53 clojurebot: #<String[] [Ljava.lang.String;@f353f9>

11:53 arohner: ,(seq (.split "foo(?bar" "\\("))

11:53 clojurebot: ("foo" "?bar")

11:53 theignorati: thanks :)

11:54 arohner: so \ escapes characters, like \n

11:54 but \( is not a legal escape, and you want to end up with "\(", so you have to do \\ to get a single \

11:58 TimMc: It is irritating that .split requires a regexp but doesn't allow a Pattern

11:58 so you have to do extra quoting in clojure

11:59 ,(seq (.split "foo(?bar" (str #"\(")))

11:59 clojurebot: ("foo" "?bar")

11:59 TimMc: ^ how to use regex literals anyway

12:02 Chousuke: isn't the str redundant

12:02 or does .split not take a Pattern argument at all

12:02 TimMc: ,(seq (.split "foo(?bar" #"\("))

12:02 clojurebot: #<ClassCastException java.lang.ClassCastException: java.util.regex.Pattern cannot be cast to java.lang.String>

12:02 Chousuke: hm :/

12:02 arohner: .split doesn't take a pattern at all

12:02 TimMc: There is no variant for it.

12:03 Java's core libraries are disappointingly sparse.

12:08 terom: ,(seq (.split #"\(" "foo(?bar"))

12:08 clojurebot: ("foo" "?bar")

12:16 arohner: has anyone gotten lein swank to run with clojure 1.3?

12:18 pandeiro: is there anywhere with examples using clojurescript's clojure.browser.net IConnection protocol?

12:23 choffstein: Anyone know if there is a way to get jetty (through ring) to just run on any port it can find above, say, 3000?

12:24 manutter: choffstein: there's always the brute force method (try/catch inside a loop)

12:24 choffstein: manutter: yeah, I was hoping for something a little…sexier :D

12:24 like I didn't know if jetty would automagically do it for me given a certain set of parameters

12:25 terom: choffstein: https://github.com/weavejester/lein-ring perhaps

12:25 choffstein: and then I could get the port by asking for a given attribute on the server object

12:27 manutter: I just googled "jetty 'first open port'" and got back "Full Text of 'Economic History of Manchuria'"

12:27 terom: :-D

12:27 manutter: not exactly what I was after...

12:29 stand1: manutter: Maybe you should read it, just to be sure.

12:29 manutter: I tell you what, it actually sounds a bit interesting

12:30 wink: maybe the first port in manchuria wasn't much more than a jetty...

12:30 manutter: indeed

12:31 It seems to be a scan/transcription of some book from "The Charles William Mason Collection on China and the Chinese," from the Cornell Univ. Library

12:31 I'll write some clojure code to parse the text for me and reduce it to a ring configuration.

12:35 choffstein: All I'm getting from google (besides Chinese coal exports in 1915) is a passing reference to setting the port to zero to mean "first available port"

12:35 choffstein: ah, I'll give that a try. thanks :)

12:35 manutter: which doesn't satisfy the "above 3000" part you were asking for, but it might be as close to "sexy" as you're going to get

12:37 TimMc: It will probably be above 3000.

12:37 The OS will pull a port from the "ad hoc" range.

12:38 "ephemeral port range"

12:40 If you're on Windows, maybe not.

12:51 choffstein: Well, 0 does the trick -- but retrieving the port seems trickier. When I request it back, I get 0 :D

12:51 That's….less than helpful

12:52 Ah, figured it out. getPort, getLocalPort … what's the difference :D

13:11 duck1123: Are there any functions / libraries that will recursively merge two hashes. (ie. if the value is a key, one is used, if it's a hash, they're merged, and if it's a seq, they're catted together)

13:12 I can write one myself, but it sounds like something that others might have done

13:13 I meant if the value is a string / number / some other object, then one wins

13:15 altsrid: has anyone implemented in-process message queues in clojure, with multiple producers and single consumer? i am looking for simpler alternatives to having the overhead of an external queue (e.g.: rabbitmq, redis)

13:15 duck1123: lamina

13:16 antares_: _srid: zeromq can be used for very efficient in-proc communication as well

13:16 _srid: i was inadvertently implementing such a thing myself yesterday using agents and had to bail out due to inability to synchronously 'pop' from an agent queue.

13:17 by 'overhead' i mean development time, not so much cpu time :)

13:17 clojurebot: multimethods is what separates the boys from the men.

13:17 * _srid reads about lamina

13:17 _srid: who was clojurebot responding to?

13:17 duck1123: antares_: if you have a handler on a zeromq queue, in which thread is the handler run?

13:18 in lamina, the enqueing thread runs the handler, (from which you can pass that to a different thread)

13:19 antares_: duck1123: I am not sure

13:23 _srid: duck1123 have you used lamina in your projects?

13:24 lamina's wiki says "if we allow multiple threads to publish events, our event stream is no longer ordered" - but what about the ordering of events from one thread (among many)? are they out of order as well?

13:24 in my case, each publisher is tail'ing a log file from a server.

13:24 i don't care about ordering of the logs from *different* sources, but the ordering of logs from a *single* source should be the same as publishing order

13:25 duck1123: if you publish to a lamina channel, they should come back out in the same order

13:25 I use both Lamina and the server component (Aleph) in my apps

13:27 _srid: duck1123 - what does aleph actually doing? the README is not very clear.

13:27 s/doing/do/

13:27 lazybot: <_srid> duck1123 - what does aleph actually do? the README is not very clear.

13:28 duck1123: Aleph is a wrapper for Netty. So you can build web apps where you can send the response from a different thread as the request comes in on

13:28 it also has an async http and redis client

13:29 zippy314: aleph is pretty cool. It's also built on top of lamina, which is a channels based async communication library.

13:29 _srid: i eventually want to process these log records, analyze them and host their 'stats' as a web app. would aleph help with that?

13:29 duck1123: Just the other day I posted about wanting to make a logger appender that posted to a lamina queue so that I could do fun things with it like sending it over a websocket connection

13:30 _srid: think of multiple instances of an app running in various EC2 instances, and you are analyzing their logs, consolidating them and providing an unified stats interface to the user (via web browser).

13:30 zippy314: Does anybody know what's going on with clojurescript keywords? It appears that if you do (str :somekeyword) it returns a string with some odd non-ascii characters on the front that cause javascript to be very confused.

13:31 duck1123: _srid: Unless you can thing of a case where you want to perform work across different threads, you could probably get away with just using jetty. Thankfully, it's really easy to convert a normal Compojure/Ring app to Aleph

13:33 TallAdam: hello everyone in Clojure-land: does anyone know how to get my logging output to print to my repl, as opposed to into thin air (where its currently going). I'm using swank-clojure in emacs

13:36 duck1123: _srid: If you do checkout Lamina/Aleph/Gloss and you're using 1.3 and you run into problems, I've been maintaining 1.3 compatibility in my fork

13:38 thorwil: i guess there's no alternative to the :as in a fn signature like [{:keys [foo bar] :as all}] that would bind a map with only the selected keys?

13:39 TimMc: TallAdam: What are you logging with?

13:39 _srid: duck1123 - thanks, I use 1.2. i am going to replace my incorrect agent-based queue implementation with a lamina based one.

13:39 TallAdam: TinMc: clojure.contrib.logging

13:40 _srid: now, tools.logging, I guess

13:40 ,where did contrib go?

13:40 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: where in this context, compiling:(NO_SOURCE_PATH:0)>

13:40 _srid: hmm

13:40 duck1123: _srid: what part of contrib are you looking for?

13:41 TimMc: TallAdam: Logging in the Java ecosystem is really irritating. I think clojure.contrib.logging pipes it all through to whatever logger you have on the classpath. Are you using log4j?

13:42 TallAdam: TimMc: I think so

13:48 alternatively, when using swank-clojure in emacs, how do I get a console buffer up (I assume my logging output is going there). I am using clojure-jack-in

13:49 duck1123: I thought that was what you had to give up by using clojure-jack-in?

13:50 _srid: duck1123 - in lamina, (enqueue …) blocks until all receive handlers complete running, correct?

13:50 TallAdam: duck1123: really?

13:50 _srid: and, does the receive handlers run in the same thread as the caller of (enqueue)?

13:51 duck1123: Yes, but you just make the handlers run with async

13:51 It's an annoyance, I agree

13:52 _srid: duck1123 in my case, (enqueue) will be called from the 'worker' thread (each worker thread tail'ing a log file from a server).

13:52 .. unless there is a way lamina can abstract the worker threads

13:53 duck1123: hey, if you're doing "workers" feel free to check out my Ciste library

13:53 I'm doing similar stuff

13:54 https://github.com/duck1123/ciste/blob/master/src/ciste/workers.clj

13:54 TimMc: TallAdam: Are you sure log4j isn't just suppressing all your log messages? I've had a devil of a time trying to get log4j.properties just right.

13:55 _srid: ok. duck1123 - so lamina doesn't spawn threads at all? it does everything in the same thread?

13:55 TallAdam: TimMc: don't think so - am using the standard console appender

13:55 duck1123: _srid: no, it leave it to you to spawn the threads as needed

13:57 raek: TallAdam: have you looked at the top of the *swank* buffer?

13:58 chewbranca: /j# emacs

13:58 bah

13:58 TallAdam: raek: bees - there it is

13:58 bees = jees

13:59 raek: what it doing there? can I nuke the rest of the stuff in that buffer?

14:00 duck1123: That's why I prefer to have a real console running in a screen session

14:00 raek: dunno

14:01 TallAdam: raek: thanks a bunch :)

14:01 nkoza: lamina is like python twisted?

14:04 duck1123: does twisted have the http part, or is it just messaging and async?

14:10 schlechtv: In ClojureScript master as of today: when I start a browser repl env, I get a prompt straight away, without waiting for a connection. Regardless of whether a browser connected or not, it then hangs at evaluating anything. Any ideas? Anyone got the browser repl working on master?

14:20 _srid: duck1123 - lamina, in conjunction with future, turns out to do what I needed

14:23 pandeiro: When using Leiningen, is there a way to simply run `clj core.clj' and have the right classpaths? I am doing some basic webserver tutorials and I can't get them to work outside of the lein repl because of classpath

14:24 schlechtv: I have the Browser REPL working, and it always shows the Server on port 9000 message before the ClojureScript:user> prompt

14:26 schlechtv: pandeiro, so it doesn't wait for the client to connect?

14:26 pandeiro, when you do a netstat, does it show the connecting ESTABLISHED?

14:26 pandeiro: it will show the prompt without a browser even being open, yes, but eval will just hang if that's the case

14:27 schlechtv: pandeiro, ok, so then that's just a glitch in the docs (they say the prompt should only come once a browser is connected)

14:27 pandeiro: it appears regardless, yes, in my exp

14:30 schlechtv: pandeiro, and the TCP connection between browser and repl is kept alive?

14:30 pandeiro: yes once the browser is started and the connection is made

14:32 schlechtv: strange... mine goes straight to TIME_WAIT

14:45 TimMc: pandeiro: Regarding lein, I don't think so. How would it know which clojure.core (and maybe contrib) version to use?

14:48 However, it might be nice to be able to invoke `lein path/to/file.clj` from within a project and have everything work.

14:56 pandeiro: TimMc: i am new so bear with me... I see some examples and I don't know how I am supposed to run them... eg https://gist.github.com/585921 (a basic ring example)

14:57 _srid: why is there no "def-"?

15:02 schlechtv: pandeiro, that example as it is, will only run from a repl of sorts

15:03 pandeiro: yeah i don't even understand how it would be invoked at the repl, in-ns or something?

15:03 schlechtv: pandeiro, no, copy & paste :-)

15:04 or if you have it in your classpath, type (ns ring.example.hello-world-2)

15:05 pandeiro: ok so if it were in a file, just ns'ing it would invoke that server function at the bottom?

15:06 schlechtv: pandeiro, sorry, you'd need (require), not (ns) ... and yeah, I guess require'ing would, unless someone here proves me wrong

15:06 pandeiro: ah ok, thanks

15:20 theignorati: hey I was benchmarking my compojure site and I found out 80/2434 requests fail because a function that uses SimpleDateFormatter fails. The page loads a file from disk and parses it. The file doesn't change, nothing is dynamic, any ideas how this happens and/or how to solve it?

15:21 tomoj: they're not threadsafe, could that be it?

15:25 theignorati: yeah thanks!

15:28 pauldoo: I have a sorted-set of vector-tuples of strings.. E.g. (sorted-set ["a" "a"] ["a" "zzz"] ["b" ""]). How can I use subseq to find all entries which begin with a given string, say "a".. ? I imagine (subseq coll >= ["a" ""]) would find where the interesting elements start..

15:28 but what is the end test ?

15:38 _srid: is it possible to update an incanter 'view' in realtime (via code, not UI)?

15:40 joegallo: pauldoo: (subseq s >= ["a" ""] <= ["b" ""]) seems to work here

15:41 pauldoo: this reads better to me, though, it is probably less efficient (filter #(= "a" (first %)) s)

15:41 pauldoo: joegallo: but in general "a" will be a more complicated string, say "monkey"

15:41 , so how would I figure out the stop string in that case..?? "monkez" ?

15:41 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: so in this context, compiling:(NO_SOURCE_PATH:0)>

15:42 pauldoo: I'm thinking an easier way will be to append the null character to the "a" string...

15:42 (subseq t >= ["a" ""] < [(append-null "a") ""])

15:48 fliebel: I'm running the Ring Jetty adapter, and it gives a 500, but does not show any stacktrace. What to do?

15:49 theignorati: I'm running the ab benchmark tool against my compojure app the first 3 times it keeps getting better results, how do I replicate this effect in production?

15:50 fliebel: theignorati: What do you want in production? I think the improvement is due to Java optimizing stuff.

15:50 theignorati: I want it to immediately be that fast :*

15:51 I don't really want to run a benchmark tool against production to warm up the jvm

15:51 fliebel: theignorati: The thing is, JIT can only do its most powerful optimizations by analyzing the runtime performance.

15:52 So you can lower the JIT barrier with some JVM opt, but 'warming up' is really the only way to go afaik.

15:53 Chousuke: theignorati: if the app will be running for a long time, you'll get nice performance eventually

15:53 it's a bit difficult to predict exactly how fast your code will become though

15:53 Providing you don't make any obvious algorithmic blunders :P

15:54 theignorati: eventually could be a long time considering the difference between 'cold' and warmed up jvm is more than a second

15:54 no opts though

15:55 Chousuke: theignorati: if the app will be running for more than 5 minutes you'll surely get the boosts :P

15:55 theignorati: wont I need visitors though

15:55 I don't get that many on this site

15:56 Chousuke: not really

15:56 if you don't get much visitors then slower code will do just fine

15:56 theignorati: no

15:56 speed is a major feature

15:56 Chousuke: you don't understand

15:56 once the JVM notices it's actually doing work, it will start optimizing

15:57 and until you do work, you don't even need the speed

15:57 hugod: or write some post deploy verification tests for your site, that also warm up your site…

15:57 theignorati: ok

15:57 Chousuke: usually the most important factor to speed will be your algorithms anyway.

15:57 theignorati: hugod: that's what I was considering, was hoping there was a better way but I guess this that will do

15:58 Chousuke: the JIT will optimise memory allocation and other things but it can't turn an O(n^2) algorithm into something sane :P

15:59 theignorati: well I'm parsing a horribly formatted page with Enlive and string splitting, not a lot of algorithms involved

16:31 pandeiro: is there anywhere with examples for using ClojureScript's clojure.browser.net IConnection protocol?

16:40 scottj: maybe the browser repl

16:43 pandeiro: scottj: yah problem is i don't grok the IProtocol syntax or how to call the methods it adds on to Closure's XhrIo

16:44 when I inspect the XhrIo object I see clojure.browser.net adds on some namespaced methods like $clojure$browser$net$transmit but i imagine that can't be the way to call them

16:46 scottj: pandeiro: I haven't seen any open sourced projects that use it

16:48 _srid: duck1123 - in regards to aleph, is there a library that makes writing websocket clojure apps even easier?

16:51 duck1123: I got websockets working with jquery, but I recently re-wrote all of my script in clojurescript, and I've yet to get that part working again

16:52 Closure has a Websocket class, but it's not in the latest release yet

16:52 kzar: I'm learning how to use Enlive and I'm a little unsure what to make as templates and what to generate with Hiccup. Say I'm doing a personal webpage that includes an about page, a portfolio and a blog. Would you have three seperate template html files that pretty much look as the sections will look, duplicating the generic parts of the layout in each? Or would you have one template file, called something like layout.h

16:52 tml that just contains the part of the layout that's constant and generate the rest with Hiccup? Alternatively I figured I could make a layout.html and have three additional templates, each containing the page specific layout.

16:54 duck1123: I would have the layout template accept params for each of the sections, and then generate those sections with a different template

16:54 That's basically how I do it, at least

16:56 kzar: duck1123: OK, yea makes sense to me

17:48 amalloy: _srid: http://groups.google.com/group/clojure/browse_thread/thread/affca6fa1e777f51

17:55 _srid: I have a lazyseq like this [a1, b1, b2, c1, d1, a2 …]. ?1 is "start" event, and ?2 is "end" event. i want to process this seq (remember, its lazy) into [(a1, nil), (b1, nil), (b1, b2), .. (a1, a2)]. what is the best way to achieve this?

17:55 "map with memory"?

18:00 tomoj: much easier to answer if you show actual clojure data

18:00 I'm thinking map + reductions but I don't really understand what you want

18:01 mdeboard: Anyone here integrating Solr & Clojure?

18:01 Oh well lookee here

18:01 https://github.com/mikejs/clojure-solr

18:01 _srid: tomoj lazy seq of 'events' as they happen. events can be of two type 'start FOO' and 'end FOO' and I want to group the events into ranges (start, end) for each FOO.

18:02 events can be interleaved

18:02 [start-a, start-b, end-a, start-c, end-b] => [(start-a, nil), (start-b, end-b), (start-c, nil)] (at the point of realizing 'end-b')

18:03 only calculate for last N events in the seq.

18:03 well, I suppose then I can simply cache the realizations and directly work on them. duh.

18:07 Chousuke: _srid: couldn't you make a map?

18:07 _srid: Chousuke - not sure how you would 'map' the above sequence to produce the one after =>

18:08 may reduce will work

18:09 Chousuke: when you get a start event, conj a nil with that event as the key. then later conj the end event

18:09 hm, I guess that's not very easy to do since you need to find the start event somehow :/

18:10 well I guess the FOO could act as a key too.

18:10 if it's unique

18:12 oh well, I need to go to sleep :P good night

18:14 _srid: Chousuke - yea, which is why reduce would probably work as I can feed the result back to f

18:14 amalloy: wow, i'm surprised. ##(keyword 1) is nil? not :1, or even an exception? that seems cruel

18:14 lazybot: ⇒ nil

18:21 _srid: what is the reason for wrapping variables with STAR? e.g.: (def *something* 42). is it a convention for global variables?

18:21 amalloy: $google clojure earmuffs

18:21 lazybot: [Conventions, Style, and Usage for Clojure Constants? - Stack ...] http://stackoverflow.com/questions/3579063/conventions-style-and-usage-for-clojure-constants

18:22 amalloy: _srid: ^

18:22 _srid: "ear muffs", heh.

18:29 hmm, looks like clojure re has no named group support. java6 doesn't either.

18:36 amalloy: $google cgrand regex

18:36 lazybot: [Milestones - cgrand/regex - GitHub] https://github.com/cgrand/regex/issues/milestones

18:36 mdeboard: I have a really oblique question that I swear is relevant to the channel: Anyone here familiar with Django Haystack?

18:37 amalloy: mdeboard: i'm tempted to bust out ~anyone, but i'm curious where you're going, here

18:38 mdeboard: amalloy: I'm implementing Haystack at work, which is Django's most ubiquitous search plugin, fronting a Solr backend. Just wondering if there would be any performance gains switching rebuilding & updating the index from Haystack to straight-up Clojure (since Solr does run on the JVM after all)

18:40 amalloy: see, i have no idea how to answer your question, but i tricked you into actually asking it, so that perhaps someone else will answer :)

18:41 mdeboard: You crafty devil

18:41 brehaut: isnt all the heavily lifting in that a) the DB b) solr, with haystack just acting as the go between glue ?

18:41 mdeboard: brehaut: Yeah it's just Python -> Solr bindings

18:42 BUT

18:42 Haystack does a lot of abstraction, and it's tied to the Django ORM

18:42 So it can be extremely slow

18:42 afaik, anyway.

18:45 tomoj: _srid: I meant that (a,b) isn't clojure and start-a/start-b etc is opaque

18:46 _srid: tomoj start-a = {:name a, :type "start"}

18:47 tomoj: that's better. I'm going home, though. sorry :)

18:50 mdeboard: I guess there wouldn't be any real gain since I can already use multiprocessing to run multiple concurrent tasks

18:50 though I bet there are higher-level advantages that I'm not experienced enough to see.

18:51 brehaut: mdeboard: the answer to your question is, nobody knows your code so use your own profiler

18:51 mdeboard: brehaut: I don't really have a question, just blabbering.

19:06 nerooth: I have a (if my-test (do (x) (y) (z)) do-smt-else), when my-test=true it only executes z. How can I get it to execute x, y, and z?

19:07 Looks like I misunderstood the do function. What is the function I'm looking for called?

19:09 To clarify: x, y and z are html snippets (field generators) that I want to be rendered in html.

19:14 _srid: using atoms for the first time, I hope swapping large data structures is a O(1) operation.

19:14 arohner: nerooth: (do) returns the value of the last expression evaluated

19:14 since you want to return the value of x,y,z, put them in a list

19:14 do (list (x) (y) (z))

19:15 nerooth: Ah, neat. Thanks.

19:15 arohner: and it has to be a list, because hiccup interprets a vector as a single html tag

19:15 nerooth: Would (do (html x y z)) work as well?

19:16 arohner: maybe

19:16 are (x) (y) returning "unevaluated hiccup", or strings?

19:16 i.e. are they calling hiccup themselves?

19:17 nerooth: no, they are partials

19:18 as in, they return a string with html code

19:32 ibdknox: nerooth: (html) will work fine in either case, and I think is clearer

19:32 nerooth: it's typically what I use

19:40 nerooth: ibdknox: Alright, will use that. Nice to see the creator of Noir here :)

19:41 ibdknox: I'm usually around more but have had a lot of stuff going on lately, so I've been a bit scarce :)

19:41 _srid: ibdknox while you are here, may I ask what the best way is to go about writing websocket-like apps in clojure? (I just want to push some things from server to browser)

19:42 ibdknox: _srid: how much do you care about fallbacks?

19:42 _srid: what are 'fallbacks'/

19:42 s///?/

19:43 ibdknox: when a browser doesn't support websockets

19:43 _srid: s/\//?/

19:43 ibdknox: you could fall back to polling, htmlfile, etc etc

19:43 _srid: ibdknox - i don't care if it doesn't work IE, for instance. it will be an internal for now. assume firefox or chrome

19:43 ibdknox: _srid: just use aleph then :)

19:44 _srid: the first time i looked alpha, things looked twisted to me. i'll take another, but patient, look.

19:44 ibdknox: _srid: if performance or fallbacks become important, you'll want something like socket.io

19:44 _srid: i hate osx auto spell correction

19:44 i thought socket.io is nodeJS specific?

19:44 ibdknox: _srid: I have a netty version of socket.io, but it's getting a bit out of date

19:44 _srid: typewire.io is built on it

19:45 _srid: generally I want to go via the least resistant route, as the 'web part' is only a minor part of the overall app.

19:45 * _srid takes another look at aleph

19:46 ibdknox: _srid: that'll be the easiest route :)

19:47 _srid: i already use lamina in the backend, btw

19:48 .. prior to which I used to hack around agents in futility.

19:48 ibdknox: haha

19:51 carllerche: What's the idiomatic way to handle specific exceptions in clojure (since it seems difficult to create custom exception subclasses)?

20:08 scgilardi: there's been a lot of discussion about that. here's some of it: http://dev.clojure.org/display/design/Error+Handling . you might get some use out of http://github.com/scgilardi/slingshot .

20:15 _srid: aleph is broken. cannot find lamina.trace -- https://gist.github.com/1230803

20:17 .. fixed by upgrading lamina to beta (clojure needs a correct package dependency management system)

20:26 tomoj: _srid: don't specify lamina directly and you'll get the one aleph says it needs

20:37 _srid: duck1123 - distributed social network in clojure? :-)

20:59 duck1123: Yeah, basically it an OStatus compatible microblog

21:00 I originally started it as a implementation of the OneSocialWeb protocol

21:21 technomancy: hmm... clojars should reject uploads that contain unresolvable deps

21:21 (y/n)

21:45 ambrosebs: dnolen: Have we cut a release to core.match? what's the new leiningen string?

21:46 dnolen: we have not, now that I'm done w/ Strange Loop I'll some head space for closing the bigger bugs.

21:46 ambrosebs: is there a SNAPSHOT for core.logic?

21:47 how did the mapping dilemma go?

21:47 dnolen: it always SNAPSHOT in the project, I use hudson to cut a release.

21:47 ambrosebs: the readme is a bit out of date, that's all. been getting msgs

21:48 links to wrong snapshot

21:48 dnolen: mapping dilemma went great! seemed like a lot of people in the audience (close to 200?)

21:48 ambrosebs: wicked!

21:49 dnolen: Sussman was cheering me on I heard :)

21:49 ambrosebs: problems in the readme we should just fix right away, no need for release.

21:50 ambrosebs: dnolen: I tried to add a suggestion for usage, via (use '[clojure.core.match :only [match]]) , but then realized the leningen string still points to the old release

21:51 so that's the only issue atm

21:51 dnolen: maaaaaan did you get to talk with Sussman?

21:52 dnolen: sadly didn't get a chance too, was awesome to see him everywhere tho.

21:54 got a chance to talk / listen on a lot of cool conversations - had dinner w/ Allen Wirfs-Brock and talked on the finer points of JS / Smalltalk. Listened to Erik Meier defend dynamic typing (!)

21:54 all around an incredible conference

21:55 ambrosebs: I don't know how you'd top that

21:55 amazing

21:57 dnolen: ambrosebs: oh you mean the version on Clojars is old?

21:57 ambrosebs: apparently

21:57 which makes sense, since the artifact id would have changed

21:57 probably org.clojure/core.match or something

22:00 dnolen: latest match pushed to clojars

22:01 ambrosebs: same leiningen string?

22:06 dnolen: any another appearances of logic programming at strangeloop?

22:06 well, any at all?

22:07 dnolen: ambrosebs: yeah just match for now. gonna try to prioritize match so we can cut an official release ASAP.

22:07 ambrosebs: sussman preso was basically art of the propagator which is very much about logic programming - constraint logic programming.

22:07 rhickey gave an amazing presentation and of course he plugged the logic programming approach as well.

22:09 ambrosebs: well, two keynotes will do :P Def have to check them out ...

22:16 dnolen: update on core.logic + fresh ?

22:18 dnolen: ambrosebs: I have 2 high priority todos: 1) core.logic exist -> fresh 2) core.match backtracking, will probably get started on them tomorrow.

22:19 ambrosebs: good to know

22:36 st3fan: hmm is there a way to filter and modify? i need to select a bunch of maps from a list and add a value that i use for the filtering

22:36 i don't want to filter and then run the operation again

22:37 symbole: Is there a way to do automatic importing in clojure-mode? Hitting some key would create appropriate :import declaration in the namespace.

22:41 st3fan: i would like some combination of map and filter i think

22:41 * st3fan will hack something up

22:42 symbole: st3fan: Doesn't "for" provide filtering capabilities? So you can exclude things in the generate sequence.

22:52 st3fan: let me check for

22:53 technomancy: symbole: slamhound does that

22:54 with a few caveats

22:56 symbole: technomancy: I'll give it a wirl.

22:56 st3fan: oh for is nice!

23:14 simard: I have a function drawline that knows how to use a function *transform* to transform its points before the drawing actually gets done. before calling it, I do a binding on *transform*. now I want to define a polygon out of lines and later use it along with a transform, how can I do that ? ie.: how do I post-pone the execution of drawline until the right moment ?

23:15 I'd like to get that data is code thing right, but I don't see how to do it correctly

23:17 tomoj: you'd probably have more luck showing some code. that doesn't make any sense to me, at least.

23:17 brehaut: i second tomoj

23:18 simard: ok :)

23:24 http://pastebin.com/ejh8tX00

23:24 that's what I was talking about

23:24 it's working fine right now.. but I'm not sure that's as good as it gets

23:28 tomoj: don't understand the question about postponing execution in that context

23:28 simard: yeah it doesn't make any sense does it

23:29 the key is I was thinking about def'ining data structures

23:29 instead of using defn (functions)

23:32 tomoj: one thing I would suggest is not to println this stuff

23:32 simard: I'm listening

23:32 what would you do ?

23:34 tomoj: well, hmm. just looking at gerber-linear-interpolation, simply removing the println makes the function look OK to me. then you have to do the rendering differently, though, and not sure what to tell you about that

23:36 it might also return something like {:type :linear-interpolation :x .. :y .. :exposure ..}, to be rendered by another function (and maybe eventually replaced with a deftype and corresponding GerberRenderable or whatever protocol but not until that looks useful..)

23:38 simard: hum centralizing the rendering function sounds neat

23:38 tomoj: a 'gerber' function with [& args] might take each arg, call 'render' on it, and return a seq of lines

23:38 generally you want to isolate the side-effects like printing to the smallest part of the code as possible, and make everything else just pure function calls returning data

23:39 simard: yes I'm aware I was breaking that rule but I wasn't sure how to fix it

23:39 in the end, the idea is that I'd like to create an object from a series of function calls, and then instanciate that object again later.. a bit like it's possible to do with an opengl display list

23:39 so using your approach would work find

23:39 fine*

23:40 ie, I could def'ine a shape as a list of {:type ...}

23:40 tomoj: it also occurs to me that transformations could be applied to data like {:type :linear-interpolation ...} directly (possibly leading to a Transformable protocol or some such)

23:40 simard: and even transform it as much as I want, and in the end, render it

23:40 tomoj: yeah

23:40 simard: what are protocols ?

23:41 are they some clojure idiom ?

23:41 or a more general programming concept ?

23:41 brehaut: simard: http://clojure.org/protocols

23:42 tomoj: I wouldn't bother with them yet though, best to start with just maps, especially if you're new to protocols/clojure

23:42 simard: alright, I'll bookmark that .. :)

23:43 but I'll read it tonight anyway, I can't think much more so I won't write good code.

23:43 thanks for the tips

23:44 tomoj: you may find multimethods useful sooner

23:44 e.g. render as a multimethod dispatching on :type

23:45 simard: neat

23:47 tomoj: btw, the 'gerber' function I described above would be just (defn gerber [& shapes] (map render shapes)) :D

23:48 simard: I love this language

23:48 :)

23:51 tomoj: I suppose render could also have a method for seqs so you just get (render shapes)..

23:51 eh

23:52 simard: one day I will use my own PCB editor written in Clojure :D

Logging service provided by n01se.net