#clojure log - Aug 12 2011

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

2:19 leo2007: why starting swank takes such a long time?

2:19 Or is the load time high in all clojure apps?

2:49 lucca: leo2007: jvm startup

2:50 leo2007: ok, but abcl loads much faster.

2:54 amalloy: leo2007: abcl is not on the jvm. there are a lot of upsides to being on it; slow startup is a downside

2:55 leo2007: sorry I am unfamiliar with the jvm. How to define 'on the jvm'?

2:59 amalloy: $google java virtual machine

2:59 lazybot: [Download Free Java Software] http://www.java.com/en/download/

2:59 amalloy: you get to plug into java libraries, run anywhere that java runs with no extra installation overhead or cross-compilation

3:48 leo2007: How to convert any object to string? (format "%s" ...)

4:00 amalloy: &(doc str)

4:00 lazybot: ⇒ "([] [x] [x & ys]); With no args, returns the empty string. With one arg x, returns x.toString(). (str nil) returns the empty string. With more than one arg, returns the concatenation of the str values of the args."

4:02 depywork: ,(str #{1 2 3})

4:02 clojurebot: "#{1 2 3}"

4:02 depywork: nice :)

4:05 pyr: when you end up pulling in most classes from a package, is there an equivalent to import some.package.* ?

4:07 zoldar: pyr: if you are talking about clojure namespace then it's (use 'some.namespace)

4:08 pyr: nope, about java packages

4:09 when working with java libs

4:09 you often end up with

4:09 (:import [some.java.package Class1 SomeOtherClass YetAnotherClass ...])

4:10 zoldar: afaik there's no such possibility - from what I've seen, it's a design decision\

4:11 pyr: ok

4:11 leo2007: depywork: thanks

4:11 ,(format "%s" #{1 2 3})

4:11 clojurebot: "#{1 2 3}"

4:20 leo2007: Any offline docs?

4:21 pyr: ,(= {} (read-string (str {})))

4:21 clojurebot: true

4:21 pyr: leo2007: str and read-string are very useful everywhere in clojure :)

4:24 leo2007: you can pull the api docs or rebuild them if you want to (with autodoc) or get a good book

4:29 amalloy: pyr: yikes, don't combine str and read-string

4:29 &(= "test" (read-string (str "test")))

4:29 lazybot: ⇒ false

4:38 amalloy: (for those following along at home, the safe way would have been ##(= "test" (read-string (pr-str "test"))))

4:38 lazybot: ⇒ true

4:43 pyr: amalloy: thanks!

4:47 depywork: what's the difference between pr-str and str?

4:48 &(doc pr-str)

4:48 lazybot: ⇒ "([& xs]); pr to a string, returning it"

4:59 amalloy: &((juxt str pr-str) "str" "pr-str")

4:59 lazybot: ⇒ ["strpr-str" "\"str\" \"pr-str\""]

5:10 raek: depywork: pr-str serializes a clojure data structure to a string. str concatenates its arguments after calling .toString on them. a string foo"bar becomes foo"bar with str, but "foo\"bar" with pr-str.

5:38 pyr: sometimes paredit makes me crazy

6:10 depywork: raek: tnx.. all clear now :)

6:14 fliebel_: Has anyone managed to get clojure-protobuf working on Mac?

6:16 https://github.com/flatland/clojure-protobuf/issues/8

6:27 triyo: I'm trying remember how to do this... I want to create a multimethod that dispatches on first argument of type keyword. Second argument is a string to be passed in to the defmethod. So I want to be able to do something like this... (convert :int "123") or (convert :date "2011-08-12")

6:42 clgv: hello, are protocoll methods related to multimethods? or even implemented via multimethods?

6:43 fliebel_: clgv: I don't think so. A protocol is just a map of functions, afaik.

6:44 clgv: fliebel_: did you write parallel programs in clojure yet?

6:44 the-kenny: I think multimethods are too slow for implementing protocol methods.

6:44 fliebel_: clgv: What do you mean?

6:46 clgv: fliebel_: I noticed that multimethods seem to have some locking since I got problems with the functions from clojure.contrib.math that are implemented via multimethods when using them really frequently in code that was run on 10 cores in parallel

6:46 triyo: Protocols are definitely not multi-methods

6:46 clgv: ok. might the protocol method implementation do some locking?

6:47 triyo: As far as I recall they are based on java interfaces, but are ore flexible.

6:47 *ore=more

6:47 clgv: yeah they generate a java interface

6:48 but if you are using the methods like: (method1 obj ...) then this is not a direct call to the interface. but what is it exactly?

6:48 triyo: what kind of locking are you referring to?

6:48 I think its more like a reflective dispatch, hence slower

6:48 clgv: the one that ruins scaling on multiple cores although there is the same algorithm running completely independent but in the same vm

6:50 when dividing parallel average run times by serial average run times I get a quotient of about 2.4

6:52 ah when running on 24 threads

6:54 I'll do a measurement with fewer threads just to be sure it's not the virtual HT Threads slowing down

8:10 lnostdal: does something like in-transaction? exist?

8:14 hm, i actually bind some other dynamic global at the same time i wrap my top-level functions in a sync so i can use that to check

8:19 clgv: lnostdal: what code does have to know whether it is executed within a transaction?

8:20 lnostdal: code which might "come from" the repl

8:20 ..stuff evaled from the repl doesn't run in a sync because it doesn't need to .. in addition it doesn't change any globals based on this

