#clojure log - Feb 13 2012

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

0:02 emezeske: Anyone know if there's a vimclojure/nailgun plugin that works with Leiningen 1.7?

0:02 I've been using org.clojars.oskarkv/lein-vimclojure "1.0.0-SNAPSHOT" but it doesn't work with 1.7.

0:02 ibdknox: emezeske: does mine not?

0:03 it seems to for me

0:03 emezeske: ibdknox: Didn't know you had one! Trying it now.

0:03 ibdknox: I really want to figure out a way to get the CLJS repl to work in vimclojure

0:04 but so far it has been nothing but frustratingly cryptic results

0:04 emezeske: That would be awesome

0:07 ibdknox: This is what happens with I "lein nailgun": http://pastebin.com/MzuhjHMe

0:08 Pretty much (exactly?) the same thing I saw with the other nailgun plugin I was using

0:08 ibdknox: that's weird

0:08 how did you install it?

0:08 lein plugin install?

0:08 emezeske: no, via :plugins

0:08 I'll try lein plugin install

0:09 ibdknox: oh yeah, I meant to mention that to you

0:09 you should encourage people to plugin install lein-cljsbuild as opposed to dev dependency it :)

0:09 emezeske: Why? I don't like global plugins; for instance, what if two projects depend on different versions of the plugin?

0:10 ibdknox: BTW, thank you, plugin install made it work

0:11 Raynes: ibdknox: No, he shouldn't.

0:11 ibdknox: I'm not sure if the general wisdom has changed (technomancy?) but after the fiascos we had with things like incanter

0:11 Raynes: ibdknox, emezeske: 'lein plugin install .." is going away in Lein 2.

0:11 ibdknox: ?

0:11 why?

0:11 clojurebot: #<ClassCastException java.lang.ClassCastException: clojure.lang.Cons cannot be cast to clojure.lang.IPersistentStack>

0:12 Raynes: Because profiles will replace user-level plugins.

0:12 technomancy: emezeske: just to clarify, :dev-dependencies still works in 1.7

0:12 it's just that if you can transition off now, it will ease the transition to 2.0

0:12 emezeske: technomancy: ahh, gotcha, okay

0:13 technomancy: I made lein-cljsbuild work either way, I think. But that's good to know for plugins that haven't been updated.

0:13 ibdknox: That doesn't seem to effect my statement for pre-2.0 though?

0:13 technomancy: emezeske: great; thanks

0:14 ibdknox: lein-cljsbuild is needed for the project to build, so it should go in project.clj

0:14 ibdknox: hm

0:14 technomancy: user-level plugins are for things that are just for your convenience, like difftest or vimclojure

0:14 ibdknox: I see

0:14 Raynes: ibdknox: Not doing it at all eases the transition. Of course, for things like `lein newnew` it is okay, but for this -- something required for building a project -- it shouldn't be installed globally.

0:14 technomancy: though you should be able to use the lein-profiles plugin to get user-level :plugins instead of using "lein plugin install"

0:14 (lightly tested)

0:15 sgarrett: Hello #clojure. I'm working with some array of objects and I want to check to see if an object is in the array and if isn't then don't append. I was thinking a simple way would be to do: (set (conj [1 2 3] 3)) But to see if the value 3 is a "new" value I have to get the length of the set. Is there built in funcitonality to get the length of a set?

0:15 ibdknox: I guess I look at it as a utility that I certainly wouldn't want to specify over and over again

0:15 which seems to be covered :)

0:16 technomancy: ibdknox: different projects would need different versions

0:17 ibdknox: of a build tool?

0:17 I'd hope not

0:17 muhoo: sgarrett: ##(count #{:fo :bar :baz})

0:17 lazybot: ⇒ 3

0:17 technomancy: ibdknox: of the plugin I mean

0:18 ibdknox: the plugin is a build tool :)

0:18 it builds CLJS

0:18 technomancy: oh, sure

0:18 ibdknox: we're not actually in disagreement though

0:18 technomancy: but naturally it's going to evolve over time

0:18 ibdknox: yep yep

0:18 technomancy: even Leiningen itself has :min-lein-version

0:19 ibdknox: the price we pay for making things better ;)

0:19 sgarrett: muoo: I'm getting a ClassNotFound exception with that...

0:19 muhoo: *

0:23 emezeske: technomancy: Cool, lein-cljsbuild's 1.7 support is all done. Wasn't too bad.

0:24 technomancy: One note: when I run "lein cljsbuild once", I see a bunch of lines like "Overriding previous definition of reference to org.clojure:clojure:jar"

0:24 technomancy: Is that left-over debug stuff? Or something I should worry about?

0:24 muhoo: sgarrett: take off the leading ##'s

0:24 lazybot: ⇒ s

0:25 * emezeske laughs at lazybot.

0:25 technomancy: emezeske: not sure; is there any more context?

0:25 muhoo: those are bot-escapes

0:25 sgarrett: so, (count #{:fo :bar :baz})

0:25 emezeske: technomancy: Nope, just that line about 30 times with different values of "something:something:jar"

0:25 sgarrett: muhoo: Just tried that and it works. Thanks for the help.

0:26 technomancy: emezeske: hm; odd. I wonder if it's related to the way you're constructing a dummy project map. I haven't seen it in "regular" usage

0:26 does every successive invocation cause it?

0:26 emezeske: Yeah, it always happens

0:26 I gotta go play some starcraft. It's not critical, I'll dig into it later. ^_^

0:27 technomancy: feel free to open an issue with repro steps

0:27 emezeske: technomancy: Roger that. Later!

1:22 romanandreg: has anyone tried to have multiple arities in fn forms?

1:22 nevermind

1:22 ...

1:23 parenthesis error :-/

1:23 paredit is killing me

1:23 * seancorfield loves paredit :)

1:24 seancorfield: i was pairing with a colleague earlier who doesn't use paredit and i got so confused!

1:24 kept forgetting to close parens and brackets... nightmare... i can't imagine editing lisp/clojure without paredit!

1:28 romanandreg: well, the thing is that I'm not familiar with it yet

1:28 takes a time to get used to

1:28 but yeah, once you are proficient on it, it can become quite dependable

1:28 in order to code lisp dialects

1:55 how can I set argslist to functions that are generated from others?

1:56 G0SUB: there will be a paredit clinic at Clojure/West.

1:56 romanandreg: when I'm doing a doc over the symbol bound using def, the argslist is not there, and I can't find a way to add that meta to it

1:56 maybe with-meta could do

1:56 but that's a bit ugly

1:56 G0SUB: romanandreg, :arglists key in metadata.

1:57 romanandreg: GOSUB def forms don't receive the meta hash as a parameter

1:57 (doc def)

1:57 clojurebot: Excuse me?

1:57 romanandreg: (doc str)

1:57 clojurebot: "([] [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."

1:57 romanandreg: (doc def)

1:57 clojurebot: No entiendo

1:57 romanandreg: clojurebot: por que no entiendes?

1:57 clojurebot: I don't understand.

1:58 G0SUB: (def ^{:foo 1} x 42)

1:58 romanandreg: (meta x)

1:58 clojurebot: Excuse me?

1:58 romanandreg: (meta x) will be nil

