#clojure log - Apr 15 2009

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

0:00 danlarkin: dysinger: are there? where?

0:01 dysinger: sorry maybe not github

0:01 arohner: there are three on the clojure libraries page

0:01 dysinger: yours is one

0:01 http://bitbucket.org/ksojat/neman/

0:01 another

0:01 ^

0:01 yeah what he said

0:02 i guess I see 3 - one in clojure contrib - not liking that one - and 2 elsewhere - 1 github - 1 bitbucket

0:05 danlarkin: neat!

0:06 seems this neman one wraps an existing java json library

0:06 dysinger: danlarkin I like your api best so far

0:06 just gimmie a basic and _UNIFORM_ encode / decode plz kthnx

0:07 hiredman: danlarkin's json lib is going to power clojurebot's twitter repl once I get it going

0:08 danlarkin: it shall power the world! bahaha

0:13 arohner: danlarkin: I'm using your lib too

0:14 danlarkin: I'm glad y'all find it useful

0:14 arohner: hiredman: twitter repl? as in "@clojurebot (+ 2 2)"?

0:18 hiredman: that's the plan

0:19 there is a ruby bot doing it already

0:22 cmvkk: after that, i'd like to see a command-line repl that uses the twitter interface to clojurebot rather than doing the calculation itself.

0:22 and then, maybe another twitter bot built on top of that.

0:23 dysinger: danlarkin - thanks for the milkshake (slurp) took me 5 min to fork it and maven-ize it and integrate it into my project

0:23 #awesome sauce

0:28 arohner: cmvkk: you'd need to include google's new repl in there somewhere

0:29 hiredman: :D

0:29 I bet you could

0:29 clojurebot needs to be on xmpp too

0:33 danlarkin: dysinger: the namespace should not be clojure.json -- clojure-json if you insist on changing it

0:33 dysinger: It's just for my use - why not ?

0:34 danlarkin: it's not a part of the clojure distribution

0:34 clojure.zip, clojure.set

0:35 dysinger: I'd buy that for a dollar

0:35 I am not trying to influence anyone

0:35 just easier to remember than your org.danlarkin namespace.

0:36 danlarkin: I understand, I'd like to change the namespace to clojure-json in my fork but the annoyance for everyone using it stops me

0:36 dysinger: OK I'll do that then.

0:44 hiredman: danlarkin: not just clojure-json, right?

0:45 danlarkin: hiredman: hm?

0:45 oh, the namespace? yes, clojure-json

0:45 hiredman: I mean, you wouldn't send something with a single segment namespace out into the world would you?

0:46 oh, so clojure-json

0:46 oh, so clojure-json.encode and .decode

0:47 danlarkin: clojure-json/encode-as-str etc I was thinking

0:47 or whatever it is

0:47 encode-to-str

0:48 hiredman: don't do that

0:49 namespaces should have atleast one . in them

0:49 otherwise you will run into trouble if you ever want to AOT compile something

0:50 danlarkin: oh? single segment namespaces can't get AOTed?

0:51 dysinger: I just did AOT

0:51 with clojure-json

0:51 it works fine

0:52 you have to name the folder clojure_json to make it work

0:52 but it works fine

0:52 hiredman: clojurebot: logs

0:52 clojurebot: logs is http://clojure-log.n01se.net/

0:54 hiredman: http://clojure-log.n01se.net/date/2008-11-13.html#14:28

0:55 dysinger: ah

0:55 yeah that would put the compiled clojure-json in the default package

0:56 danlarkin - what else would work ?

0:57 danlarkin: well there's always the old org.clojure-json

0:57 hiredman: danlarkin.json

0:58 danlarkin: if you find it necessary to rename the files in the first place... you only need to import once per file, what's so hard to remember

0:58 dysinger: there's nothing wrong with the current setup

0:58 I am just having fun.

0:58 and that's what's great about git.

1:08 danlarkin - I just added maven build to your setup as is and didn't change the ns

1:08 http://github.com/dysinger/clojure-json/tree/master

1:10 I did this for myself but if you want to try it you need maven 2.1.0 / java 6 & http://github.com/dysinger/clojure-pom

1:18 danlarkin: dysinger: your git-fu is stronger than mine, how are you pushing commits to github and then they're not there anymore?

1:18 dysinger: git push -f

1:19 git reset

1:19 git push -f (again)

1:19 or git push --mirror

1:19 would do it too

1:32 danlarkin thanks again - it's working perfectly - I am pushing json through rabbitmq and back

1:34 wute I love lisp

1:44 hiredman: clojurebot: arguments is <reply>http://www.pigdog.org/auto/mr_bads_list/shortcolumn/1914.html

1:44 clojurebot: c'est bon!

1:44 hiredman: clojurebot: what are some arguments I can use to get out of this mess?

1:44 clojurebot: http://www.pigdog.org/auto/mr_bads_list/shortcolumn/1914.html

2:26 Lau_of_DK: Top of the morning gents

2:29 hiredman: good evening

2:35 * Raynes nods a greeting in the general direction of Lau_of_DK and hiredman

5:58 AWizzArd: The german readers might be interested in this article about Scala: http://www.heise.de/newsticker/Scala-Kombination-aus-funktionaler-und-objektorientierter-Programmierung--/meldung/136206

6:24 Lau_of_DK: AWizzArd: this is #clojure

6:30 antifuchs: you realize that you have to do a leonidas impression while saying this, right?

7:00 Lau_of_DK: haha

8:52 AWizzArd: Lau_of_DK: how can I stop a webserver, started from Compojure via (run-server ...)?

8:53 Lau_of_DK: Kill the process

8:53 AWizzArd: Oh. Okay :)

8:53 Lau_of_DK: Or - compojure.server.jetty/stop

8:54 AWizzArd: but this wants to have a server object. (run-server ..) unfortunately doesn't return one.

9:01 Lau_of_DK: The server object is just a hash containing a port # no ?

9:08 AWizzArd: No, that isn't the server object.

9:09 Lau_of_DK: Theres a create-server method which returns a server object

9:09 And you can call start/stop on that