8:21 clgv: why is it not within a transaction when it comes from the repl although it needs a transaction?

8:21 lnostdal: it doesn't

8:21 clgv: why does it need a transaction when it was NOT launched from the repl?

8:22 I mean if you are using clojures STM, i.e. you do use refs, then you always do need a dosync-transaction

8:24 lnostdal: i'm not using refs, anyway, when testing this in the repl

8:24 ..i.e. it doesn't talk with session related stuff

8:25 i guess i could modify the slime repl loop or something, just in case .. it might want to touch some refs later for all i know

8:25 (add a sync wrapper to the repl)

8:25 ..but dunno yet

8:47 solussd: is there a 'for side-effects' version of pmap (e.g. like doseq is to for)?

8:47 depywork: :Q

8:52 sry, typo

9:03 tufflax: Hm I'm using proxy to create an instance of an interface. But I'm trying to define some more methods that are not part of the interface, and it doesn't seem to work all that well. Is that not possible?

9:03 clgv: lnostdal: sounds a bit strange

9:03 stuartsierra: tufflax: nope

9:04 tufflax: hm, so what if I want to :(

9:04 joegallo: stop wanting that :)

9:04 MasseR: tufflax: AFAIK you can't have any extra methods with a proxy. You need to use :gen-class

9:04 clgv: waits for cemerick's chart to be posted ;)

9:04 stuartsierra: Tufflax: define a protocol with the methods you want and use `reify`

9:04 joegallo: clgv: just pulling that up now!

9:05 tufflax: It's a java interface I'm trying to proxy, can I like extend that interface with a protocol?

9:06 joegallo: can you tell us which interface it is and which extra methods you're looking to add? or it is something internal?

9:07 stuartsierra: tufflax: `reify` and `deftype`/`defrecord` can define interface methods the same way they define protocol methods.

9:08 gotta go

9:10 tufflax: It's this GUI library, and it uses a "Controller" (Listener type thing) java interface to do stuff with the GUI, but the interface declares only very basic methods, and the idea is that you give your controller instance more methods as you need them, and you call them via the GUI (xml) e.g. onClick="doSomething()"

9:12 joegallo: ah, okay -- yeah, maybe deftype is what you're looking for then, if not gen-class. (in my highly limited knowledge of this particular thing)

9:40 dnolen: match now has guards https://github.com/swannodette/match/blob/master/test/match/test/core.clj#L126

9:41 fliebel_: dnolen: Sweet!

9:42 dnolen: Hey, I thought you had to declare your predicates? Or am I confusing stuff?

9:43 dnolen: fliebel_: that's later when we get around to integrating core.logic

9:43 fliebel_: and we probably won't get to that soon, we need a plan for open matching, tricky business that.

9:47 thorwil: lovely how concise and easy to read that is

9:47 dnolen: adding guards was like 40 lines of code :)

9:51 thorwil: dnolen: what happens if there are multiple matches? does it stop on first match, return the last match, can you get a collection out of it?

9:52 * thorwil read a bit about pattern matching in erlang, but forgot "details" like that already

9:52 dnolen: thorwil: it always stops on the first match

9:52 thorwil: the testing is ordered, top down

9:53 as far as getting a collection out, we're going to add :as next.

9:53 thorwil: good, that would have been my assumption

9:54 dnolen: (match [x] [[({_ :a} :as foo) _ _]] …)

9:55 wunki: can someone help a beginner with this exception: https://gist.github.com/3b3f6536a6f71435b0ac

9:55 caused by this code:https://gist.github.com/ad829a9b36b821ea8648

9:58 tufflax: In Java, interfaces can extend/inherit from other interfaces, for example DataInput is a superinterface of ObjectInput. Can I create a subinterface of a Java interface in Clojure without AOT compilation or other nasty stuff? :p

9:59 lnostdal: how does deliver/promise work when combined with dosync or STM? .. will a call to deliver be rolled back?

9:59 dnolen: lnostdal: no, separate system entirely.

9:59 lnostdal: ok, thanks, dnolen

10:01 joegallo: wunki: i think your ns declaration is wrong

10:01 no need to quote stuff

10:01 and put redirect in a vector, not a list

10:01 wunki: joegallo: I copied it from here

10:01 https://github.com/mattrepl/clj-oauth

10:02 joegallo: (require) and (:require) use different syntax

10:02 you are using the latter, they are using the former

10:02 wunki: joegallo: ah, thank you...

10:03 joegallo: np, eventually it all seems perfectly natural, but yeah, it's a little odd

10:03 thorwil: i did run inti that early on, too

10:04 there's a hint in the error, as it complains about line 1 (otherwise it's terribly unhelpful, of course)

10:05 lnostdal: i suppose i could use an agent; and call send / send-off with a call to deliver there .. since agents run after a completed transaction, dnolen .. .. or something

10:05 feels sort of hackish tho

10:05 there's no "after transaction" hooks?

10:07 dnolen: lnostdal: send / send-off is the after transaction hook as far as I know.

10:18 coopernurse: basic design question for y'all

10:19 let's say I'm writing a web service that stores data somewhere

10:19 and I want to have two different persistence implementations

10:19 one that stores data in a sql db, the other in, say, mongodb

10:19 the persistence call semantics are the same for both

10:20 what's the idiomatic way to switch between implementations at runtime?

10:20 one idea that came to mind would be to have a separate .clj file for each impl with the same functions, and to require the impl dynamically at runtime

10:21 would that work? or is there a better way to do this?