1:58 G0SUB: romanandreg, (meta #'x)

1:59 romanandreg, metadata is in the var not the fn object.

1:59 romanandreg: I always get confused with the #'

1:59 seancorfield: (meta #'x)

1:59 you need the var

2:00 and you can do (def ^{:arglists ([x])} i identity)

2:00 oops (def ^{:arglists '([x])} i identity)

2:00 needs the '

2:00 romanandreg: yes

2:00 seancorfield: then (doc i) yields the expected result

2:01 romanandreg: if you are using both the ^{} and the string on def

2:01 does it still works

2:01 seancorfield: like this: (def ^{:arglists '([x])} i "some docs" identity)

2:01 romanandreg: it doesn't for me for some reason

2:01 yes

2:01 seancorfield: or (def ^{:arglists '([x]) :docs "some docs"} i identity)

2:01 romanandreg: it works with that example

2:01 seancorfield: err :doc

2:01 romanandreg: but not with mine… umm

2:02 let me see what is wrong

2:02 seancorfield: pastebin yours somewhere?

2:02 romanandreg: typoe

2:02 typo

2:02 seancorfield: 'k

2:02 romanandreg: argslist -> arglist

2:03 done!

2:03 seancorfield: thanks!

2:03 :-)

2:03 seancorfield: glad to help :)

2:03 the more i work with clojure, the more i like it...

2:05 G0SUB: seancorfield, et tu?

2:06 * seancorfield goes back to watching abelson & sussman's MIT 6.001 SICP lectures

2:08 romanandreg: seancorfield: yeah, I'm really digging it to

2:08 I come from Haskell land and really like the simplicity of it all, types are great for strict systems, but for most of cases you can just let it pass

2:08 and clojure is the closest thing I've found to Haskell's functional awesomeness

2:09 I'm porting some libraries that I'm missing from Haskellland :-), everything is going pretty smooth so far

2:24 seancorfield: we're using clojure for a lot of back end stuff in our internet dating platform at world singles

2:24 persistence, logging, i18n, xml, json, html email generation, log file analysis...

2:30 Raynes: seancorfield: Oh, World Singles is a dating platform?

2:31 G0SUB: seancorfield, how do you guys do i18n? any libs?

2:31 seancorfield, we use enlive for tempting and will need i18n soon.

2:32 seancorfield: we just store key / translation / locale in the DB and have a few functions wrapping that

2:33 we used to use properties files but we wanted a nice web UI for updating them and we have thousands of keys so a DB makes more sense

2:33 Raynes: seancorfield: You guys aren't affiliated with that christianmingle website with the annoying commercials, are you?

2:33 seancorfield: the fns are (get-resource key locale) and (format-string resource & args)

2:33 Raynes: Because I hate those commercials.

2:33 seancorfield: lol... no, christianmingle is not one of ours

2:33 we focus on ethnic verticals

2:33 Raynes: Excellent.

2:34 seancorfield: but we are doing animated TV commercials in iran and greece soon :)

2:34 Raynes: They can't be even remotely as terrible as the christianmingle commercials.

2:35 seancorfield: lol... ours are cute animations with local language narration (and some local cultural references)

2:35 you can see some of our sites listed here: http://worldsingles.com/ws2010/index.cfm

2:35 we've migrated ten sites to the new platform (that uses clojure)

2:35 Raynes: Haha, vietvibe. That's clever.

2:36 Awesome. We're getting to the point where we can say "Clojure is used for everything." and be completely serious.

2:36 "Don't believe me? Iranian dating, bro."

2:38 seancorfield: the sites on the new platform are pretty diverse: lovingbbw, deafsinglesmeet, vietvibe, latinromantico, italianosingles, salaamlove, muslimsingles and, coming soon, islamicmarriage

2:38 Raynes: seancorfield: Do you like your work? You're very committed to it all.

2:38 seancorfield: love my job :)

2:38 Raynes: :)

2:39 seancorfield: interesting problems to solve, interesting business space, we all work from home, and i love using clojure professionally :)

2:39 Raynes: I'm probably going to lose my work from home perk soon.

2:39 Mostly because it was never seen as a perk but as a limitation. I've gotten rather used to it though.

2:41 seancorfield: Saw your blog post btw. Thanks for the nerdcred. :>

2:42 alandipert: holy crap clojure/west is close

2:42 seancorfield: yeah, better start writing my talk i guess...

2:42 Raynes: Hah, that sounds like me pre-conj.

2:43 It was like a month before the conference and I'm like "Meh, I've still got time…"

2:43 And then I nearly killed myself writing the thing.

2:43 alandipert: came out awesomely though, i can only hope for such success!

2:43 Raynes: <3

2:44 * Raynes hopes there will be copious videos.

2:44 Raynes: I wont be making this one. Above my paygrade.

2:44 alandipert: uploading the last of the next batch atm

2:44 (conj vids)

2:44 Raynes: Yeah, I mean from c/w.

2:44 alandipert: oh, yeah, me too

2:45 seancorfield: your talk was awesome at the conj Raynes !!

2:45 Raynes: Double <3

2:45 seancorfield: C/W is right in my back yard

2:46 and two of my team will be there too - Charlie (who was at the Conj) and Fumiko

2:47 alandipert: i'm amped to hang with the west coast clj crew

2:47 i've always wanted to go to a bay area clj meeting

2:47 seancorfield: we generally get about 30-40 people at meetings... lots of interest around here...

2:48 alandipert: brenton ashworth has told me stories

2:52 well, g'night all

2:52 G0SUB: seancorfield, OK. Isn't perf an issue?

3:03 seancorfield: performance of clojure? no... why would it be? G0SUB

3:04 or do you the i18n stuff in general?

3:07 G0SUB: we load the keys into memory and cache them (in an atom) and we reset! it if they change in the DB and we need to reload them

3:08 G0SUB: seancorfield, cool! I was talking about the perf of the i18n strings being in the DB.

3:08 seancorfield: our entire i18n package is just 41 lines including comments and whitespace :)

3:08 G0SUB: seancorfield, :-)

3:09 seancorfield: anyways... time for bed here...

3:56 Raynes: Huh.

3:57 Functions called from within an Enlive template don't inherit the bindings that were in place when the template was called.

3:57 Nobody ever caught that? It's a pretty massive bug, one would think.

4:01 * Raynes is not sure if he should bother reporting it, since Enlive's issue tracker seems to be where bugs go to live for eternity.

4:02 vijaykiran: seems like there will be some action again soon - I saw a couple of comments on the issues by cgrand recently

4:03 of course this is not a conclusive evidence though

4:03 Raynes: I'm just not a fan of leaving pull requests without comment for years.

4:04 vijaykiran: agreed, but I'd report it though, just to help others who wonder about the same thing.

4:05 * Raynes is still shocked nobody else has.

4:05 Raynes: I'm still googling in disbelief.

4:06 raek: Raynes: what behavior did you expect?

4:06 vijaykiran: I started using enlive pretty recently - so I'm still using simple transformations. So I'm not sure about the bug you are talking about

4:06 raek: that Enlive would use bound-fn somehow?

4:07 or what kind of bindings are you referring to?

4:07 Raynes: raek: (defn x [] (prn *out*)) (binding [*out* "foo"] (x))

4:09 Well, obviously that doesn't work because string isn't a writer.

4:09 raek: this should print "foo". what about the enlive case?

4:09 Raynes: But anyways, *out* should be "foo".

4:09 raek: hrm, yeah

4:09 Raynes: If x is an enlive template (which is also a normal function), it does not get the inherited value.

4:09 Something enlive does blows away the bindings.

4:09 Not sure what though.

4:09 raek: (def ^{:dynamic true} *foo*) (defn x [] (prn *foo*)) (binding [*foo* "foo"] (x))

4:10 ok, that sounds like something that should either be fixed or documented

4:11 Raynes: It's probably a result of everything being wrapped in 27 functions and other magic.

4:11 raek: so a template behaves as if it was wrapped with bound-fn?

4:11 Raynes: Yes.

4:13 * Raynes sighs, really not wanting to delve into the major hax it'll take to get around this so he can continue his work.

4:15 Raynes: Okay, guess I'm filing an issue.

4:15 Not optimistic.

4:17 ejackson: Happy Monday, everyone.

5:07 cindy1986: Hi ;)

5:08 Why is leiningen taking so much CPU ?

5:13 lucian: because JVM

5:19 cindy1986: damn jvm

5:28 warning: [options] bootstrap class path not set in conjunction with -source 1.5 << what does it mean?

5:29 vijaykiran: compiling the sources with 1.5 source but with >1.6 classpath ?

5:30 cindy1986: how can i set another value for that in project.clj ?

5:37 vijaykiran: I'm not sure where you are getting the -source option from .. can you paste the project.clj somewhere ?

5:46 cindy1986: vijaykiran: https://gist.github.com/1815984

5:49 vijaykiran: and you get this warning when you are running lein run ?

5:51 I just used the same with a new temp project, and I don't get any warning. Not sure what you are trying to do though. Create a project with java and clojure sources ?

5:51 cindy1986: ^^

5:51 cindy1986: java 1.7 ?

5:51 problem occured after updating to 1.7 on linux

5:52 vijaykiran: ah okay. could be the cause of the warning then. I don't have 1.7

5:52 cindy1986: Don't know vijaykiran

5:52 vijaykiran: may be one of the projects that you are pulling via project.clj, might have source setting

5:55 cindy1986: where is the damn source setting?

5:57 vijaykiran: probably in one of the deps you are pulling

5:58 https://blogs.oracle.com/darcy/entry/bootclasspath_older_source

5:59 cindy1986: ahh ok

5:59 yes

5:59 got it ;)

6:19 osa1: what is the minimum library requirement to create a clojure app that communicates with a web server? actually I want to create a webapp with clojure but I don't want to learn lots of libraries for now. so I'll keep third party libraries minimum.

6:19 vijaykiran: ring, compojure

6:19 or ring + moustache

6:20 zxcxzc: im trying counterclockwise. just because i already had eclipse. but i hear there's others, like la clojure? is that better?