9:11 AWizzArd: Yes, it is a private function. I think I should use that instead of the public run-server.

9:11 I think run-server should also return the server object.

10:09 Drakeson: is it possible to get the list of current threads in slime?

10:10 (e.g. using some combination of clojure-contrib libraries)

10:10 Chouser: you can get stack traces for all live threads

10:10 oh, it's both.

10:11 Drakeson: how?

10:11 Chouser: (Thread/getAllStackTraces)

10:11 returns a map -- keys are Threads, vals are stack traces

10:11 Drakeson: cool

10:11 thanks

10:12 umm, how do you kill a thread?

10:12 Chouser: http://java.sun.com/javase/6/docs/api/java/lang/Thread.html

10:13 Drakeson: I mean, should I just kill it off, or there are more concerns?

10:13 Chouser: (.stop thread) -- it's deprecated and discouraged, but it works

10:13 concerns: http://java.sun.com/javase/6/docs/technotes/guides/concurrency/threadPrimitiveDeprecation.html

10:16 Drakeson: is it better to interrupt then? what does vimclojure do?

10:16 AWizzArd: If it is deprecated, doesn't this mean that Sun could potentially remove this method from the next Java realease?

10:16 Chouser: AWizzArd: I assume so, yes

10:17 Drakeson: it's best not to try to stop threads from the outside at all, but rather to have the thread sufficiently aware that it can shut itself down properly when needed.

10:17 kotarak_: Drakeson: nothing at the moment. But vimclojure has no continuous connection to the server. I'm mulling about how to handle long-running commands...

10:17 rhickey: right

10:18 Chouser: Drakeson: is this a single runaway thread, or part of your design?

10:21 Drakeson: Every eval in slime creates a thread. Sometimes during "interactive development", some threads fall into infinite loops. These are not on a production server, so maybe they can be killed off.

10:22 Chouser: huh. are they cpu-intensive loops, or are they blocked on something?

10:22 Drakeson: in slime + sbcl we could just interrupt the thread and see a stacktrace. then we could abort or continue it.

10:23 Chouser: they appear during "experimentation". In other words, they are stupid loops where the reason is often a simple mistake.

10:25 Chouser: if they're loops printing infinite seqs, you probably want to set *print-length* and *print-level*

10:26 Drakeson: you shouldn't defend those processes :D They are just half-thought throw-away evals, that happen to loop forever.

10:28 Chouser: if they're loop/recur or some other kind of loop, there's probably nothing better to be done than (.stop thread), just be aware that it may leave things in a bad state and that that option may go away in the future.

10:28 this might be helpful: http://groups.google.com/group/clojure/msg/b3d1d2fdd1cdc93d

10:32 Drakeson: Chouser: that helps, thanks.

10:34 Chouser: but setting *print-length* and *print-level* for interactive repls really is a good idea

10:34 you can set them once for the whole session. my repl startup script does it for me.

10:36 Drakeson: what values you use for them?

10:42 what does this mean: call to java.io.File ctor can't be resolved

10:43 (I activated warn on reflection in user.clj)

10:43 AWizzArd: rhickey: Are you the copyright owner of the Clojure logo, or is your brother? And is the use of that logo restricted?

10:43 rhickey: I am - what do you want to do with it?

10:44 AWizzArd: I wanted to know if it is allowed to be used for other (google) user groups, for example for a german Clojure group. (as the logo)

10:46 rhickey: as long as you are using it to refer to my Clojure, ok

10:47 AWizzArd: Thanks. The german branch links directly in the group description to http://clojure.org/

10:47 rhickey: if Microsoft ever makes IronClosure, then no :)

10:48 AWizzArd: *g*

10:49 pjstadig: embrace and extend

10:50 Chouser: Drakeson: (set! *print-length* 103) (set! *print-level* 15)

10:51 those are (obviously) pretty arbitrary

10:51 Drakeson: thanks, I wanted to get a sense of how large they should be.

10:58 Chouser: hm, actually I have not been setting *print-level*

11:14 mihand: hey guys. did somebody try clojure and jena?

11:17 rhickey: mihand: I fiddled with jena briefly - works fine

11:21 Chouser: rhickey: you're here today. Hi, how are ya? :-)

11:21 rhickey: Chouser: fine, thanks

11:21 slashcom: When the manual says combine, does it mean use the Combine Children script?

11:22 rhickey: accessing AWS from Clojure - a total blast

11:22 slashcom: oh shoot

11:23 mihand: rhickey: do you have some examples? I'm particulary interested in wrapping the iterators to seqs

11:23 Chouser: rhickey: ah, good. I've started a little GAE thing (because of the free pricepoint) but I'm still just swimming in foreign xml.

11:23 slashcom: wrong channel?

11:23 slashcom: yes :)

11:23 rhickey: I'm just dropping maps in Simple DB, querying with Clojure data literals...

11:24 no XML in sight

11:24 Chouser: lovely

11:24 I think the web service xml stuff will be a one-time thing, hopefully.

11:24 AWizzArd: Btw, is there a helper for serializing refs? For example refs of hashmaps which can have values that are refs itself?

11:25 rhickey: Chouser: there's no Java lib wrapping that bit?

11:25 Raynes: Well, there goes using the Clojure logo as an avatar for forums :\

11:25 rhickey: mihand: I didn't do that, but you could look at resultset-seq for an example of how to do something like that, also remember iterator-seq

11:26 Chouser: rhickey: dunno, just following tutorials at this point. I've still done essentially no java servlets before.

11:26 mihand: rhickey:thanks for the pointer

11:26 rhickey: Chouser: oh that bit, yeah, one-time copy the config files...

11:27 Chouser: right, that bit.

11:28 rhickey: Parameterized query of simpledb:

11:28 (let [cat "Clothes"]

11:28 (query client

11:28 `{:select * :from "test" :where (or (= :category ~cat) (= :category "Car Parts"))})))

11:28 Chouser: oh, yum

11:29 rhickey: sit at the repl and put your data in the cloud...

11:29 Chousuke: heh, clever.

11:29 rhickey: create an item:

11:29 (put-attrs client "test"

11:29 {:sdb/id (uuid "e76589f6-34e5-4a14-8af6-b70bf0242d7d"),

11:29 :category "Clothes",

11:29 :subcat "Pants",

11:29 :Name "Sweatpants",

11:29 :color #{"Yellow" "Pink" "Blue"},

11:29 :size "Large"})

11:31 Chousuke: I would never have thought of using maps like that.

11:31 rhickey: basically read/write Clojure data - no query strings, no conversions, no resultsets, no friction

11:32 AWizzArd: rhickey: in the for macro you use when-first, which makes it quite elegant. However, this does not allow destructuring, such as (for [[a b] coll] (function a b)). Do you think that it could be nice to extend for to support that?

11:34 Chouser: ,(for [[a b] [[1 2] [3 4]]] (+ a b))

11:34 clojurebot: (3 7)

11:38 AWizzArd: It works if the collection is already packed correctly.

11:38 Chouser: you expect destructuring to work on incorrectly formatted collections?

11:38 AWizzArd: if you have for example key/value pairs '(:a 1, :b 2, :c 3), not in a hashmap, then for can't be used directly.

11:39 ,(let [[a b] [1 2 3 4 5]] (list b a))

11:39 clojurebot: (2 1)

11:39 Chouser: that's what partition is for

11:39 AWizzArd: Would partition be needed if for would support directly destructuring?

11:40 I know there are workarounds, but for example my let from above didn't need to call partition.

11:40 Chouser: as you demonstrate, there's already a valid interpretation for that form. How could 'for' possibly know that you want partition, and what sort of partitioning you want?

11:41 AWizzArd: ,(let [[a b] [[1 2] [3 4]]] (+ a b))

11:41 clojurebot: java.lang.ClassCastException: clojure.lang.LazilyPersistentVector cannot be cast to java.lang.Number

11:41 Chouser: and while we're on the topic, what are you doing with key/value pairs not in a map collection?!? :-)

11:41 AWizzArd: I thought destructuring in FOR could behave like it does in let.

11:42 Chousuke: ,(for [[a b] [1 2 3 4]] [b a])

11:42 clojurebot: java.lang.UnsupportedOperationException: nth not supported on this type: Integer

11:42 AWizzArd: Chouser: k/v pairs are just one example.

11:42 Chousuke: ,(let [[a b] [1 2 3 4]] [b a])

11:42 clojurebot: [2 1]

11:43 Chouser: 'for' iterates, 'let' does not, so they can't be idential.

11:43 ah, and you switched to 'let', I hadn't caught that. hm...

11:43 AWizzArd: the NTH thingy comes from the when-first

11:43 ~def for

11:43 Also see 5:13 at http://clojure-log.n01se.net/date/2009-04-09.html

11:43 Chousuke: destructuring in for expects the structure to be the one you specify for *each* item in the coll, and let expects it to be the structure of the left-hand value

11:43 Chouser: ,(for [[a b] [[1 2 3 4]]] (list b a))

11:43 clojurebot: ((2 1))

11:44 AWizzArd: jdz, hiredman and I were talking about it

11:44 Chousuke: it makes perfect sense for for to behave like that.

11:44 Chouser: ,(for [[a b] (partition 2 [1 2 3 4])] (list b a))

11:44 clojurebot: ((2 1) (4 3))

11:44 AWizzArd: yes sure, with partition it works

11:44 Chouser: I wouldn't call that a workaround so much as just saying what you want

11:45 because maybe that's not what you want, maybe you want: ,(for [[a b] (partition 2 1 [1 2 3 4])] (list b a))

11:45 ,(for [[a b] (partition 2 1 [1 2 3 4])] (list b a))

11:45 clojurebot: ((2 1) (3 2) (4 3))

11:45 Chousuke: AWizzArd: in my opinion, it'd be wrong for (for [[a b] [1 2 3 4]] (list b a)) to work

11:46 AWizzArd: It would be taking each time two things out of the list, instead of always the first.

11:46 Chousuke: what output would you expect from that for?

11:46 Chousuke: but that wouldn't make sense.

11:46 AWizzArd: an error.

11:46 AWizzArd: Not ((2 1) (4 3))?

11:46 Chousuke: nope

11:46 since the semantics of the for binding form differs from let's

11:47 the destructuring on the right side applies to *each* element in the collection you provide, because that's how for works

11:47 and you can't destructure "1" as [a b] so it should give an error

11:48 AWizzArd: ,(partition 2 "123")

11:48 clojurebot: ((\1 \2))

11:48 AWizzArd: ,(partition 2 "1")

11:48 clojurebot: ()

11:49 Chousuke: it's not about doing automatic partitioning

11:50 AWizzArd: ,(let [[a b] "1"] (list b a))

11:50 clojurebot: (nil \1)

11:50 Chousuke: note that I meant a literal 1 with "1" in that case :P

11:50 AWizzArd: I think that would be perfect behaviour for FOR. It would just be more flexible, a bit like CLs loop, which is not bound to iterate only one by one over a collection.

11:51 ,(let [[a b] 1] (list b a))

11:51 clojurebot: java.lang.UnsupportedOperationException: nth not supported on this type: Integer

11:51 AWizzArd: Yes, in that case I would FOR also like to throw an Exception.

11:51 Chousuke: as Chouser noticed earlier, (for [[a b] '[[1 2 3 4] [A B C D]]] [b a]) does work analogously to let, so I don't think there's any mismatch.

11:52 and adding this kind of hidden behaviour into for would in my opinion just make it more complicated and more error-prone :/

11:53 as then you might have your destructuring work for data you didn't *intend* it to work with in the first place.

11:53 if you want to destructure pairs in a list, just use partition explicitly. it's not a workaround, it's the proper way to do things.

11:54 Chouser: if 'for' tried to partition automatically, what would you want it do with something like: (for [{a :a} {:a 1 :b 2}] a)

11:54 that's a valid 'let' form:

11:54 ,(let [{a :a} {:a 1 :b 2}] a)

11:54 clojurebot: 1

11:55 Chousuke: ,(for [{a :a} {:a 1 :b 2}] a)

11:55 clojurebot: (nil nil)

11:55 Chousuke: hmm :P

11:55 not surprising I guess.

11:55 ,(for [{a :a} [{:a 1 :b 2}]] a)

11:55 clojurebot: (1)

11:55 AWizzArd: I find it a bit surprising

11:55 Chousuke: AWizzArd: I think you misunderstand how for works.

11:56 AWizzArd: the binding form is not like let.

11:56 a let takes a simple list of a = b pairs

11:56 AWizzArd: I understand that part. I just see that for can walk its collection only element by element. And I think if that is not given anymore, then behaving like in let makes sense.

11:57 Chousuke: for takes a list of a <- coll pairs and produces a seq where each item in coll is bound to a for each iteration, with destructuring.

11:57 AWizzArd: anyway, gtg

11:57 Chousuke: destructuring in for does not destructure the collection, it destructures each item in the collection

11:58 mixing the different destructurings just makes it more complicated :/

11:58 digash: and then there are others that behave the same way as for, like doseq

11:58 Chousuke: how could you tell whether it's going to destructure the collection or the items?

11:59 Chouser: AWizzArd_: what would you expect from (for [[a b] [[1 2] 3 4]] (list b a))

12:05 digash: one thing that always trip me up on the destructuring form is

12:05 ,(let [{:a a} {:a "a" :b "b"}] a)

12:05 clojurebot: java.lang.Exception: Unsupported binding form: :a

12:05 digash: vs

12:05 ,(let [{a :a} {:a "a" :b "b"}] a)

12:05 clojurebot: "a"

12:06 Chouser: yeah, it's easier to remember if you keep in mind features like :keys, :or, etc.

12:06 ,(let [{:keys [a]} {:a 1 :b 2}] a)

12:06 clojurebot: 1

12:07 digash: ,(let [{a :keys} {:a 1 :keys 2}] a)

12:07 clojurebot: 2

12:08 digash: :)

12:08 Chouser: exactly my point

12:08 digash: makes total sense to me now, thanks

12:20 Cark: "There are similar :strs and :syms directives for matching string and symbol keys."

12:20 but there's no example of that

12:20 oh sorry i see !

12:21 ,(let [{:strs [a]} {"a" 1}] a)

12:21 clojurebot: 1

12:26 digash: i wish i could do something like = in Erlang

12:26 ,(if-let [[a :a] ["a" :a]] a)

12:26 clojurebot: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.Exception: Unsupported binding form: :a

12:27 digash: the common idiom in Erlang is to do asserts like {ok, S} = file:open("filename", [read])

12:34 * kotarak just released VimClojure 2.1.0. Have fun. :)

12:38 dakrone_hb: thanks kotarak

12:46 kotarak, I'm seeing /build.xml:66: Could not find clojure.lang.Compile. Make sure you have it in your classpath, it should be able to find it from the clojure.jar in my local.properties, right?

12:47 kotarak, did you drop off?

12:47 kotarak_: dakrone_hb: I closed the laptop lid and walked around a bit with the little one. But he sleeps now. :) So in a sense I dropped off, yes. :)

12:48 dakrone_hb: okay, then probably missed my question

12:48 first, thanks for vimclojure :)

12:48 kotarak_: :) Thanks.

12:48 dakrone_hb: second, I'm seeing /build.xml:66: Could not find clojure.lang.Compile. Make sure you have it in your classpath, it should be able to find it from the clojure.jar in my local.properties, right?

12:49 kotarak_: yes. clojure.jar=/path/to/your/clojure.jar in local.properties should do the trick

12:50 dakrone_hb: I have it set to the correct jar, latest from svn, still getting that error

12:50 kotarak_: hmmm... let me check

12:56 dakrone_hb: could '~'s in the path be confusing it? (ie, does it need full-path?)

13:03 kotarak_: dakrone_hb: no ~ please. That is shellism!

13:04 dakrone_hb: kotarak_, oka

13:04 y

13:05 cool, that works, thanks kotarak_

13:05 kotarak_: but it can a relative path. Or absolute. But no ~. ~ is expanded by the shell, but the local.properties is read directly. eg. java -cp ~/foo.jar:~/bar.jar will also only expand the first ~.

13:06 dakrone_hb: np. :)

13:08 dakrone_hb: btw: you can use vim for path completion. clojure.jar = /<C-x><C-f> (note: whitespace around the =)

13:26 gnuvince: Hey guys, I asked this question in two channels already, without success. Hope you can help. What would you name this function: (fn [x] (if (< 0 x 1) (/ 1 x) x))?

13:30 Chouser: how do you define success? what if suggested naming him "George"?

13:31 kotarak: Sombrero?

13:31 grkz: I'd go with "Billy-Bob"

13:32 gnuvince: Chouser: if there's already a widely accepted name for this operation, I'd want to go with that. Otherwise, a short and descriptive name, maybe cond-recip.

13:32 Chouser: I think this could be correctly characterized as "without success"

13:33 gnuvince: so far, your suggestions are pretty much the same as in other channels.

13:34 Chouser: where does one find a mathemetician?

13:34 kotarak: I am, but I don't know whether this specific function has a common name.

13:35 Chouser: the combination of a curve below 1 and a line above 1 seems unusual

13:36 dysinger: #lol http://shouldiusescala.com

13:36 Chouser: gnuvince: what are you using it for?

13:37 gnuvince: Chouser: this is to be used in an aspect-ratio function. I was doing (/ (max width height) (min width height)) to always get a ratio over 1.

13:37 conditionally using reciprocal looks nicer

13:37 but I need a good name for it.

13:39 Chousuke: what would you call the result of that function? is it used as a coefficient of some sort?

13:40 cemerick: kotarak will eventually regret having admitted to being a mathematician... ;-)

13:40 gnuvince: it's to be used as a ratio for resizing an image.

13:40 * kotarak ducks...

13:40 yason: gnuvince: just use it first and when your program is finished enough you have come up with a good name

13:40 gnuvince: yason: my program is finished :)

13:40 yason: =you will have

13:40 gnuvince: the tests are done and pass

13:41 I'm at the part where I take the code written hastily and refactor it into nice, understandable functions.

13:41 Chousuke: gnuvince: I think there's no need to invent a name for the actual function performed if you can think up something to call value that it will be used as.

13:41 yason: gnuvince: well, it doesn't exactly ring a bell here. So just describe it based on how you're using it

13:42 gnuvince: nevermind.

13:42 Chousuke: so you could use it something like (* (scaling-factor) whatever)

13:42 (forgot the parameter, but meh)

13:42 gnuvince: and Chousuke wins!

13:42 scaling-factor is perfect

13:44 yason: glad you found it!

13:52 Lau_of_DK: Hey guys

14:32 hiredman: woa

14:33 pjstadig: woa, what?

14:34 hiredman: vimclojure now spits out about two screens worth of errors when I try to open kevin.clj

14:34 kotarak: hiredman: what kind of errors?

14:36 hiredman: kotarak: dunno, I just ignored them, it failed to open the file, but I did tabe again and it opened the file with no errors

14:37 kotarak: hiredman: try :messages

14:37 Was kevin.clj correctly in the classpath?

14:38 VC really relies on this.

14:38 hiredman: Couldn't execute Nail! java.lang.Exception: Unable to resolve symbol: lazy-cons in this context (kev

14:38 in.clj:19)

14:39 makes sense

14:40 and it isn't on the classpath correctly, so I did not really expect vimclojure to handle it properly

14:40 although \eb works, but \et just seems to eval the first form in the file

14:41 kotarak: hmmm... \et should evaluate the form the cursor is in...

14:42 hiredman: wait, kevin.clj is on the classpath, just no namespace declaration and it has lazy-cons in it

14:42 if I try and load euler.clj which is not on the classpath and has a namespace declaration, vimclojure gives me errors and I cannot open the file

14:43 which is kind of annoying, I would hope even if vimclojure cannot do the nailgun thing it would still let me open the file

14:44 kotarak: Hmm.. Ok. I'll see that I can make it more robust.

14:44 hiredman: shit

14:45 I opened clojurebot.clj in vimclojure

14:45 ^-

14:45 I didn't hit \ef or anything

14:46 that also explains why kevin.clj was throwing an error about lazy-cons

14:46 and it explaims why loading a clojure buffer was so much slower

14:47 kotarak: It explains all these things?....

14:47 hiredman: yeah

14:47 vimclojure is evaling the whole file when I open a clojure file

14:48 which is why PircBot showed up when I did :tabe clojurebot.clj

14:48 kotarak: It's basically require'ing it. To set up the aliases, uses and requires. This is necessary for completion and syntax highlighting.

14:48 hiredman: it is very annoying

14:48 kotarak: Well. You can turn it off: let clj_want_gorilla = 0

14:49 hiredman: yeah

14:49 I just did

14:49 no wonder it was choking on kevin.clj

14:49 that file is ancient

14:50 and full of syntax errors and what not

14:50 brennanc: can someone point me in the right direction on how to learn about Clojure's XML capabilities?

14:50 hiredman: well, there is clojure.xml

14:50 contrib has some xml processing related stuff too

14:51 brennanc: any docs or tutorials?

14:52 hiredman: ~google clojure xml

14:52 clojurebot: First, out of 48300 results is:

14:52 Clojure � java_interop

14:52 http://clojure.org/java_interop

14:52 hiredman: well, that's not very helpful

14:53 brennanc: I found a little bit here and there in google but not much

14:53 kotarak: hiredman: yeah, I need a more robust incremental reader...

14:53 hiredman: if you use clojure.xml/parse it turns xml into a map structure

14:54 kotarak: hiredman: currently I really on the stock clojure reader. So the files must be halfway sane...

14:54 hiredman: kotarak: the fact that they are read at all is a deal breaker

14:55 clojurebot.clj is perfectly sane

14:55 but I don't want copies of clojurebot launching everytime I open it

14:55 ,(impot 'java.io.StringBufferInputStream)

14:55 clojurebot: java.lang.Exception: Unable to resolve symbol: impot in this context

14:55 hiredman: ,(import 'java.io.StringBufferInputStream)

14:55 clojurebot: nil

14:55 hiredman: ,(clojure.xml/parse (StringBufferInputStream. "<foo>bar</foo>"))

14:55 clojurebot: Eval-in-box threw an exception:java.lang.NoClassDefFoundError: clojure/lang/PersistentStructMap$Seq

14:56 hiredman: whoops

14:56 kotarak: hiredman: to be honest: then your clojurebot.clj is broken. IMO, files should do this unless being told so. "reading" doesn't mean "do something"

14:57 hiredman: ok

14:57 vimclojure is not "reading" it is "evaling"

14:58 kotarak: hiredman: ok. point taken. Then you will have to live with static vimclojure and what vim itself gives you. Eg. <C-n>.

14:59 hiredman: I would be surprised if you don't get more complaints about this

15:00 lispbliss: Is there a way to use the xml-seq on non-perfect xml? (most html)

15:01 kotarak: hiredman: you are the first up to now...

15:01 hiredman: xml-seq works on the map structure returned by clojure.xml/parse

15:01 kotarak: But I will look into improve things in that respect.

15:01 Maybe bailing out in case of a problem.

15:01 lispbliss: hiredman: if parse won't take it, do you have any other options?

15:01 hiredman: I forget exactly, but I think you can pass a parser to parse

15:02 so if you have a parser that can read broken xml you can pass it to parse

15:02 ,(doc clojure.xml/parse)

15:02 clojurebot: "([s] [s startparse]); Parses and loads the source s, which can be a File, InputStream or String naming a URI. Returns a tree of the xml/element struct-map, which has the keys :tag, :attrs, and :content. and accessor fns tag, attrs, and content. Other parsers can be supplied by passing startparse, a fn taking a source and a ContentHandler and returning a parser"

15:02 Chouser: you can use tagsoup for example to get good parsed xml out of bad html

15:02 brennanc: zippers the best way to go through it after that?

15:03 I'm basically going through XHTML and replacing certain tags with logic

15:03 Chouser: brennanc: I like zippers and zip-filter for plucking out information

15:04 brennanc: if you're replacing content, zip-filter might be a bit too clumsy still. but zippers should work fine.

15:04 hiredman: ,(doc clojure.zip/next)

15:04 clojurebot: "([loc]); Moves to the next loc in the hierarchy, depth-first. When reaching the end, returns a distinguished loc detectable via end?. If already at the end, stays there."

15:04 brennanc: ahh, that could be useful :)

15:04 Chouser: brennanc: you might look at enlive from cgrand -- I haven't yet, but I think it's all about replacing bits of content in an html doc.

15:04 hiredman: clojurebot: transform?

15:04 clojurebot: transform is http://github.com/hiredman/odds-and-ends/blob/8a84e6ddbad9d71f714ba16c3e1239633228a7eb/functional.clj

15:05 lispbliss: Chouser: great, looking into tagsoup right now. You don't happen to have a pasteable snippet that shows you combine tagsoup with parse?

15:05 hiredman: brennanc: transform, transforml and transformr might be useful as well

15:07 brennanc: I basically have a tag like <blah:iterateCollection src="col" as "x"> <li><%= x.name %></li></blah:IterateCollection>

15:07 trying to make a templating system so users can upload dynamic sites but not give them access to do anythign "bad"

15:08 lisppaste8: Chouser pasted "tagsoup -> parse -> xml-zip" at http://paste.lisp.org/display/78642

15:08 lispbliss: Chouser: thanks

15:13 hiredman: transform is a helper function for a macro that does code transformation using zippers

15:16 lispbliss: From the name and doc, java.awt.Toolkit's getSystemSelection sounds like it could be used to return what is selected in another app, even non-java, such as Notepad. Anyone used it and know if this is what it does?

15:16 hiredman: ~javadoc java.awt.Toolkit

15:21 lispbliss: oh, I guess that is what getSystemSelection does, but it doesn't work on Windows.

15:36 cemerick: In the "I can't believe I've gotten so far with so little" department: why do symbols and keywords exist in clojure?

15:36 s/and/*and*

15:37 spacema__: danlarkin: I've been having some troubel wtih your json library since I updated clojure the other day - do you know whether it's working with the new builds?

15:37 hiredman: cemerick: objects that evaluate to themselves are handy

15:37 danlarkin: spacema__: I haven't tried it recently, do the tests run? what's the error

15:38 cemerick: hiredman: symbols and keywords don't both evaluate to themselves?

15:38 rhickey: ,rest

15:38 clojurebot: #<core$rest__3094 clojure.core$rest__3094@16181be>

15:38 rhickey: ,:rest

15:38 clojurebot: :rest

15:38 Drakeson: ,#{() nil}

15:38 clojurebot: #{nil ()}

15:39 hiredman: cemerick: nope

15:39 cemerick: right, right, what I'm driving at is, isn't there a big overlap in the usage of keywords and symbols?

15:39 durka42: ,'rest

15:39 clojurebot: rest

15:40 rhickey: cemerick: no, symbols are usually used to designate something else, and keywords always to designate themselves

15:40 hiredman: cemerick: clojure is my first real use of lisp, but the general impression is yes, in most lisps quoted symbols also perform the same job that keywords do in clojure

15:40 rhickey: hiredman: no, keywords are in CL for the same reasons

15:40 cemerick: rhickey: that's just a question of idioms, though, right?

15:41 rhickey: no

15:41 Drakeson: is there a [mostly] declarative GUI toolkit for clojure, yet?

15:42 spacema__: danlarkin: nm, I got it; sorry abotu that. By the way, I haven't been following closely, but how's Madison coming?

15:42 rhickey: it has to do with print/eval, with keywords that is value preserving, with symbols it isn't - they need quoting

15:43 hiredman: ah

15:43 cemerick: huh

15:43 pjstadig: a quoted symbol is actually a list 'rest => (quote rest)

15:43 ' is a reader macro

15:44 (eval 'rest) => rest

15:44 danlarkin: spacema__: quite alright... it's coming along well, shaping up nicely... I need to think of a simple sample app to show off what it's got so far

15:44 rhickey: ,(eval (read-string (pr-str :foo)))

15:44 clojurebot: DENIED

15:44 pjstadig: (eval (eval 'rest)) => whatevery rest points to

15:44 cemerick: rhickey: that's still a question of idiomatic implementation of print and eval, though, right? i.e. There's nothing in clojure.lang.Keyword's impl beyond what Symbol has besides namespace support.

15:44 rhickey: (eval (read-string (pr-str 'foo)))

15:44 pjstadig: (eval (eval :key)) => :key

15:45 (eval (eval (eval :key))) => :key

15:46 rhickey: cemerick: eval is special for symbols and sequences, not for keywords/strings etc

15:47 cemerick: there's no optional idiom about it, else no variables/locals in the language

15:48 cemerick: OK, I think I'm grokking it now.

15:49 rhickey: user=> (def x 42)

15:49 #'user/x

15:49 user=> {:x x}

15:49 {:x 42}

15:49 user=> {'x x}

15:49 {x 42}

15:49 user=> {x 42}

15:49 {42 42}

15:50 quoted symbols don't round-trip

15:51 cemerick: sure, sure. I know how the stuff works now, I was just wondering if one could get to where we are now with only keywords (perhaps by having a separate lookup/dereference mechanism in eval).

15:51 s/now/already

15:51 rhickey: cemerick: all var names as keywords?

15:52 cemerick: yeah (I think)

15:52 It does seem possible, but you'd end up doing a runtime lookup for every symbol in the expression you evaluate.

15:53 writing a lisp interpreter would likely clarify these things for me pretty quickly :-)

15:53 rhickey: so how do you say {'x x}, and print it evaluably?

15:54 for whatever syntax of foo and the-thing-named-by-foo you desire

15:55 it's keywords that are optional, you could instead use strings

15:57 cemerick: {'x x} drove it home, thanks

15:57 whew, I love asking dumb questions! :-D

15:58 rhickey: cemerick: lisp interpreter still a good exercise - once you've done that you are in a whole different place in thinking about lisp

15:58 hiredman: I should finish mine

15:58 cemerick: yeah, it's in my long todo list :-/

15:58 djkthx: lisp compilers are where it's at!

15:59 pjstadig: how would I do something like (if (seq? x) (some-seq-stuff) (some-atom-stuff))?

15:59 rhickey: http://www.amazon.com/Lisp-Small-Pieces-Christian-Queinnec/dp/0521562473

15:59 http://www.amazon.com/Essentials-Programming-Languages-Daniel-Friedman/dp/0262062798/ref=pd_sim_b_24

15:59 pjstadig: seq? only returns true if x implements ISeq

15:59 ,(seq? [])

15:59 clojurebot: false

15:59 pjstadig: ,(seq? (seq []))

15:59 clojurebot: false

16:00 hiredman: ...

16:00 kotarak: ,(seq? (seq [1]))

16:00 clojurebot: true

16:00 kotarak: ,(nil? (seq []))

16:00 clojurebot: true

16:00 rhickey: ,(doc coll?)

16:00 clojurebot: "([x]); Returns true if x implements IPersistentCollection"

16:00 pjstadig: (coll? ())

16:00 hiredman: pjstadig: you might use instanceof?

16:00 pjstadig: ,(coll? ())

16:00 hiredman: or instanceof

16:00 clojurebot: true

16:00 pjstadig: ,(coll? [])

16:00 clojurebot: true

16:00 pjstadig: ,(coll? #{})

16:00 clojurebot: true

16:01 cemerick: I read through lisp in small pieces years ago...I probably just took along the minimum of what I needed :-)

16:01 pjstadig: so CL would be (if (list? x) ...) and clojure would be (if (coll? x) ...)

16:02 hiredman: pjstadig: (instance? java.util.Collection ...) is more general

16:03 djkthx: pjstadig: vectors won't return true to listp

16:03 rhickey: pjstadig: CL doesn't have the same collection stack, but it's very subtle and depends on what you are doping - strings are seqable - but are they atoms in your application?

16:03 djkthx: * (vector 1 2 3)

16:03 #(1 2 3)

16:03 * (listp (vector 1 2 3))

16:03 NIL

16:03 rhickey: it ends up atom is not a rich abstraction

16:03 djkthx: heh

16:03 rhickey: CL atom

16:03 pjstadig: right sorry i meant listp

16:03 rhickey: seq? is most similar to listp

16:03 djkthx: yeah

16:04 pjstadig: i'm trying to write a macro that does something to lists, but leaves numbers, strings, etc. alone

16:04 i guess seq? is all i need

16:04 Chouser: rhickey: did you notice you just recommended a $270 book?

16:04 pjstadig: i don't need to treat vectors, hashmaps, sets, etc. specially, they should probably fall through too

16:04 hiredman: pjstadig: (instance? java.util.List ...)

16:05 rhickey: if you want to catch vectors also, there's sequential?

16:05 for all collections, coll?

16:05 depends on what you want to do

16:05 pjstadig: ok

16:06 hiredman: Chouser: holy crap

16:07 I love how peter norvig is the most helpful review

16:09 rhickey: http://books.google.com/books?id=81mFK8pqh5EC&dq=lisp+in+small+pieces&printsec=frontcover&source=bn&hl=en&ei=IzzmSaLzLI6Mtgeh0sWXAg&sa=X&oi=book_result&ct=result&resnum=4

16:11 cemerick: Chouser: $270 books aren't a problem. The real problem are theses that have never been printed.

16:12 pjstadig: cemerick: i know. I wrote a thesis about that.

16:12 but i never printed it

16:12 cemerick: pjstadig, always part of the problem, never part of the solution ;-)

16:13 Chouser: hm, seems like a joke I'm not getting?

16:13 cemerick: I think it's all improv, anyway.

16:14 pjstadig: i wrote a thesis about things that seem like jokes too...

16:14 ~but then suddenly

16:14 clojurebot: CLABANGO!

16:14 kotarak: my thesis was a joke..

16:14 Chouser: certainly nobody's going to print cemerick's joke about theses.

16:15 cemerick: heh, no one is going to print ANY of MY jokes, EVAH!

16:16 Chouser: remember, my legendary bad sense of humor

16:16 or, my grand sense of humor that I share with almost no one

16:17 Chousuke: isn't that functionally equivalent to having a bad sense of humour? :)

16:18 cemerick: only to other people

16:18 I find myself hilarious! :-P

16:18 Chouser: only christophe's sense of humor can safely be called grand

16:18 Chousuke: Well, yeah. Sometimes it suffices to look in the mirror.

16:18 cemerick: boom. ouch.

16:25 danlarkin: y'all should stick to writing code

16:25 hiredman: lisp in small pieces seems to be much cheaper on barnes and noble

17:21 brennanc: how do I use zip_filter? I can't even figure out how to get it to show up in my REPL. I'm including the clojure-contrib jar

17:22 kotarak: brennanc: (use 'clojure.contrib.zip-filter)

17:22 clojurebot: clojure is the bestest programming language available.

17:22 brennanc: I get the following:

17:22 java.lang.IllegalStateException: descendants already refers to: #'clojure.core/descendants in namespace: user (NO_SOURCE_FILE:0)

17:22 when I do that

17:22 AWizzArd: Chouser: I know how the current for behaves, so your example (for [[a b] [[1 2] 3 4]] (list b a)) would throw this NTH error. But I think a good result would be: ((3 [1 2]) (nil 4))

17:23 kotarak: brennanc: (use 'clojure.contrib.zip-filter :exclude (descendants))

17:40 Chouser: AWizzArd: but if the coll were [[1 2] [3 4]] instead, you'd get ((2 1) (4 3)), right? or are you asking for a breaking change?

17:43 but that would mean 'for' would have to look ahead throught the (possibly lazy) seq to see if there were any non-seqable items anywhere, and change its behavior accordingly

17:43 cp2: ugh, i cant believe i just woke up

17:51 AWizzArd: Chouser: do you see a way for extending for so that it can take out more than one element each time without breaking changes? Partition can help, but possibly leaves elements out.

17:52 (for [[a b c] (partition 3 '(1 2 3 4 5))] (list c b a)) vs (for [[a b c] (partition 3 '(1 2 3 4 5 6))] (list c b a))

17:52 Chousuke: AWizzArd: just make a version of partition that returns the remnant as well

17:53 then you'll get ((3 2 1) (nil 5 4)) for the first one

17:53 Chouser: seq-utils/partition-all

17:54 Chousuke: ,`partition-all

17:54 clojurebot: sandbox/partition-all

17:54 Chousuke: hm, no contrib still :/

17:55 or...

17:55 ,clojure.contrib.seq-utils/partition-all

17:55 clojurebot: java.lang.ClassNotFoundException: clojure.contrib.seq-utils

17:55 Chousuke: meh.

17:57 AWizzArd: (doc sandbox/partition-all)

17:57 clojurebot: Titim gan �ir� ort.

17:59 hiredman: I swapped out the clojure and clojure-contrib jars out from under clojurebot so somethings are a little fubar

18:02 dysinger: so I am messing around with rabbitmq again today

18:02 http://gist.github.com/96053

18:02 my question

18:02 how do I create a seq out of something that uses a callback :/

18:03 I was hoping to do (for [msg (repeat (consume-from-rabbitmq-queue)] .....

18:03 rabbtimq's java api uses a callback for a msg consumer

18:04 instead of just a blocking call

18:04 kotarak: Hmmm... isn't there seque or something which might be used?

18:05 (doc seque)

18:05 clojurebot: Creates a queued seq on another (presumably lazy) seq s. The queued seq will produce a concrete seq in the background, and can get up to n items ahead of the consumer. n-or-q can be an integer n buffer size, or an instance of java.util.concurrent BlockingQueue. Note that reading from a seque can block if the reader gets ahead of the producer.; arglists ([s] [n-or-q s])

18:05 hiredman: dysinger: have the callback push things onto a queue

18:05 dysinger: ok - that's an idea

18:05 hiredman: unless it is already a Queue

18:06 dysinger: seems strange to consume from rabbitmq queue and put on a java queue

18:06 hiredman: which I guess it is

18:06 dysinger: wish they would have just provided a blocking queue -like interface to call

18:07 hiredman: dysinger: well, it is pretty easy to build one on top

18:07 dysinger: ok I'll think about it more thanks

18:16 hmm seque looks like it get's it's feed from another seq

18:16 This callback message api is upside-down from what I am used to (blocking queue)

18:17 * dysinger goes off to read up on agents

18:52 Cark: dysinger : you can use (clojure.lang.PersistentQueue/EMPTY)

18:52 then puch pop and peek

18:52 push =/

19:41 brennanc: I have {:foo [1 2 3]} and then someone passes in the string "foo". How do I get the key the value of the key they passed in when it is a string and needs to be converted to a symbol?

19:43 hiredman: you wnat a function to turn "foo" into :foo ?

19:43 brennanc: correct

19:43 hiredman: ,(keyword "foo")

19:43 clojurebot: :foo

19:43 brennanc: I tried symbol but it didn't work

19:43 hiredman: ,(symbol ":foo")

19:43 clojurebot: :foo

19:43 brennanc: ahh, was thinking they wre called symbols

19:43 hiredman: :P

19:44 symbols and keywords are different

19:44 brennanc: awesome, thanks

19:44 hiredman: actually rhickey was in here earlier today and someone asked him about keywords

20:55 stuhood: where can i find a good explanation of all the features of binding-forms, like destructuring, etc

20:55 shoot, special_forms on the website

21:34 delitescere: I'm at the first Chicago Clojure user group (yay!)

21:35 http://onclojure.com/chicago/

21:36 Rich - any plans to be here this year?

21:51 stuhood: in a gen-class'd class, it looks *ns* is always clojure.core

21:51 is there a way to have the methods of the class execute in the context of whatever namespace gen-class was run in?

22:02 slashus2: Is there something like pany in clojure's core? None parallel?

23:09 lisppaste8: slashus2 annotated #78128 "another test" at http://paste.lisp.org/display/78128#5

23:09 slashus2: I didn't mean to paste this here, sorry.

23:17 monty: hi. can you compile a clojure prohram with just javac, like in an ant task? in everything ive seen you have to go in the repl

23:18 danlarkin: monty: you can use ant, not javac though

23:19 monty: danlarkin: so how do you initiate the compile call?

23:21 i think i found it: clojure.lang.Compile

23:22 danlarkin: monty: correct

23:22 monty: here's an example http://github.com/danlarkin/clojure-json/blob/edf253b9231d3abecc93408c49e7349754da320f/build.xml

23:23 monty: awesome, thanks!

23:23 hiredman: I would use: java clojure.main -e "(compile 'some.name.space)"

23:24 monty: hmm, that looks handy too

23:25 ive been learning clojure this week playing around with the google appengine

23:28 how would you set clojure.complie.path, if you were just doing it from the command line?

23:30 hiredman: I would use: java clojure.main -e "(set! *compile-path* \"/some/path\") (compile 'some.name.space)"

23:30 monty: i see. thanks

23:31 since it generates a few class files, ie. example__init.class, example$_main, are all this needed?

23:32 hiredman: yes

23:33 one class per function, and then if you are using gen-class, another class named class you generated

23:34 stuhood: monty: i think you can also set a java system property for the compile path: aka `java -Dclojure.compile.path=classes`

23:36 monty: i wonder, since appengine has a limit of 1000 files, and 1 class file per function would add up

23:36 maybe i can jar them all together

23:45 one more question, anyone know how to set failonerror=true to java at the command line?

23:59 stuhood: the failonerror part is ant specific: it just causes ant to fail the build if the java binbary returns anything other than 0

Logging service provided by n01se.net