10:21 normally in Java I'd just have an interface, and then some way of dispensing the correct impl

10:21 jose: Hi all

10:27 manutter: coopernurse: are you talking about a one-time startup choice of implementations, or a continual on-the-fly switching back and forth between the two?

10:27 coopernurse: manutter: at this point, a one time startup choice

10:28 perhaps driven by a properties file

10:28 manutter: for a one-time startup, I'd think having separate .clj files would be reasonable

10:29 coopernurse: ok, thanks. or is this the problem protocols are designed to solve?

10:29 raek: coopernurse: protocols can be used also

10:29 manutter: I'm pretty sure you can (if (global-is-mongo?) (require 'mongo-version) (require 'sql-version')) onr whatever

10:30 raek: the dispatch happens at runtime, but is quite fast

10:30 manutter: I did a test once where I used multi-methods and defined a macro called with-driver that you could pass a keyword to

10:30 That was pre-protocol days, but I'd think protocols could work the same

10:31 coopernurse: ok, I'll read more about protocols -- seems like that's the solution most similar to using a Java interface

10:31 manutter: The nice thing about protocols is you could conceivably have both implementations available at runtime, and easily switch between the two.

10:32 raek: coopernurse: yes, protocols are very similar to interfaces

10:32 manutter: they're cool, I should play more with them :)

10:32 raek: they also add a way to document the abstraction

10:41 coopernurse: great, I'm reading the section about them in Joy of Clojure.. seems to be what I'm after

10:45 pyr: a question for paredit users (on emacs)

10:45 stuartsierra: pyr: ?

10:45 pyr: i often go back to code wanting to nest an expression in a new one

10:45 as in

10:46 (let [a :a] (thing)) -> (let [a :a] (.foo (thing)))

10:47 paredit does this annoying thing where if you open up a ( before (thing) it will write out () (thing)

10:47 TimMc: C-right

10:47 pyr: is that on the cheat sheet ? can't figure out why i never found it

10:47 TimMc: aka "slurp", IIRC

10:47 pyr: thank you <3

10:48 stuartsierra: pyr: You've got two approaches: M-S-( before the expression to wrap it in another expression, or TimMc's suggestion.

10:48 pyr: \o/

10:48 dark hours for my vim setup

10:48 joegallo: for bonus points, you could M-( and it will start off the way you'd like it to be

10:49 pyr: i've been pastin' ) all day!

10:49 joegallo: oh, just saw stuartsierra's response -- oops

10:49 pyr: :)

10:49 stuartsierra: np

10:49 TimMc: While we're on the topic, how do I kill whitespace after the point?

10:49 pyr: ^K ?

10:49 TimMc: e.g. (foo | bar)

10:49 pyr: ah

11:59 clgv: what is the easiest way to realize a "press any key" via *in*? (.read *in*) waits for an enter.

12:00 manutter: clgv: there's a related question on stack overflow: http://goo.gl/AJ3qd

12:01 clgv: manutter: humm it says thats not possible...

12:01 only "return" works

12:03 manutter: That's consistent with what I've heard :/

12:04 short of using some kind of native lib

12:04 clgv: ok. then its limited like this...

12:05 I only need it to get my profiler attached to the jar before starting the computation ;)

12:05 manutter: probably the simplest way would be to put up a Swing panel to wait for the keypress

12:05 ("simple" being a relative term)

12:06 clgv: lol. a swing panel doesnt work that well over ssh in general ;)

12:06 joegallo: change the prompt from "press any key" to "press enter" :)

12:06 * manutter gives joegallo a cookie.

12:06 manutter: :)

12:06 clgv: joegallo: I did in fact a minute ago^^

12:07 joegallo: a bug? nope, we just changes the specs. now it's a feature. presto!

12:08 manutter: I withdraw my earlier comment about the "simplest" solution.

12:08 clgv: I still wonder if someone has enough to investigate the behavior of defmultis in parallel execution

12:08 s/enough/enough time/

12:08 lazybot: <clgv> I still wonder if someone has enough time to investigate the behavior of defmultis in parallel execution

12:25 technomancy: TimMc: M-SPC

12:25 aaelony: hi - I have what must be a common Leiningen question regarding local jar files (apologies in advance). I am able to copy local jar files into the lib directory, but is there a way to specify a local directory containing jar files in the project.clj ?

12:26 technomancy: aaelony: I think there's something for that in "lein help sample" but you should really get them in a proper repository.

12:26 aaelony: thanks!

12:27 i was googling but was looking for exactly this. thx again.

12:27 TimMc: technomancy: Fantastic, thanks.

12:30 wastrel: technomancy turns out to be surprisingly helpful

12:35 ejackson: Is there a way to do something like, given (defrecord My-rec [a b]), create an instance with (My-rec. {:a 1 :b 2}) ?

12:36 * scgilardi is not surprised

12:37 * technomancy won't touch protocol questions though; sorry.

12:37 cemerick: ejackson: in that case, defrecord defines ->My-rec and map->My-rec; you want the latter

12:38 ejackson: thanks gents.

12:47 dnolen: technomancy: better watch out, if you start using match w/ Java objects - you might become a protocol expert yourself :)

12:49 ejackson: would that make him C3PO ?

12:49 technomancy: interop schminterop.

12:49 ejackson: i'm not interoping, I'm polymorphing :)

12:50 technomancy: (not really)

12:51 Bronsa: is there a way to trasform a keyword to a symbol?

12:51 eg :a -> a