6:20 dbushenko: just ring if you're talking about really minimum

6:20 vijaykiran: zxcxzc: yeah, la clojure is fine too .. if you are used to IntelliJ

6:20 dbushenko: zxcxzc, yep, I tried both and LaClojure is better

6:22 osa1: vijaykiran: thanks. I think I'll go with ring. what are my webserver alternatives?

6:22 vijaykiran: jetty/netty

6:22 just add the jetty adapter for ring

6:22 dbushenko: tomcat

6:23 zxcxzc: im not used to intellij. but it's available for free too these days, right?

6:23 vijaykiran: yes community edition + laclojure works fine

6:24 dbushenko: osa1, btw, it would be much better if you've tried Noir (webnoir.org). You'll find yourself making the website with clojure quick and easy. much easier than with pure ring

6:31 cemerick, a few days ago bought "Clojure Programming". Great work! Most practical book about clojure I've read so far!

6:32 cemerick: dbushenko: Thank you :-)

6:32 tell your friends, and have them tell 5 more ;-)

6:32 dbushenko: :-) sure!

6:33 vijaykiran: cemerick: +1 for the book, been reading it on Safari Rough Cuts

6:34 cemerick: dbushenko, vijaykiran: Keep an eye on http://clojurebook.com or https://twitter.com/#!/clojurebook for updates re: sample code and errata

6:36 vijaykiran: sure

6:37 cemerick: Anyway, glad you guys are enjoying it. Hopefully it'll be in print before Clojure/west.

6:38 lucian: cemerick: is an ebook version planned?

6:41 cemerick: lucian: Yup, it'll be available in kindle, mobi, and epub IIRC.

6:42 If you get the Rough Cut, you can download a PDF of that (and then a copy of the final book when it ships).

6:43 lucian: cemerick: would that be DRM-free? afaik safari is drm-only

6:43 cemerick: You mean the downloaded PDF? I honestly don't know.

6:44 lucian: i'll just wait for the epub then (i'm assuming that one is DRM-free)

6:45 vijaykiran: safari pdfs are DRM -free

6:47 osa1: where are json functions in clojure 1.3? I tried clojure.data.json but got an FileNotFoundException

6:48 cemerick: lucian: yeah, looks like O'Reilly is strictly no-DRM http://shop.oreilly.com/category/ebooks.do

6:48 lucian: cemerick: nice, thanks

6:48 vijaykiran: osa1: did you add clojure.data.json dependency ?

6:48 dbushenko: osa1: try cheshire

6:49 vijaykiran: osa1: https://github.com/clojure/data.json

6:49 cheshire is better though

7:16 cindy1986: #on clojure

9:15 zxcxzc1: hmm, i installed intellij and la clojure and the leiningen plugin, but there doesnt seem to be a "lein repl"

9:18 vijaykiran: you just need to use start clojure console

9:18 look under tools menu

9:20 zxcxzc1: had to add the lib folder in the project settings

9:20 so now the clojure repl works

9:20 although that seems a bit wrong

9:31 vijaykiran: I think laclojure comes with its own clojure - 1.2, so yes, you need to setup to use the correct clojure version

9:50 mklojure: I want to read an entry, when it is null, the entry should be created. Can I pack this into the "let" bindings ?

9:57 morphling: mklojure: (let [entry (or (read-entry) (create-entry))] ...) are you looking for or?

9:57 mklojure: is create entry used if read-entry is false? morphling ?

9:59 morphling: mklojure: ah, yes, didn't think of that

10:01 mklojure: What is the best way to store a list of strings?

10:01 clojurebot: Gabh mo leithscéal?

10:01 mklojure: seq?

10:01 clojurebot: #<ClassCastException java.lang.ClassCastException: clojure.lang.Cons cannot be cast to clojure.lang.IPersistentStack>

10:04 morphling: mklojure: depending on what you want to do with them a set, vector, or list. each of these is seqable

10:04 mklojure: set is okay,... how can I create a set in clojure?

10:04 TimMc: mklojure: Specifically, 1) how will you create the list, 2) how will you access it?

10:05 morphling: ,(doc set)

10:05 clojurebot: "([coll]); Returns a set of the distinct elements of coll."

10:05 joly: ,(= (set 1 2 3) #{1 2 3})

10:05 clojurebot: #<ArityException clojure.lang.ArityException: Wrong number of args (3) passed to: core$set>

10:05 mklojure: how will you create the list << set of hashes with initial hash to create the set

10:06 TimMc: &(conj #{} "foo" "bar" "qux")

10:06 lazybot: ⇒ #{"foo" "bar" "qux"}

10:06 joly: oops...

10:07 TimMc: If all you need is a set, my two questions actually don't matter.

10:07 mklojure: ,(set "hash")

10:07 clojurebot: #{\a \h \s}

10:07 mklojure: I want to build a structure to store collections in memcached

10:08 [head node] => leaf: headname_checksum

10:08 joly: (set ["hash" "test" "abcde"])

10:08 ,(set ["hash" "test" "abcde"])

10:08 clojurebot: #{"abcde" "hash" "test"}

10:10 mklojure: ,(set "hash" "hash2")

10:10 clojurebot: #<ArityException clojure.lang.ArityException: Wrong number of args (2) passed to: core$set>

10:10 mklojure: ,(set ["hash"])

10:10 clojurebot: #{"hash"}

10:10 mklojure: yeah

10:10 How to generate UUID in clojure?

10:11 vijaykiran: just use java uuid generator ?

10:12 mklojure: ;)

10:13 francisl: Hi, Im trying to start a project in clojurescript and an empty file to a basic def statement it throws an error

10:13 -- No protocol method ILookup.-lookup

10:14 can someone give me a hint on how to go from there?

10:15 vijaykiran: francisl: can you tell us how you created the project ?

10:15 francisl: just put a cljs file in a directory. and create the output with : cljsc myfile.cljs > myfile.js

10:16 I tried to follow the quickstart on the github wiki page

10:19 vijaykiran: hmm .. works fine for me ..

10:19 what does your file contian ?

10:21 francisl: I tried with nothing, got the error. I tried with a simple (ns employee) (def employees ["some data"]), same error

10:22 TimMc: Could be a CLJS bug. It's in alpha or so.

10:25 vijaykiran: works fine, with that - 1. Cloned the repo 2. ./script/bootstrap 3. created a cljs file with the code that you pasted

10:26 works fine - and I see the result javascript

10:33 francisl: humm, thank, I'll tried to reinstall it all

10:38 ohpauleez: ibdknox: Any word on the possibility of a korma CQL partial merge?

10:42 LauJensen: ^

11:30 mklojure: ,(concat (set "") "x")

11:30 clojurebot: (\x)

11:31 mklojure: ,(concat (set [""]) ["x"])

11:31 clojurebot: ("" "x")

11:32 mklojure: How to generate empty set?

11:32 ,(set)

11:32 clojurebot: #<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: core$set>

11:32 mklojure: ,(set nil)

11:32 clojurebot: #{}

11:32 terom: ,#{}

11:32 clojurebot: #{}

11:33 mklojure: ,(concat #{} ["x"])

11:33 clojurebot: ("x")

11:33 mklojure: yeah

11:36 when I have two instructions,... how can i execute both?

11:36 (creplace bucket (concat currentbucket leafkey) (cset leafkey value))

11:36 (cset leafkey value) is the 2'nd

11:36 (creplace bucket (concat currentbucket leafkey)) the 1'st

11:39 AWizzArd: mklojure: just write them one after each other.

11:40 mklojure: you can test this: (println "command 1") (println "command 2")

11:40 lucian: although theoretically execution order is not guaranteed unless it's in a (do ...)

11:40 mklojure: even it is in a let ... ?

11:40 AWizzArd: lucian: why is it not guaranteed?

11:40 From left to right.

11:40 This is how it happens.

11:41 as the forms are read

11:43 mklojure: ,(concat #{} "iluv_9e3c286d-d6a8-4ca6-98a7-5642e614aae5")

11:43 clojurebot: (\i \l \u \v \_ ...)

11:43 TimMc: mklojure: conj

11:43 mklojure: ,(concat #{} ["iluv_9e3c286d-d6a8-4ca6-98a7-5642e614aae5"])

11:43 clojurebot: ("iluv_9e3c286d-d6a8-4ca6-98a7-5642e614aae5")

11:43 TimMc: &(conj #{} "hello")

11:43 lazybot: ⇒ #{"hello"}

11:44 TimMc: &(disj #{"hello"} "hello")

11:44 lazybot: ⇒ #{}

11:44 AWizzArd: do is not really doing anything, it is a helper for macros, where exactly one form is expected

11:44 for macros ==> for places

11:47 mklojure: #<ClassCastException java.lang.ClassCastException: net.spy.memcached.internal.OperationFuture cannot be cast to clojure.lang.IPersistentCollection>

11:47 mh,.. !

11:47 (cset bucket #{})) in a let returns the OperationFuture

11:48 TimMc: Something is expecting a collection, you're only giving it a bare item.

11:51 lucian: AWizzArd: you may have a point in that clojure does it differently. but all lisps i've seen so far don't guarantee it

11:51 TimMc: lucian: Are you sure you aren't thinking about argument eval order?

11:52 Oh wait, you definitely are.

11:52 nvm

11:52 Yes, some lisps make a guarantee, others do not.

11:53 I *believe* Scheme48 evals the even-index arguments first, and then the odd-index arguments in reverse order -- just so that people don't rely on an ordering.

11:53 jsabeaudry: Any suggestions regarding a client side UI framework with clojurescript?

11:54 lucian: TimMc: heh. it should just do it randomly

11:54 jsabeaudry: twitter bootstrap

11:58 vijaykiran: jsabeaudry: depends on what you mean by "framework"

11:58 mklojure: (let [leafkey (str bucket "_" (uuid)) currentbucket (or (cget bucket) (cset bucket #{}))] (creplace bucket (concat currentbucket [leafkey])) (cset leafkey value))

11:58 cset returns the OperationFuture

12:00 But I think it is still not so nice... cause I know that I can "prefill" the collection with the leafkey and set it. To create a new one only to be able to make the replace there,... mhhh

12:00 TimMc: mklojure: I think you missed my earlier comment that conj is way more appropriate than concat with a single-element coll.

12:00 mklojure: I tried it TimMc, but it also ends up with problems

12:00 (concat currentbucket [leafkey]) => (conj currentbucket leafkey)

12:01 TimMc: Ah... what type is currentbucket?

12:01 zzach: Question about a function containing def ^:dynamic ... and binding ...: after entering this function (http://pastebin.com/9H5J2yTL) into the Clojure 1.3 repl, it returns "resultA", after entering it a second time, it returns "resultB". Why does it not directly return "resultA"?

12:02 TimMc: mklojure: concat produces a lazy seq, conj produces an object of the same abstraction type

12:02 raek: zzach: you are not supposed to use 'def' inside another def

12:03 def does not create a local variable, it creates a global variable (if it didn't exist) and sets it value in a non-threadsafe manner

12:03 mklojure: Ok, it works also with conj

12:04 <ClassCastException java.lang.ClassCastException: net.spy.memcached.internal.OperationFuture cannot be cast to clojure.lang.IPersistentCollection> << mhhh!!1

12:04 zzach: raek: i expected "resultB" as result. How to set the variable locally so that binding does not complain?

12:05 raek: zzach: if you want to play with :dynamic and binding, you need to structure your code like this:

12:05 (def ^:dynamic var1 "resultA")

12:05 (defn test1 [] (binding [var1 "resultB"] var1))

12:06 this will always return "resultB"

12:06 mklojure: can I cascade let and if-let ?

12:08 TimMc: mklojure: You can nest them, yes.

12:08 zzach: raek: OK, it returns "resultB". Can it be achieved if var1 is not already declared at time of function test1 execution?

12:08 mklojure: (if-let [currentbucket (cget bucket)] << does it do what I want if bucket is NIL ?

12:08 raek: zzach: a rule of thumb is if you have a "def___" form inside a function, you are doing something wrong

12:09 TimMc: mklojure: That depends on what cget is.

12:09 raek: zzach: If I understood you correctly, no. binding only works on already defined top-level vars

12:09 mklojure: cget is a fn, queries memcached

12:09 returns nil or the value

12:10 of a speficied key

12:10 raek: zzach: are you looking for something like variable assignment in imperative languages?

12:10 TimMc: mklojure: Well, I still don't know what that means for you here... if-let only cares about the return value of cget.

12:10 mklojure: okay, and if it is nil if-test will yield to else ?

12:10 not nil to true ?

12:11 TimMc: Sorry, I couldn't parse that.

12:12 zzach: raek: in principle yes, was also trying let, which allows only one-time assignments.

12:12 TimMc: &(if-let [x 42] (str "consequent " x) "alternative")

12:12 lazybot: ⇒ "consequent 42"

12:12 TimMc: &(if-let [x nil] (str "consequent " x) "alternative")

12:12 lazybot: ⇒ "alternative"

12:12 mklojure: TimMc: cget returns nil or something other

12:12 yeah

12:12 thx

12:13 raek: zzach: the only answer I can give you is "it depends on what you want to solve with assignment" :-)

12:17 mklojure: It works!

12:17 (let [leafkey (str bucket "_" (uuid)) newitem (cset leafkey value)] (if-let [currentbucket (cget bucket)] (creplace bucket (conj currentbucket leafkey)) (cset bucket [leafkey])))

12:17 Any ideas how to improve / write it more compact / better style ?

12:18 One thing I was not sure about is "newitem",... I don't need it but wanted it to happen before yielding

12:18 raek: zzach: assignment is used for many things. one usage is for updating loop variables, another is in conditions (like int y; if (x < 0) { y = -x; } else { y = x; }), a third is to mutate a object

12:18 zzach: clojure has a different approach to all three cases

12:18 for number one, check my answer to this question: http://stackoverflow.com/questions/8540855/setf-in-clojure/8564082#8564082

12:18 for number two: you can do it like this in clojure (let [y (if (neg? x) (- x) x)] ...) since if is an expression rather than a statement

12:18 for number three: check out 'atom' and 'ref': http://clojure.org/atoms http://clojure.org/refs

12:23 zzach: raek: In case two, does y automatically change if x is changed?

12:26 r0adrunner: hi! anyone knows how to solve character encoding issues with enlive's deftemplate?

12:27 raek: zzach: x cannot be changed

12:28 in clojure, locals introduced by let and function parameters are alway unchangeable. they act as a name for a value rather than a mutable cell

12:28 r0adrunner: I know a little

12:29 r0adrunner: have you identified whether the problem is when you read the template or when you generate the http response?

12:30 r0adrunner: raek: i think is when i read the template... this works: (defpage teste "/teste" []

12:30 (slurp "resources/templates/newuser.html"))

12:30 raek: but this shows black diamonds:

12:30 raek: ok, that can explain it

12:30 r0adrunner: raek: (defpage newuser "/newuser" []

12:30 (view/template-newuser))

12:30

12:31 raek: slurp always uses UTF-8 unless you provide a :encoding option

12:31 enlive uses some automatic encoding detection mechanism which can guess the wrong encoding

12:31 r0adrunner: raek: i want to default to utf-8

12:32 raek: r0adrunner: are you using deftemplate?

12:32 armpants: hi, does anyone know where to find an xmpp library that supports mutli-user-chat in clojure?

12:32 r0adrunner: raek: yes

12:33 raek: r0adrunner: I think you should be able to write (io/reader (io/resource "some/path") :encoding "UTF-8") instead of "some/path"

12:33 TimMc: armpants: Check the Java world too.

12:34 raek: r0adrunner: sorry, io/reader defaults to UTF-8 too, so (-> "some/path" io/resource io/reader) should be enough

12:34 armpants: Thanks, I'll try that. I'm a newb, and so not so confident in my ability to wrap a java library, but I'll try. Thanks.

12:36 raek: r0adrunner: did it solve the problem?

12:37 r0adrunner: raek: im trying right now

12:37 * raek wishes more libraries would be brave and say "sorry, we only support UTF-8"

12:38 mklojure: r0adrunner: yes, I know

12:38 enlive's deftemplate? I had encoding issues with jetty not with netty

12:39 raek: r0adrunner: you might also need to add a "Content-Type: text/html; charset=UTF-8" header if your web stack does not already provide it

12:39 mklojure: r0adrunner: or try this: ; To fix issues that appear for Jetty (not Netty) with UTF-8 responses (defn utf8response "Ring skeleton with headers." [body] {:status 200 :headers { "Content-Type" "text/html;charset=UTF-8" "Character-Encoding" "UTF-8"} :body body})

12:40 raek: otherwise, if the header is just "Content-Type: text/html" then the servlet infrostruvture will "correct it" to "Content-Type: text/html; charset=iso8859-1"

12:40 mklojure: yeah. Netty deals with this issue

12:40 Got long time to figure it out

12:40 raek: *infrastructure

12:41 mklojure: r0adrunner: did it work for you?

12:42 r0adrunner: raek: first solution dont seem to have worked. I am using noir.. how to change the encoding for that

12:43 raek: r0adrunner: dunno. I haven't used noir myself yet. you need to make sure that enlive gets the reader you provided somehow

12:44 if enlive gets a reader, it won't try to guess the encoding itself

12:45 r0adrunner: raek: tried that: (deftemplate template-profile (clojure.java.io/reader (clojure.java.io/resource "templates/profile.html") :encoding "UTF-8"))

12:45

12:45 raek: what happened?

12:45 r0adrunner: raek: what do you mean by make sure that enlive gets the reader you provided?

12:45 raek: ah, you are using deftemplate directly

12:45 r0adrunner: raek: same result in browser

12:46 raek: I thought you were using something in noir that abstracted enlive away

12:46 mklojure: damn headers

12:46 raek: are you sure the page isn't cached or something?

12:47 r0adrunner: i am.. (defpage profile "/user/:nick" {:keys [nick]}

12:47 (view/template-profile {:nick nick})

12:47

12:47 raek: have you reloaded the view namespace?

12:47 r0adrunner: raek: does not seem to be cached

12:49 raek: does not seem to be a namespace thing

12:49 raek: weird

12:51 r0adrunner: are you sure the file is in UTF-8?

12:51 rodrigovieira: hello everyone

12:51 how do I know the size of a vector in Clojure?

12:52 raek: rodrigovieira: count

12:52 r0adrunner: raek: yes

12:52 TimMc: $findfn [1 4 5] 3

12:52 lazybot: [clojure.core/count]

12:52 raek: r0adrunner: which version of enlive are you using?

12:53 r0adrunner: 1.0.

12:53 1.0.0

12:53 noir 1.2.1

12:54 raek: r0adrunner: if you run (apply str (template-profile <some valid argument here>)) in the repl, does the characters look correct there?

12:54 r0adrunner: raek: there is some answers in google refering to using a middleware, but in noir page it says it is deprecated bcause ring already does the utf-8 encoding by default

12:55 raek: ok, good

12:55 the enlive coding handling is still broken, though

12:55 rodrigovieira: raek: thanks

12:56 raek: this is strange... (deftemplate template-profile (io/reader (io/resource "templates/profile.html")) ...) should just work!

12:56 r0adrunner: raek: yes.. it prints the character im trying to print: ç

12:57 raek: r0adrunner: what repl are you using?

12:57 r0adrunner: raek: even without clojure.java.io it prints everything well in the repl.

12:57 raek: r0adrunner: if you remove my io/... fix, does the character become broken again?

12:58 r0adrunner: the problem with encoding bugs is that sometimes they can undo themselves

12:58 there are encoding problems in some repl setups too... :(

12:58 r0adrunner: im using the emacs repl,,

12:58 raek: using clojure-jack-in?

12:58 r0adrunner: yes

12:58 raek: then you're good

12:59 jcromartie: there are two kinds of encodings: UTF-8, and the wrong kind

12:59 r0adrunner: it used to have problems with encoding but i fixed it somehow..

12:59 raek: this seems to indicate that the error is not with enlive (and that is sucessfully guesses the encoding to be UTF-8)

12:59 if you used slime-connect, you needed to set slime-net-coding-system to utf-8-unix

13:00 but clojure-jack-in takes care of that nowadays

13:00 jcromartie: yes. agreed!

13:00 r0adrunner: tried with curl in shell, same thing.. wrong encoding

13:01 raek: have you tried adding the "Content-Type: text/html; charset=utf-8" header?

13:01 r0adrunner: how to do that

13:01 :

13:01 raek: r0adrunner: oh, can you check in curl which header it actually sends?

13:02 r0adrunner: GET /newuser HTTP/1.1

13:02 > User-Agent: curl/7.24.0 (x86_64-unknown-linux-gnu) libcurl/7.24.0 OpenSSL/1.0.0g zlib/1.2.6 libssh2/1.3.0

13:02 > Host: localhost:8080

13:02 > Accept: */*

13:02 hsbot: mueval-core: L.hs: removeLink: does not exist (No such file or directory)

13:02 Not in scope: data constructor `User'Not in scope: data constructor `Agent'Not in scope: `curl'Not in scope: `x86_64'Not in scope: `unknown'Not in scope: `linux'Not in scope: `gnu'Not in scope: `libcurl'Not in scope: dat...

13:02 mueval-core: L.hs: removeLink: does not exist (No such file or directory)

13:02 r0adrunner: >

13:02 < HTTP/1.1 200 OK

13:02 < Date: Mon, 13 Feb 2012 18:03:11 GMT

13:03 < Set-Cookie: ring-session=22bc8e8a-fa67-4695-85df-1911137b26ed;Path=/

13:03 < Transfer-Encoding: chunked

13:03 < Server: Jetty(6.1.25)

13:03 <

13:03 raek: sorry.. didnt know which line is important...

13:03 pmooser: Anyone here have much experience with using ritz ? I've only gotten it to work for me by hacking on it, but I don't understand why those hacks are required.

13:04 hugod: pmooser: I would be interested in hearing what you needed to do to get it to work

13:06 r0adrunner: raek: the html file has the "Content-Type: text/html; charset=utf-8"

13:08 raek: any clue?

13:10 raek: you think enlive character coding handling is broken?

13:10 mklojure: r0adrunner: have you tried jetty?

13:10 I think it is not about enlive

13:11 I use it too and had the same issues

13:11 It's about the standard headers that are set for a http response

13:12 Do you have a response method r0adrunner like (def routes (app ...

13:12 ["change"] (fn [req] (response ....

13:12 it works with utf8response

13:12 ; To fix issues that appear for Jetty (not Netty) with UTF-8 responses (defn utf8response "Ring skeleton with headers." [body] {:status 200 :headers { "Content-Type" "text/html;charset=UTF-8" "Character-Encoding" "UTF-8"} :body body})

13:12 jcromartie: so, who's hiring wannabe-Clojure/JDK devs nowadays?

13:13 I know computers. Hire me.

13:13 mklojure: good q. jcromartie !

13:13 I configured internet rouaters

13:14 r0adrunner: mklojure: i use noir's defpage.. can u explain how to setup that code u just wrote?

13:15 mklojure: I use enlive and moustache, can you post your code as gist?

13:15 ring.adapter.jetty << ...

13:15 https://gist.github.com/

13:18 have you tried http://webnoir.org/autodoc/1.2.0/noir.util.middleware-api.html#noir.util.middleware/wrap-utf-8 ? r0adrunner

13:21 r0adrunner: mklojure: Unable to resolve symbol: wrap-utf-8 in this context

13:22 mklojure: it says that it is deprecated in that page

13:23 mklojure: yes r0adrunner , depends on which version you use

13:24 http://webnoir.org/tutorials/middleware

13:24 example for utf-8 !?

13:24 damn! Nothing is working really out of the box

13:24 :D Just like Noir

13:25 r0adrunner: mklojure: that worked for you?

13:25 mklojure: https://gist.github.com/1818843

13:26 mklojure: r0adrunner: I do not use Noir

13:27 Just Moustache + Enlive directly

13:27 r0adrunner: mklojure: oh.. right..

13:29 mklojure: r0adrunner: https://github.com/kremers/Clojure-Memcached-Connector

13:37 r0adrunner: mklojure: Worked! Thanks a lot

13:37 raek: thanks too!

13:37 mklojure: yeah

13:37 r0adrunner: what are you working on?

13:38 r0adrunner: mklojure: a miniblog to post photos. a "pet project" to learn clojure

13:39 mklojure: Ahh nice ;)

13:40 And how does your stack look like? Noir, Enlive, MySql ?

13:42 r0adrunner: mklojure: noir, enlive and trying mongodb...

13:42 mklojure: good exp with mongodb ?

13:42 I like memcached cause it is so fast

13:42 and with membase there is persistence management and authentification etc.

13:42 r0adrunner: mklojure: i think mongodb fits well with the dynamic flow of clojure..

13:43 mklojure: I think mongo is a bit heavyweight?

13:44 antares_: r0adrunner: if you are using mongodb with clojure, check out monger (https://github.com/michaelklishin/monger) and validateur (https://github.com/michaelklishin/validateur) for data validation. We hope to push initial documentation site for Monger up this weekend.

13:44 r0adrunner: mklojure: i have not done anything with it in production... i just like how i can shove data into it, and it manages to add fields and stuff

13:44 antares_: tnx.. i will check it out

13:45 mklojure: http://www.couchbase.com/couchbase-server/features#production_ready

13:45 check this out

13:47 r0adrunner: anything online to see?

13:49 r0adrunner: mklojure: no.. i am yet trying to print input on screen and getting it right :)

13:49 mklojure: used it in production? couchbase?

13:50 mklojure: output i mean

13:53 mklojure: nope r0adrunner

13:53 Want to do this :)

14:13 Does anyone know how to build a Lazy seq behind a future : http://dustin.github.com/java-memcached-client/apidocs/net/spy/memcached/MemcachedClient.html#asyncGetBulk(java.util.Collection)

14:14 Now I've done it like this: (defn cgetall "Read the full collection" [bucket] (let [nodes (cget bucket)] (.getBulk (find-connection) nodes)) )

14:16 TimMc: any idea?

14:25 detryo: Hi, which http client would you recomend? http.async.client or clj-http?

14:25 technomancy: clj-http for sure

14:26 detryo: since I'm more familiar to the async client in java I was about to choose http.async.clinet

14:26 but it is true that the documentation looks more complete for clj-http

14:27 thank you technomancy

14:38 amalloy: mklojure: "build a lazy seq behind a future" doesn't mean anything as far as i can tell

14:40 mklojure: amalloy: cause the future itself is already kind of lazy?

15:01 Belaf: Hello list! Anybody using clojure.java.jdbc with sqlite-jdbc ? I used to have no issue with clojure.contrib.sql, but moving to clojure 1.3 (and thus clojure.java.jdbc) I keep getting "java.sql.SQLException: database is locked".

15:41 gtrak`: #clojure

15:42 Bronsa: yes, this is how this chan is called :P

15:42 mklojure: yeah yeah yeah

15:42 gtrak`: indeed

15:42 mklojure: let get crazy-clojure

15:43 ritre: Xen+alS3

15:44 ahh, sorry

15:45 TimMc: Now tell us what that's the password for! :-)

15:45 mklojure: secret porn collection'?

15:45 https://github.com/vim-scripts/VimClojure/blob/master/ftplugin/clojure.vim

15:45 Does anyone know if a good documentation for all this shortcut stuff exists?

15:46 ritre: true that is password :)

15:48 tmciver: That *was* a pretty good password. :/

15:49 TimMc: Fairly memorable, too.

15:50 ritre: just accdent, bad window wos focused, pretty stupid

15:53 TimMc: happens to me all the time, luckily not into IRC

15:59 rahcola: does anyone know whats happening when slime gives Evaluation aborted without other errors?

16:00 amalloy: it's always so horrifying to see your password in plaintext. i usually react like..."wait, i didn't realize fonts could render this, i thought it existed only in my head and rendered as ****"

16:02 hugod: rahcola: hava a look at *e, which should be bound to whatever exception caused that

16:03 rahcola: hugod: thank you

16:03 any idea why those exceptions are not presented in the usual manner?

16:04 raek: rahcola: did you try to display a string with non-ascii characters?

16:04 rahcola: noup

16:04 ritre: Typing password to IRC, it's really memorable.

16:05 rahcola: it was a IllegalArgumentException from calling a method for nil

16:05 raek: /msg NickServ IDENTIFY hunter2

16:07 hugod: rahcola: assuming this is swank-clojure, no idea

16:12 pjstadig: hugod: your change here https://github.com/technomancy/clojure-mode/commit/cdfc45850b29700dda83a148e1c90ed2219ab943 is wreaking havoc on my formatting

16:13 https://github.com/technomancy/clojure-mode/issues/63

16:13 hugod: is there something i need to configure?

16:14 hugod: pjstadig: mm, not sure swank-clojure updates indentation

16:15 pjstadig: i've found pulling out that add-hook fixes the issue, but i wonder if there's a way to make it play more nicely

16:15 hugod: i guess the indentations in clojure-mode need to get back into swank-clojure somehow

16:16 using the hook you can write macros, and set ^{:indent n} so they indent properly when used

16:16 amalloy: raek: nobody seems to be taking the bait and telling you they just see it as *******

16:17 raek: amalloy: yeah..

16:17 hiredman: hugod: neat

16:18 raek: re. "hunter2": http://bash.org/?244321

16:18 aphyr: If I have some code that needs to be run once at JVM startup (configuring log4j)... where should I put it?

16:19 ordnungswidrig: aphyr: you can place it in any namespace that gets loaded.

16:19 (ns foo) (do-some-initialization)

16:36 * technomancy likes to defonce that kind of thing

16:36 aphyr: Ah, that's rather nice actually. Thanks technomancy, ordnungswidrig

16:44 TimMc: &(doc defonce)

16:44 lazybot: ⇒ "Macro ([name expr]); defs name to have the root value of the expr iff the named var has no root value, else expr is unevaluated"

16:44 TimMc: (defmacro uneval [& args] nil)

17:10 slewis: hi. How can I pass pre-defined fields in to defrecord? Ex: (def fields ['a 'b]) (defrecord R fields) doesn't work.

17:13 brehaut: (apply ->R fields)

17:14 slewis: also, keywords are more idiomatic than quoted symbols in clojure (eg, (def fields [:a :b]))

17:14 hiredman: brehaut: you are misunderstanding the question

17:15 brehaut: hiredman: oh, so i am

17:15 slewis: ignore me

17:16 slewis: ok :), didn't work

17:16 TimMc: slewis: Probably a macro.

17:18 slewis: so in (defrecord R [a b]), what are a and b? symbols that aren't evaluated til later?

17:20 amalloy: aren't evaluated ever

17:21 slewis: oh, right… but are they symbols?

17:21 amalloy: yep

17:22 TimMc: slewis: Are you sure you should even be using a defrecord?

17:23 slewis: why can't I do (defercord R [(symbol "a") (symbol "b")])

17:24 amalloy: because (symbol "a") isn't a symbol. it's a list which, if you evaluated it, would evaluate to a symbol

17:25 TimMc: slewis: Just use a regular ol' map.

17:26 slewis: TimMc: Well, its part of an interface within appengine-magic. Basically I want to be able to create a record, and have access to the field names for the created class at a later time.

17:26 without introspecting

17:26 emezeske: slewis: You'll have to write a macro to do that.

17:27 gtrak`: aren't there issues with defining records at runtime anyway, or protocols, maybe?

17:27 emezeske: (defmacro crazy-thing [a b] `(defrecord R [~a ~b]))

17:28 Or something horrible like that

17:28 amalloy: not really, gtrak. but who said anything about doing this at runtime?

17:28 ordnungswidrig: slewis: see here. http://stackoverflow.com/questions/5531986/treat-clojure-macro-as-a-function

17:28 gtrak`: amalloy: noone, I just want to make sure he's not trying to do that

17:29 slewis: gtrak: I'm not. I want to define some field names, use those to create a record, and later have access to the field names

17:29 ordnungswidrig: gtrak: using a macro to expand a macro "call" it ok.

17:29 gtrak: what emezeske suggested should work fine

17:29 gtrak`: yea

17:30 dnolen: slewis: why do you need a record?

17:30 TimMc: dnolen: Something to do with appengine

17:31 slewis: dnolen: I guess I could cite performance, but the real reason is because that's what the library i'm using wants

17:31 emezeske: dnolen: The appengine-magic interface to the GAE datastore is defined in terms of records

17:32 dnolen: slews: emezeske: does it actually need records? or can you provide a deftype or something created w/ reify

17:32 ?

17:32 slewis: I think the root of the problem is I don't fully understand how clojure macros work, so I'll look in to fixing that

17:32 dnolen: well it provides a macro (defentity …) which calls (defrecord ...)

17:34 dnolen: slewis: so look under the hood, you can probably do what you want on the fly w/ reify

17:34 slewis: I would lose the functionality the (defentity ) macro provides then if I follow you...

17:35 dnolen: slewis: defentity is just sugar

17:35 slewis: it provides some other functions

17:35 ordnungswidrig: slewis: so you can provide a macro which calls defentity which calls defrecord. But on the other hand why would you like to keep the arguments to defentity?

17:36 slewis: because I want to know the names of the fields that the entity was defined with

17:36 dnolen: slewis: if I'm understanding correctly you want to create the records dynamically right?

17:36 slewis: no

17:36 dnolen: slewis: oh ok

17:37 slewis: I just want to know the field names that the created class has

17:37 which I can get by introspecting the java class… but that seems wrong, since the field names are passed in at compile time and won't change

17:37 ordnungswidrig: slewis: assuming that defentity doesn't give you a way to access the fields later, then using a macro to call defentity and store the field names "somewhere" is perfectly possible.

17:38 slewis: ordnungswidrig: k, that's what i was thinking…

17:38 ordnungswidrig: slewis: have you read this? http://groups.google.com/group/clojure/browse_thread/thread/d134035d3efe8c7e

17:39 dnolen: slewis: is app-engine magic 1.3.0 compatible?

17:39 slewis: if so you have YouRecord/getBasis

17:40 slewis: ordnunswidrig: I hadn't, thank you

17:40 dnolen: yes it is

17:41 nathanmarz: technomancy: hey

17:41 dnolen: slewis: getBasis will give you vector of symbols that are the records fields

17:41 technomancy: nathanmarz: what are the haps?

17:41 nathanmarz: technomancy: does leiningen let you configure how often it updates SNAPSHOT deps?

17:41 e.g., every time or just periodically

17:41 slewis: dnolen: nice, didn't see that… that seems to be the best solution

17:41 technomancy: nathanmarz: IIRC maven-ant-tasks provides methods to do that, but they are no-ops.

17:42 ordnungswidrig: appengine-magic seems to define a method "get-clh-properties" on the entiy

17:42 technomancy: hopefully pomegranate/aether will do better in lein2

17:42 ordnungswidrig: slewis: https://github.com/gcv/appengine-magic/blob/master/src/appengine_magic/services/datastore.clj#L397

17:42 nathanmarz: ah ok

17:42 ordnungswidrig: "Returns a set of all properties which pass through the Clojure reader on their way in and out of the datastore."

17:43 nathanmarz: grazie

17:43 technomancy: nathanmarz: lein2 should be usable very soon though

17:44 ordnungswidrig: slewis: oh, ignore what I said, clj-properties is for "reader-format-persisted" properties only.

17:47 slewis: I still want to fix my mental model though… (defrecord name [fields]), what type of object is [fields] and why can't I pass it in from something pre-defined

17:48 TimMc: slewis: lrn2macro

17:48 That's really the only solution.

17:48 slewis: dnolen: getBasis was close, but (defentity) doesn't pass it through to the record object

17:49 TimMc: yeah, you're right. Thanks all

17:49 TimMc: defrecord is a macro; it is a syntax transformer; you cannot pass things to a macro like you can a fn

17:49 emezeske: slewis: [fields] is a vector of symbols

17:49 ordnungswidrig: slewis: you can, but you cannot "apply" a macro, thus you have to expand the application of the list of arguments yourself. This is done by a macro itself.

17:50 dnolen: slewis: that doesn't make sense based on the link ordnungswidrig pasted. you have to be using Clojure 1.3.0 for this to work.

17:52 gtrak`: ordnungswidrig: you can @ it for that

17:52 emezeske: slewis: (defmacro special-defentity [entity-name fields] `(do (def ~(symbol (str (name entity-name) "-fields")) ~fields) (defentity ~entity-name [~@fields])))

17:52 slewis: totally untested, probably broken

17:54 ordnungswidrig: emezeske: like that, or maybe better by using a protocol: (defprotocol SelfAwareEntity (field-names [this])) and a matching macro to extend-protocol the defined entity in special-defentitiy

17:54 slewis: dnolen: hmm yeah looking it at it should work… and now it works, I don't know what I did. sorry

17:55 emezeske: ordnungswidrig: that sounds cleaner!

17:55 ordnungswidrig: slewis: another so question on that: http://stackoverflow.com/questions/5925048/using-macros-in-clojure

17:56 emezeske: I don't use appengine-magic but it sounds like a reasonable extension to me

17:59 slewis: ordnunswidrig: I did see that before and it makes more sense now that I've talked to you all

18:00 ordnungswidrig: slewis: at least your google power was in place at the time needed *g*

18:00 slewis: its very rare that I make my way to IRC ;)

18:01 ordnungswidrig: slewis: in case of clojure it helps.

18:03 slewis: ordnungswidrig: so I see!

19:24 devn: Is it possible to have prompt-like behavior in the REPL using just clojure?

19:24 As in: Enter your name and hit enter

19:26 technomancy: devn: sure, as long as you have access to *in*, which you don't always in leiningen

19:26 print+flush+read-line

19:27 devn: technomancy: I guess I was thinking in the SLIME REPL -- what about that?

19:27 technomancy: what would cause me to lose access to *in*

19:27 TimMc: Ant throws away stdin -- trampoline doesn't help with that, does it?

19:28 technomancy: no, trampoline does

19:28 but slime is just not hooked up to stdin

19:28 it's hooked up to a socket

19:29 anyway, you can do it, I just don't know which streams you have to rebind and wrap to make it happen in swakn

19:33 devn: technomancy: hm, that's not ideal but I can take a peek and see if I can figure it out. If you have any pointers let me know, seems like you probably have a better handle on swank internals than me.

19:33 technomancy: hah

19:33 I don't really know anything about the internals actually

19:33 but I can see why you would make that mistake =)

19:34 devn: well, you're certainly more proficient in elisp

19:34 and yes I suppose I made the mistake of thinking: oh right, lein-swank

19:34 :)

19:34 swank-clojure, etc.

19:35 technomancy: you'll have to ask jochu

20:20 tmciver: technomancy: I'm trying to upgrade lein; I don't think I've ever done an upgrade since the original install some time ago. Do I simply put the lein shell script on my path? Do I need to run 'lein self-install' or is that for Windows users?

20:20 technomancy: it should be able to run self-install itself when necessary

20:20 placing it on the $PATH is enough

20:21 unless... (hint hint) you would like to try 2.x

20:21 TimMc: tmciver: just run lein upgrade

20:21 tmciver: OK, so just overwrite the old lein script?

20:21 technomancy: oh right; lein upgrade will do it too

20:21 tmciver: TimMc: Oh, didn't see that task.

20:21 technomancy: I haven't used that in ages but that's what you want

20:21 tmciver: OK, thanks.

20:39 photex: hello folks, I am experiencing a bit of discord between my understanding of a simple bit of code and what's actually happening.

20:40 looking at a blog post someone else has this problem and mentions that it's discussed in "Programming Clojure"

20:40 TimMc: $1.50 on "lazy seqs and binding"

20:40 photex: but I'm searching through the pdf and am having trouble locating the discussion

20:40 totally!

20:40 :)

20:40 TimMc: I was kidding... was I right?

20:41 photex: yes

20:41 haha

20:41 TimMc: clojurebot: You owe me.

20:41 clojurebot: No entiendo

20:42 TimMc: photex: I have the book; what page are you on?

20:43 photex: 158

20:43 I'm using with-open as suggested in the documentation

20:43 technomancy: so if my profiler shows most of the time being spent in sun.misc.Unsafe.park but the load is insanely high, that means I/O issues, right?

20:43 photex: on a reader that's being given a path

20:44 to a log file

20:44 and I thought that using (map my-func (line-seq logfile)) would work

20:45 but the stream is being closed, and I would like to understand why and learn what the correct approach to this is

20:45 TimMc: Hmm, I think we have different versions of the book.

20:45 photex: mine might be old

20:45 I haven't downloaded it in a while

20:45 technomancy: photex: you have to consume the seq produced by map inside the with-open call

20:45 photex: lemme check for an update

20:46 tmciver: Isn't there only one version of that book?

20:46 photex: technomancy: so use vector?

20:46 TimMc: photex: As technomancy said, map produces a lazy seq itself.

20:46 technomancy: that's one way to do it

20:47 depends what you're trying to do really

20:47 photex: tmciver my ebook says it's version P3.0 from July 2010

20:47 TimMc: photex: Wrapping the call to 'map in (dorun ...) would be a quick fix, but converting map to doseq would be better.

20:48 photex: ok awesome... thanks for the information. I didn't realize map was lazy :)

20:48 TimMc: photex: Wait, are you just doing side-effects in my-func, or getting back results you want?

20:48 I may have assumed something.

20:49 photex: right now, I'm trying to just do something that I did in Python in like 15 minutes (analyze a bunch of render logs)

20:49 figured that it would be a good way to learn

20:49 apply things I do for work etc etc

20:49 TimMc: OK, so my-func is probably a pure function that just parses a log line, yeah?

20:49 photex: so I'm just splitting up log lines

20:49 hoping to generate some simple stats like 2/30 frames failed

20:49 etc

20:49 nothing crazy

20:50 just trying to learn

20:50 list start times in the logs, maybe determine total running time of the job and so on

20:50 TimMc: photex: (doall ...) around the map will realize the lazy seq *and* hand it back to you. (Read up on doall, dorun, and doseq.)

20:50 tmciver: I only have a hard copy of "Programming Clojure" from 2009.

20:51 photex: but yeah, to start, I'm taking each line, using a regex to extract the log level and the message

20:51 TimMc: tmciver: I bought the ebook, and there was an updated copy.

20:51 photex: and associate that in a map by the show the job ran under

20:52 TimMc technomancy thank you for the information

20:52 tmciver: I upgraded lein from 1.6.1 to 1.7.0 in an effort to get rid of an error when trying to run 'lein difftest', but it's still there. The error is:

20:53 java.io.FileNotFoundException: Could not locate clansi__init.class or clansi.clj on classpath:

20:53 technomancy: tmciver: heading off, but try reinstalling the plugin

20:53 TimMc: photex: There's a similar issue where lazy seqs escape a (binding ...) clause and see a different value for a var than you intended. Same solution works, or you can capture the value lexically.

20:53 tmciver: technomancy: do I manually remove the old jar? I forget.

20:54 TimMc: tmciver: lein plugin uninstall...

20:54 tmciver: TimMc: Thanks.

20:54 TimMc: But 1.3.7 is what I have.

20:58 tmciver: technomancy, TimMc: lein difftest works now. Thanks.

20:58 technomancy: you don't have to uninstall

20:58 fwiw

20:59 tmciver: TimMc lied to me? >:

20:59 TimMc: tmciver: Did you install a different version?

20:59 tmciver: Nl

20:59 No

20:59 1.3.7

20:59 No prob. It works now.

21:00 After all that I can finally do some Clojure.

21:17 TimMc: tmciver: How does this look for import+ syntax? https://refheap.com/paste/738

21:19 tmciver: I'm a little torn on options like "A :as B" vs. ":rename {A B}" vs. simply "{A B}"

21:21 You can see that I've used all of those in the example syntax. :-)

21:21 The {A B} form is the most options-limiting.

21:27 tmciver: TimMc: my initial reaction is to go with "A :as B"

21:27 TimMc: {A B} isn't as obvious.

21:28 TimMc: It does match the "Class [option value]*" pattern.

21:28 citizenparker: seancorfield: Just wanted to say thanks for http://corfield.org/blog/post.cfm/getting-started-with-clojurescript-and-fw-1

21:29 tmciver: TimMc: not sure if I'm familiar with that...

21:29 citizenparker: That's the best and most straightforward resource I've seen for getting cljs up and running on a standalone project

21:29 tmciver: TimMc: was there supposed to be parenthises around contents of line 7?

21:29 TimMc: tmciver: That's pseudo-BNF

21:30 tmciver: Line 7? Nope.

21:31 tmciver: TimMc: why is there parens for the stuff on line 8 then?

21:31 TimMc: (sub.pack.age Class :opt val :opt val AnotherClass :opt val (deeper.sub.package YAClass))

21:31 tmciver: s/is/are

21:31 TimMc: Nesting subpackges.

21:38 tmciver: TimMc: where is the pattern used? use, require?

21:38 TimMc: It isn't.

21:38 But it should!

21:39 If you think it's too confusing, we can just leave that syntax open for future features.

21:39 and always use full package names for now

21:39 tmciver: Hmm, so the question is whether to conform to what use/require do, or to break away and do it 'better'?

21:40 TimMc: Better, as long as it really is.

21:49 tmciver: I'm confused by a lack of parens on line 7. It may be unambiguous to parse but it would be confusing to the eye if not for the indentation.

21:49 seancorfield: citizenparker: just saw your message - glad it helped!

21:50 TimMc: tmciver: Well, that's what indentation's for, yeah? :-P

21:51 tmciver: TimMc: eh

21:51 TimMc: tmciver: Reload, is it clearer now?

21:52 seancorfield: ,(clojure-version)

21:52 clojurebot: "1.3.0"

21:52 seancorfield: ,*clojure-version*

21:52 clojurebot: {:major 1, :minor 3, :incremental 0, :qualifier nil}

21:53 tmciver: Well, I feel that since both 'Color' and the stuff that follows and the line starting with (geom.. are both subordinate to java.awt, they should be indented to the same level.

21:54 But it looks weird to my eye that (geom... has parens and Color... doesn't.

21:56 amalloy: TimMc: Color should have []s

21:57 in the same way that require looks like (:require (clojure [core :as c]))

21:58 TimMc: (will respond when I'm off the phone)

21:58 amalloy: so eg (import+ (java.awt [Color ...] (geom [Point2D$Double ...]))

22:06 francisl: hi group, I have a basic question, I want the users input in the console, it work fine with read-line + lein repl, but it fails with lein run

22:06 what should I use to make it work with lein run?

22:07 TimMc: Someone just asked that!

22:07 ~logs

22:07 clojurebot: logs is http://clojure-log.n01se.net/

22:07 TimMc: http://clojure-log.n01se.net/#19:24

22:08 francisl: ^ this discussion might be helpful

22:08 francisl: ok, perfect, thanks

22:09 TimMc: I don't understand the issues involved, so I might be misleading you...

22:10 amalloy: I was avoiding mixing [] and (). Also, I figured it might be OK to drop some parens the way Clojure does with 'let.

22:10 * talios smells common homework

22:11 brehaut: talios: hi

22:12 amalloy: TimMc: let and for drop unnecessary parens, but you always see a newline instead for legibility

22:12 TimMc: hrm

22:13 amalloy: the parens are useful for lining stuff up, too - you like *can't* put a newline in your current layout because the modifiers would get indented to the left of the things they're modifying

22:14 TimMc: If I use [java.awt (Color ...)] things line up more nicely, but I'd prefer it the other way.

22:15 talios: hey brehaut

22:15 TimMc: Gotta go, but I'll check the backlog for any more suggestions.

22:15 talios: brehaut - done anything with pallet? looks like I'm getting/having to play with it soon

22:16 tmciver: TimMc: OK, see you tomorrow.

22:16 brehaut: talios: i havent sorry

22:16 it does look like its worth some time though

22:16 talios: I'll just hit up cemerick sometime. I still kinda loathe the lisp syntax at times tho.

22:17 sp?

22:17 tim___: Is there a way to have a non-namespaced symbol in a syntax quote?

22:17 brehaut: talios: just think, at least its not javascript ;)

22:18 talios: brehaut - I can only think that, I'm not allowed to vocalise my JS dislike at the office anymore ;p

22:18 tim___: e.g. `(def ~name 1) that expands to (def baz 1)

22:18 brehaut: talios: oh dear.

22:19 talios: theres quite a bit of coffeescript love in your office isnt there?

22:19 amalloy: &(let [name 'baz] `(def ~name 1))

22:19 lazybot: java.lang.SecurityException: You tripped the alarm! def is bad!

22:19 talios: brehaut - yep - about 80% ish of our JS code is coffee

22:20 brehaut: talios: i havent made up my mind if that is a good thing or a bad thing

22:21 talios: brehaut: well it solves a lot of potential JS bugs just in the code it gens

22:21 hugod: talios: stop on by #pallet if you have questions...

22:23 tmciver: tim___, amalloy: also `(def ~'baz 1)

22:23 &`(def ~'baz 1)

22:23 lazybot: java.lang.SecurityException: You tripped the alarm! def is bad!

22:24 talios: hugod: sweet. will do.

22:24 brehaut: talios: yeah thats definately true, although ive found that strict mode + jquery catch a lot of the same ones

22:25 tim___: tmciver: thanks, that did the trick

22:28 talios: brehaut: I see jet brains kotlin got updated with some nice canvas love as well. looks nice

22:29 brehaut: talios: i havent looked at kotlin at all.

22:30 talios: brehaut: http://kotlin-demo.jetbrains.com - compiles to .class and .js files which is nice. wicket web based ide as well

23:29 sdegutis: evening

23:30 would a 64-bit unsigned int be enough space to store hash codes for clojure values?

23:31 arohner1: sdegutis: yes. Java hash codes are 32-bits

23:31 sdegutis: what algorithm is used to calculate them?

23:33 reply!

23:33 sorry, dont mind me.

23:33 arohner1: sdegutis: clojure doesn't have control over the hash codes for java primitives (ints & strings, etc). You'll have to read the clojure source code for the algos to clojure's hash-map & vector algos

23:33 sdegutis: ah cool thanks

23:34 wait, do java primitives have hash code functions built-in?

23:34 i dont know much about java specifically, but the more i hear about it the more i like golang :)

23:35 Raynes: Go is for gophers!

23:35 amalloy: &(.hashCode (Long. 10))

23:35 lazybot: ⇒ 10

23:35 Raynes: Rust is where it's at.

23:35 arohner1: sdegutis: yes, class Integer and class String's hash code fns are built in, and can't be changed

23:38 sdegutis: interesting

23:54 jhowarth: Are there any good animation libraries clojurescript yet?

23:54 for clojurescript*

23:59 lynaghk: jhowarth, you mean for DOM attribute tweening?

23:59 ibdknox just wrapped jQuery, so you could use the animate function from there

Logging service provided by n01se.net