12:51 dnolen: ,(-> :a name symbol)

12:51 clojurebot: a

12:52 Bronsa: thanks

12:57 JackAllan: how can I sort a long text ( "adb dba cba acb abcd" following a defined sequence? I want to order in sequence "cdba" and NOT with traditional "abcd"

13:01 mdrogalis: JackAllan, elaborate a bit on how you want it sorted?

13:02 Scriptor: JackAllan: do you mean how you can provide your own comparision function for sorting?

13:02 JackAllan: i want order adb dba cba acb abcd .... to.... cba dba acb adb abcd (Because "c" is the first letter)

13:03 yes, my own comparision, but i guess it is possible using regex or something

13:06 dnolen: ,(sort-by #((zipmap (seq "cdba") (range)) %) (seq "adb"))

13:06 clojurebot: (\d \b \a)

13:07 dnolen: ,(require '[clojure.string :as string])

13:07 clojurebot: nil

13:10 JackAllan: ,help zipmap

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

13:10 dnolen: ,(map (partial apply str) (map (fn [s] (sort-by #((zipmap (seq "cdba") (range)) %) s)) (map seq (string/split "adb dba cba acb abcd" #" "))))

13:10 clojurebot: ("dba" "dba" "cba" "cba" "cdba")

13:10 dnolen: JackAllan: ^

13:14 JackAllan: oh my god, it is work :)

13:14 let me try with my project

13:16 cool... thanks

13:22 I will ask how to order by letter too, but this code already order by word and by letter.

13:32 alandipert: does anyone know off-hand if any of the ide plugins are using nrepl?

13:38 dakrone: alandipert: the eclipse clojure plugin does I believe

13:40 alandipert: dakrone: thanks!

13:47 cemerick: alandipert: That's where Enclojure is going as well AFAIK, at least if/when Eric has bandwidth for working on it.

13:47 alandipert: cemerick: cool

13:48 cemerick: And I *think* vimclojure uses it now……?

13:48 alandipert: reason i ask is, we're looking into a clojurescript nrepl server

13:48 wastrel: what's nrepl

13:48 alandipert: in the early design stage at least, about to fire out a confluence page

13:49 cemerick: nrepl?

13:49 hrm

13:49 clojurebot: nrepl is a network REPL implementation: http://github.com/clojure/tools.nrepl

13:49 clojurebot: 'Sea, mhuise.

13:50 cemerick: wastrel: ^^

13:51 alandipert: I thought a clojurescript REPL was out of scope?

13:53 alandipert: cemerick: the eval form is out of scope, but an extensible E in REPL is not. ie untie cljs repl from rhino, and add ability to have v8, multi-browser evaluation backends

13:53 a-la brepl

13:53 then for the front, support multiple presentations, of which an important one seems to be nrepl

13:55 (also opens up possibility of simultaneous evaluation in multiple browsers for compatibility testing!)

13:57 triyo: Anyone know of any nice projects out in the wild that widely utilize the "enlive" library?

13:58 technomancy: triyo: http://seajure.github.com

13:58 kind of a trivial usage, but it may be a good starting point

13:58 or rather: https://github.com/Seajure/seajure

14:00 triyo: technomancy: thanks, I've reached that point where it would be good to see how others utilize enlive. It is a bit of tricky library to get used to

14:00 well maybe just in the beginning of course

14:01 technomancy: yeah, true. don't ask me how it works though; I've forgotten everything about it since writing that code.

14:01 marick has a nice tutorial now though

14:01 triyo: Oh really? Do you have the link to the tutorial by any chance?

14:02 technomancy: clojurebot: google marick enlive tutorial

14:02 come on brah

14:02 triyo: not off the top of my head

14:03 algernon: https://github.com/swannodette/enlive-tutorial ?

14:03 triyo: Oh I've read that one

14:03 technomancy: algernon: I'm thinking of a different one that was more focused on output than scraping

14:03 seancorfield: i wish enlive was more of a function library and didn't use macros so much

14:04 algernon: technomancy: hm.. I need to find that one too, then.

14:04 seancorfield: i was trying to incorporate it into a port of my FW/1 mvc framework but i need a lot of its functionality as functions not macros since all the templates are dynamically located and processed...

14:05 algernon: this seems to be the other one: https://github.com/cgrand/enlive/wiki/Table-and-Layout-Tutorial,-Part-1:-The-Goal

14:05 seancorfield: enlive is certainly very cool tho'

14:05 triyo: Oh yes that one is pretty cool

14:05 the 5 part tutorial

14:06 enlive is cool, however, even though I've been programming for over a decade, facing enlive I still look like a noob

14:07 For example, I've written a nice little binding+validation library for my web app and now I need to display the errors via enlive....

14:07 Easy right? ;)

14:09 I have a snippet that already loads the html template and does quite a bit of foot work already. Remove non-admin viewable fields, set "value" attribute of input fields and now add errors if any...

14:10 Logically, I would like to split these parts out. But seems that its easier said than done.

14:11 Hence its good time to see how others deal with these common patterns.

14:14 https://github.com/marick/enlive-tutorial

14:15 technomancy: clojurebot: ping?

14:15 clojurebot: PONG!

14:16 * dnolen will probably be diving into multiway decision graphs / diagram literature in order to make match open... papers welcome

14:16 triyo: Need to catch a flight. Later friends!

14:19 symbole: dnolen: About your talk at NYC Clojure next week, is there any introductory infromation one could look at before the talk so as to not get lost?

14:21 dnolen: symbole: the talk will not assume you know anything about pattern matching.

14:21 symbole: but if you want a head start, look at pattern matching in Erlang, Haskell, SML, Racket to get the general idea.

14:23 symbole: dnolen: Great.

14:28 gtrak`: when you write key/value pairs, is it more proper to line up values or let them get jagged base on key length?

14:29 arohner: gtrak: I line up the keys, but that's just me. I don't think there's a standard

14:31 cemerick: Keeping values lined up seems like a lot of ongoing maintenance.

14:31 gtrak`: but it looks pretty

14:31 * cemerick waits for someone to mention M-x keep-values-horizontally-aligned or something :-)

14:32 gtrak`: M-x pretty-mode

14:33 duck1123: you could use org mode and then regex to remove the lines

14:34 Has anyone received the "can't recur here" error trying to use noir-cljs

14:36 * hiredman assumed aligning the values was an eclipse thing

14:37 ibdknox: duck1123: are you using pinot as well?

14:37 duck1123: well, it's on the classpath

14:38 havn't gotten there yet

14:38 ibdknox: duck1123: try removing it

14:39 technomancy: hiredman: M-x align-regex; I've seen it around but am not a fan personally

14:39 duck1123: so noir-cljs expects my files to be in src/

14:39 ibdknox: duck1123: yeah I saw your pull request

14:39 duck1123: but that's where they would normally go, right?

14:40 ibdknox: mhm

14:40 duck1123: I had them in src/main/clojurescript/ before today

14:40 hiredman: technomancy: interesting

14:41 technomancy: actually I saw it more in ruby

14:41 ibdknox: duck1123: that would be fine, they can go anywhere inside of source

14:41 err src

14:42 duck1123: ibdknox: NoSuchMethodError: com.google.common.collect.ImmutableSet.copyOf

14:43 ibdknox: duck1123: what caused that error?

14:44 owl__: hi, i just wrote a gen_fsm like fsm for clojure, tell me what you think of it: https://github.com/rixmann/gen_fsm

14:44 duck1123: hold on, if it happens again, I'll gist it

14:45 does it matter that I'm not using noir

14:45 I pulled it in, but I'm using my own framework

14:46 hiredman: ~single segment namespaces

14:46 clojurebot: namespaces are (more or less, Chouser) java packages. they look like foo.bar; and corresponde to a directory foo/ containg a file bar.clj in your classpath. the namespace declaration in bar.clj would like like (ns foo.bar). Do not try to use single segment namespaces. a single segment namespace is a namespace without a period in it

14:47 duck1123: https://gist.github.com/1142689

14:47 I'm not sure if the line numbers will match up, I added 2 printlns to see what the params were

14:47 Hodapp: ugh, jesus christ, I just got banned from #java again.

14:48 ibdknox: duck1123: never seen that one before, that's something to do with the compiler itself. do you have code actually in your project?

14:49 duck1123: https://github.com/duck1123/jiksnu/blob/master/src/main/clojurescript/jiksnu/core.cljs

14:50 ibdknox: change the extension of that to not be cljs and see what happens

14:50 you may have something in there that the compiler chokes on

14:51 I also just pushed new versions of everything up

14:51 there were a few changes in the cljs compiler stuff

14:51 maybe it will fix it

14:51 duck1123: actually, it looks like I had everything commented out except the greet and the require

14:52 I doubt this would be an issue, but I'm also using Aleph

14:52 hiredman: ~underscores

14:52 clojurebot: idiomatic clojure uses dashes to separate words

14:52 hiredman: ~filenames

14:52 clojurebot: you filename should match your namespace declaration, but with - channged to _ e.g. (ns foo.bar-baz) => foo/bar_baz.clj

14:52 ibdknox: duck1123: Aleph has 1.3 compat now?

14:52 I couldn't use it for brepl

14:53 duck1123: I've been maintaining the 1.3 branch

14:54 Okay, even with that file renamed, it's still choking

14:54 owl__: plz have a look at my gen_fsm, it's not a lot of code and i use a behaviour like in erlang and i'm not sure about the performance issues of resolve: https://github.com/rixmann/gen_fsm

14:56 ibdknox: duck1123: hm

14:56 duck1123: so this jiksnu project is the one you're running?

14:57 duck1123: yes

14:58 It started as an implementation of OneSocialWeb, but now it also does OStatus

14:58 arohner: ,(clojure.string/replace "foo?bar" #"\?" "\\?")

14:58 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.string>

14:58 arohner: hrm.

14:59 &(clojure.string/replace "foo?bar" #"\?" "\\?")

14:59 lazybot: ⇒ "foo?bar"

14:59 duck1123: ibdknox: How are you packaging up clojurescript for clojars?

14:59 arohner: what is going on there?

14:59 &(clojure.string/replace "foo?bar" #"\?" "\\\\")

14:59 lazybot: ⇒ "foo\\bar"

14:59 mdeboard``: arohner: regex string replacement

14:59 ibdknox: duck1123: hah which part of it? cljs projects? the compiler? the goog libs?

14:59 duck1123: ooh, I see a pom now

14:59 mdeboard``: arohner: What are you confused by

14:59 arohner: the fact that the first version doesn't contain a \

15:00 I expect to see "foo\?bar"

15:00 duck1123: I was asking about the compiler. I'm building fresh to see if I can figure out where this is going wrong

15:00 ibdknox: duck1123: mm

15:02 mdeboard``: &(clojure.string/replace "foo?bar" #"\?" "\\\?")

15:02 lazybot: java.lang.Exception: Unsupported escape character: \?

15:02 mdeboard``: Yeah

15:02 &(clojure.string/replace "foo?bar" #"\?" "\\\\?")

15:02 lazybot: ⇒ "foo\\?bar"

15:03 mdeboard``: Huh.

15:03 Iunno :)

15:05 &(clojure.string/replace "foo?bar" #"\?" '("\\?"))

15:05 lazybot: java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.IFn

15:05 ibdknox: duck1123: any luck?

15:05 mdeboard``: &(clojure.string/replace "foo?bar" #"\?" '"\\\?")

15:05 lazybot: java.lang.Exception: Unsupported escape character: \?

15:05 mdeboard``: &(clojure.string/replace "foo?bar" #"\?" '"\\?")

15:05 lazybot: ⇒ "foo?bar"

15:06 mdeboard``: arohner: If you figure it out, let me know.

15:08 ibdknox: duck1123: how do I run this?

15:08 thorwil: ibdknox: what's the reasoning behind noir's defpartial? couldn't you justuse hiccup's defhtml?

15:08 duck1123: lol, come over and use my computer

15:09 you could try the ./checkout-dependencies to build everything it needs

15:09 ibdknox: thorwil: yeah, I don't remember it being there back when I originally wrote noir.

15:09 duck1123: I think that'll get you everything

15:09 then mvn clojure:run

15:09 ibdknox: thorwil: or I just missed it

15:10 duck1123: in ciste, I have defsection which allows dispatching on the class, the format, and the srialization

15:12 thorwil: ibdknox: does noir include any kind of support for composing views? (just curious, looking for code to learn from)

15:12 ibdknox: thorwil: composing views?

15:13 thorwil: since you end up with partial functions, composing views is just a matter of calling those functions in other partials

15:13 stuartsierra: arohner: It's because of Matcher.replaceAll interpreting the replacement string.

15:14 ibdknox: assuming you keep using hiccup

15:14 if you don't

15:14 thorwil: ibdknox: ah, then i have to look at those partials

15:14 arohner: &(.replace "foo?bar" "?" (str (char 92) "?"))

15:14 lazybot: ⇒ "foo\\?bar"

15:14 ibdknox: thorwil: the blog app provides a decent example

15:15 arohner: does that \\? mean two characters? is it printing the ? as escaped?

15:15 duck1123: I love Hiccup, I fear I'm really going to miss it now that I've replaced all the templates in my code with soy templates

15:15 arohner: &(count (.replace "foo?bar" "?" (str (char 92) "?")))

15:15 lazybot: ⇒ 8

15:15 stuartsierra: Yes, "\\?" is two characters, an escaped backslash and a question mark.

15:15 arohner: stuartsierra: thanks

15:16 stuartsierra: See http://download.oracle.com/javase/6/docs/api/java/util/regex/Matcher.html#appendReplacement(java.lang.StringBuffer, java.lang.String)

15:16 ibdknox: duck1123: nooooooooo

15:16 duck1123: ibdknox: I excluded your clojurescript compiler, and replaced it with one I just checked out, and it works

15:16 ibdknox: duck1123: don't do that

15:16 duck1123: weird

15:16 duck1123: I might go back if I can get your hiccup for cljs working

15:17 ibdknox: can you remove my jars from ~/.m2/repository

15:17 and get the deps again

15:17 duck1123: I just don't want to have to duplicate my templates in both places

15:17 ibdknox: I pushed up the latest compiler

15:17 it should be exactly what you downloaded

15:17 back shortly

15:20 duck1123: ibdknox: same error

15:23 ibdknox: duck1123: hah, I wonder if it's because we're telling it to build but there are no files to build

15:23 that path is relative

15:24 wunki: someone willing to help me out on this error: https://gist.github.com/395ce4c072e2ed2ba041

15:25 took me a day to get here, now I'm stuck :)

15:29 thorwil: wunki: looks to me like you are handing a string to fetch-and-modify where it expects an object

15:30 wunki: is there perhaps a a username-as-string->mongo-db-object kind of function you should be using?

15:35 wunki: thorwil: I really don't know. I will check the types that i'm passing on

15:42 * TimMc rolls U+10D6 for bug free code...

15:43 TimMc: :-(

15:47 I got an ზ

16:01 amalloy: wunki: i don't know how fetch-and-modify works, but you don't need it here

16:02 just do a regular update, like (update! :users {:username username} {:$set {:access-token access-token}})

16:24 fliebel: Raynes or ninjudd around? I need to figure out timezones, because my day is ending already.

16:25 Raynes: fliebel: I just woke up, but that isn't exactly a normal thing where I live.

16:25 It's 3:28PM.

16:25 fliebel: Raynes: At which time do the other five inhabitants of your vilage wake up?

16:25 oh

16:26 Raynes: fliebel: Early morning. And there are 6, not five.

16:27 fliebel: Raynes: Okay, so I assume you'd rather have some more sleep and coffee, or are you ready for some Jiraph troubles?

16:27 Hodapp: hah

16:28 Raynes: fliebel: I'd love more sleep, but I don't really drink coffee. I'm good to go.

16:28 fliebel: There is a #jiraph channel if you'd rather talk about it there.

16:28 fliebel: oh, sure

16:29 Hodapp: Now I'm curious WTF Jiraph is.

16:30 ibdknox: Hodapp: it's a graph database

16:30 Hodapp: What sort of things does one use a graph DB for?

16:31 Raynes: Hodapp: Graphs.

16:31 Hodapp: 9_9

16:31 "Graph" is quite a vague term, at least when I'm around people who describe their pie charts as being graphs.

16:32 ibdknox: lol

16:32 Graph in the datastructure sense ;)

16:32 Raynes: Hodapp: Graph databases are just specialized databases. A graph DB can typically be used as a general database but excells in places where things are connected to each other. Like, for example, products to the users who own them. Graph databases make it easy to make and find those connections.

16:33 fliebel: Or discussions, like on Twitter and in email. :D

16:33 Hodapp: Raynes: So, something you could do in SQL, but you wouldn't unless you were clinically insane?

16:33 Raynes: Hodapp: Essentially.

16:33 fliebel: Hodapp: Basically, but Twitter implemented a graph database on top of MySQL.

16:33 Hodapp: This does seem a natural fit for Clojure.

16:35 Raynes: Hodapp: http://jim.webber.name/2011/04/21/e2f48ace-7dba-4709-8600-f29da3491cb4.aspx Good read.

16:37 Hodapp: Raynes: Thanks, I will read this

16:50 Raynes: interesting article. Good explanation.

16:56 duck1123: Anyone ever see this error from closurescript? No method in multimethod 'javascript-name' for dispatch value: class cljs.closure.JavaScriptFile

17:01 ibdknox: duck1123: different problem now?

17:02 duck1123: yeah, it's odd. With the middleware in, it fails. but I can remove it, compile, run, add the middleware and eval, and it works

17:06 ibdknox: that *is* weird

17:06 duck1123: I just keep going further down the rabbit hole with this one

17:06 ibdknox: so you have both my thing and clojurescript on your class path

17:06 ?

17:06 duck1123: glad I took today off work

17:07 ibdknox: That could cause problems

17:07 I tried doing a completely fresh install of everything on mine and it worked

17:07 I'm using Noir but that shouldn't make a difference overall

17:08 duck1123: I've excluded your version of the clojurescript library, and I have a pom I created to compile clojurescript

17:08 ibdknox: I couldn't get your project to run

17:08 duck1123: I think I may have something messed up now

17:08 ibdknox: *sigh* such is the way of these things :(

17:08 duck1123: yeah, it's a bit of a mess dependency-wise

17:09 I keep running into the issue that Tigase looks for it's plugins by loading EVERY class on the classpath

17:09 so I have to keep patching that file to exclude all but the one class that actually has a plugin

17:21 arohner: did c.c.duck-streams/to-byte-array make it into core?

17:22 hiredman: nope

17:22 it is in some silly incubator namespace

17:23 http://dev.clojure.org/display/design/Contrib+Library+Names

17:23 (See comments)

17:23 arohner: I'm starting to get really annoyed by all the contrib ns shuffling

17:23 hiredman: starting?

17:24 ibdknox: lol

17:24 arohner: the only thing mutable in clojure seems to be namespaces

18:09 TimMc: haha

18:19 duck1123: sigh. I've now got just about everything working except the fact that it can't resolve anything in cljs.core

18:28 TimMc: I'm reading that as "kludges dot core"

18:35 dnolen: ok it's official, map pattern supports Java classes, https://github.com/swannodette/match/commit/ba6ef717d1445c3d32ec35ad7c36328aea040b7e#L0R7

18:37 hiredman: dnolen: do you have to explicitly extend the protocol to each java class you want to match against?

18:38 dnolen: hiredman: yup, do you have a better idea?

18:39 hiredman: I dunno

18:40 extend it to objet and have object generate something for all .get* methods the first time it encounters a given class?

18:40 object

18:42 dnolen: hiredman: how could tho get method be made fast?

18:42 s/method/methods

18:42 lazybot: <dnolen> hiredman: how could tho get methods be made fast?

18:43 hiredman: well you would generate the specific protocol extension for that type and subsequent usage would use that

18:44 dnolen: hiredman: what I mean is how could I make get access for unknown types fast at runtime?

18:44 it seems to be best I could do is provide a macro to automatically IMatchLookup-ize a Java type.

18:44 hiredman: it would require eval for runtime code generation

18:44 maybe the macro would be best

18:45 dnolen: hiredman: yeah I'd prefer not tread into eval waters. I'd be will to accept a patch that provides said macro.

18:46 hiredman: :)

19:15 neotyk: Good morning everyone

19:16 pdk: refresh me

19:16 does clojure auto upscale numbers to bignums transparently

19:18 hiredman: pdk: not in 1.3

19:18 unless you use special overflowing fns +' and friends

19:19 pdk: oh is 1.3 up to a production release yet

19:19 hiredman: no

19:19 beta1

19:19 pdk: dang

19:19 gotta get hustlin!

19:20 hiredman: *shrug* given clojure/core's sense of drama I think 1.3 will be released at the conj

19:20 ibdknox: haha

19:20 probably

20:17 seancorfield: pdk: at world singles we're in production with clojure 1.3 and we've had no problems

20:17 i heard that we'll get beta2 "real soon now"

20:19 we were developing against the nightlies for a while... that was a bit fraught at times... then we settled on one of the alpha builds for development and first took clojure code into production with alpha7 (i think), then updated to each milestone as it appeared...

20:19 ibdknox: is there an official "what's new" for 1.3 somehwere?

20:20 somewhere*

20:26 raek: ibdknox: there is a file called changes.txt or something similar in the repo

20:28 ibdknox: raek: thanks

20:38 seancorfield: https://github.com/clojure/clojure/blob/master/changes.txt

20:39 doesn't show changes from alph8 to beta1

20:39 s/alph/alpha/

20:39 lazybot: <seancorfield> doesn't show changes from alpha8 to beta1

20:40 seancorfield: but there were only two bug fixes in that delta: 801 and 769

20:41 and just a few bug fixes since beta1

20:41 some without jira tickets... tsk, tsk!

21:28 pdk: actually

21:28 there's a clojure jobs blog right

21:28 duck1123: The biggest issue with using 1.3 is fixing the dependencies

21:29 seancorfield: You can use the new contrib libs from 1.2 so folks can already switch.

21:29 That then makes it easier for them to move to 1.3 later.

21:30 it also means they can take advantage of the bug fixes and enhancements in the new contrib libs.

21:30 duck1123: I switched to 1.3 very early on and had to patch just about every lib I was using

21:30 it's getting better though

21:33 amac: is there a widely-accepted clojure style guide published anywhere?

21:37 duck1123: I know there is a Lisp style guide that people were using for a while

21:37 most of the rules were pretty much the same

21:39 http://mumble.net/~campbell/scheme/style.txt Some of the rules don't apply to Clojure

21:40 amac: ah, thanks; this'll help

21:40 duck1123: when in doubt, look at a well-written library

21:42 amac: true, though there can still be plenty of variation; and the clojuredocs guide didn't seem very comprehensive

21:43 duck1123: The rule I follow is: put it wherever emacs wants it

21:58 amalloy: yeah, emacs is always right

22:13 leo2007: does clj have continuation?

23:08 carlo_au: is there some special notation for accessing a subtype of a class?

23:09 tomoj: how is it you want to access the subtype

23:09 carlo_au: I'm trying to make a new ArrayDouble.D2 for dealing with NetCDF files: https://gist.github.com/1143434

23:09 tomoj: ah

23:09 the class name is ArrayDouble$D2

23:09 you must import it separately

23:09 carlo_au: I can use a 'factory' method in a superclass to make one of these things, and Clojure thinks that it is of type ucar.ma2.ArrayDouble$D2

23:10 tomoj: yeah

23:10 carlo_au: tomoj: how do I import it separately?

23:10 tomoj: well, you're doing it right

23:10 just don't do three separate imports

23:11 (:import (ucar.ma2 Array ArrayDouble ArrayDouble$D2)) should work

23:11 to create an ArrayDouble$D2, call:

23:12 (ArrayDouble$D2. 1 2)

23:12 if the constructor is public

23:12 looks like it is

23:13 carlo_au: $ clj x.clj

23:13 #<D2 0.0 0.0 >

23:13 huzzah!

23:13 tomoj: many thanks :)

23:16 actually for my example this line does the job: (ns testing-netcdf (:import (ucar.ma2 ArrayDouble$D2)))

23:17 * srid is 1/3rd through the-joy-of-clojure (chapter on vectors) and is impatient to get to the meat so he can start writing web apps.

23:19 carlo_au: tomoj: is there a place with more detail about :import?

23:20 http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/import is pretty brief

23:20 tomoj: think that's it

23:20 http://clojuredocs.org/clojure_core/clojure.core/import

23:20 amalloy: carlo_au: your issue is nothing to do with import really

23:21 the class is named ArrayDouble$D2, so you import ArrayDouble$D2. there's no magic there, you just need to know the classname

23:21 tomoj: "Note that nested classes are named EnclosingClass$NestedClass, per the JVM spec."

23:21 http://clojure.org/java_interop

23:21 carlo_au: ah, I can also do (ucar.ma2.ArrayDouble$D2. 1 2) with my earlier import

23:22 amalloy: carlo_au: you can do that without any imports at all

23:22 carlo_au: amalloy: ah, of course

23:23 tomoj: thanks for the link

23:26 dnolen: as patterns have landed, match-0.1.0 pushed to Clojars - I'm sure there are crazy bugs - feedback appreciated.

23:35 jli: I'm working on a little clojurescript thing. how can I read in clojure data structures in clojurescript?

23:36 e.g., some page has the text "[1 2 3]". how can I convert that into a vector in clojurescript?

23:41 amalloy: &(doc read-string)

23:41 lazybot: ⇒ "([s]); Reads one object from the string s"

23:42 jli: hm

23:43 WARNING: Use of undeclared Var hops.main/read-string

23:43 am I doing something wrong?

23:48 ah, found cljs.reader

23:55 srid: what is the algorithmic complexity of peek and conj on clojure.lang.PersistentQueue?

23:56 amalloy: O(1)

23:57 well. O(log32(N)), like vectors

23:57 srid: btw, I meant pop, not peek.

23:57 pdk: they're implemented as trees with 32 children per node

23:57 srid: when the front list is exhausted, the rear vector is wrapped in a seq -- wouldn't that cause subsequent pops to be O(n)?

23:57 amalloy: no

23:58 srid: so the vector items are never garbage collected until they too are exhausted?

23:58 amalloy: first and rest on a seq is O(1)

23:58 srid: does `seq` return a copy of the underlying data structure, or only a 'view' on it?

23:59 amalloy: a view

23:59 it could copy in order to create the view if it wanted; that's not specified

23:59 srid: ok, so a pop on seq == deleting the first item of a vector … which is O(1)?

Logging service provided by n01se.net