#clojure logs

2009-04-15

00:00danlarkindysinger: are there? where?
00:01dysingersorry maybe not github
00:01arohnerthere are three on the clojure libraries page
00:01dysingeryours is one
00:01dysingerhttp://bitbucket.org/ksojat/neman/
00:01dysingeranother
00:01dysinger^
00:01dysingeryeah what he said
00:02dysingeri guess I see 3 - one in clojure contrib - not liking that one - and 2 elsewhere - 1 github - 1 bitbucket
00:05danlarkinneat!
00:06danlarkinseems this neman one wraps an existing java json library
00:06dysingerdanlarkin I like your api best so far
00:06dysingerjust gimmie a basic and _UNIFORM_ encode / decode plz kthnx
00:07hiredmandanlarkin's json lib is going to power clojurebot's twitter repl once I get it going
00:08danlarkinit shall power the world! bahaha
00:13arohnerdanlarkin: I'm using your lib too
00:14danlarkinI'm glad y'all find it useful
00:14arohnerhiredman: twitter repl? as in "@clojurebot (+ 2 2)"?
00:18hiredmanthat's the plan
00:19hiredmanthere is a ruby bot doing it already
00:22cmvkkafter that, i'd like to see a command-line repl that uses the twitter interface to clojurebot rather than doing the calculation itself.
00:22cmvkkand then, maybe another twitter bot built on top of that.
00:23dysingerdanlarkin - thanks for the milkshake (slurp) took me 5 min to fork it and maven-ize it and integrate it into my project
00:23dysinger#awesome sauce
00:28arohnercmvkk: you'd need to include google's new repl in there somewhere
00:29hiredman:D
00:29hiredmanI bet you could
00:29hiredmanclojurebot needs to be on xmpp too
00:33danlarkindysinger: the namespace should not be clojure.json -- clojure-json if you insist on changing it
00:33dysingerIt's just for my use - why not ?
00:34danlarkinit's not a part of the clojure distribution
00:34danlarkinclojure.zip, clojure.set
00:35dysingerI'd buy that for a dollar
00:35dysingerI am not trying to influence anyone
00:35dysingerjust easier to remember than your org.danlarkin namespace.
00:36danlarkinI understand, I'd like to change the namespace to clojure-json in my fork but the annoyance for everyone using it stops me
00:36dysingerOK I'll do that then.
00:44hiredmandanlarkin: not just clojure-json, right?
00:45danlarkinhiredman: hm?
00:45danlarkinoh, the namespace? yes, clojure-json
00:45hiredmanI mean, you wouldn't send something with a single segment namespace out into the world would you?
00:46hiredmanoh, so clojure-json
00:46hiredmanoh, so clojure-json.encode and .decode
00:47danlarkinclojure-json/encode-as-str etc I was thinking
00:47danlarkinor whatever it is
00:47danlarkinencode-to-str
00:48hiredmandon't do that
00:49hiredmannamespaces should have atleast one . in them
00:49hiredmanotherwise you will run into trouble if you ever want to AOT compile something
00:50danlarkinoh? single segment namespaces can't get AOTed?
00:51dysingerI just did AOT
00:51dysingerwith clojure-json
00:51dysingerit works fine
00:52dysingeryou have to name the folder clojure_json to make it work
00:52dysingerbut it works fine
00:52hiredmanclojurebot: logs
00:52clojurebotlogs is http://clojure-log.n01se.net/
00:54hiredmanhttp://clojure-log.n01se.net/date/2008-11-13.html#14:28
00:55dysingerah
00:55dysingeryeah that would put the compiled clojure-json in the default package
00:56dysingerdanlarkin - what else would work ?
00:57danlarkinwell there's always the old org.clojure-json
00:57hiredmandanlarkin.json
00:58danlarkinif 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
00:58dysingerthere's nothing wrong with the current setup
00:58dysingerI am just having fun.
00:58dysingerand that's what's great about git.
01:08dysingerdanlarkin - I just added maven build to your setup as is and didn't change the ns
01:08dysingerhttp://github.com/dysinger/clojure-json/tree/master
01:10dysingerI 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
01:18danlarkindysinger: your git-fu is stronger than mine, how are you pushing commits to github and then they're not there anymore?
01:18dysingergit push -f
01:19dysingergit reset
01:19dysingergit push -f (again)
01:19dysingeror git push --mirror
01:19dysingerwould do it too
01:32dysingerdanlarkin thanks again - it's working perfectly - I am pushing json through rabbitmq and back
01:34dysingerwute I love lisp
01:44hiredmanclojurebot: arguments is <reply>http://www.pigdog.org/auto/mr_bads_list/shortcolumn/1914.html
01:44clojurebotc'est bon!
01:44hiredmanclojurebot: what are some arguments I can use to get out of this mess?
01:44clojurebothttp://www.pigdog.org/auto/mr_bads_list/shortcolumn/1914.html
02:26Lau_of_DKTop of the morning gents
02:29hiredmangood evening
05:58AWizzArdThe german readers might be interested in this article about Scala: http://www.heise.de/newsticker/Scala-Kombination-aus-funktionaler-und-objektorientierter-Programmierung--/meldung/136206
06:24Lau_of_DKAWizzArd: this is #clojure
06:30antifuchsyou realize that you have to do a leonidas impression while saying this, right?
07:00Lau_of_DKhaha
08:52AWizzArdLau_of_DK: how can I stop a webserver, started from Compojure via (run-server ...)?
08:53Lau_of_DKKill the process
08:53AWizzArdOh. Okay :)
08:53Lau_of_DKOr - compojure.server.jetty/stop
08:54AWizzArdbut this wants to have a server object. (run-server ..) unfortunately doesn't return one.
09:01Lau_of_DKThe server object is just a hash containing a port # no ?
09:08AWizzArdNo, that isn't the server object.
09:09Lau_of_DKTheres a create-server method which returns a server object
09:09Lau_of_DKAnd you can call start/stop on that
09:11AWizzArdYes, it is a private function. I think I should use that instead of the public run-server.
09:11AWizzArdI think run-server should also return the server object.
10:09Drakesonis it possible to get the list of current threads in slime?
10:10Drakeson(e.g. using some combination of clojure-contrib libraries)
10:10Chouseryou can get stack traces for all live threads
10:10Chouseroh, it's both.
10:11Drakesonhow?
10:11Chouser(Thread/getAllStackTraces)
10:11Chouserreturns a map -- keys are Threads, vals are stack traces
10:11Drakesoncool
10:11Drakesonthanks
10:12Drakesonumm, how do you kill a thread?
10:12Chouserhttp://java.sun.com/javase/6/docs/api/java/lang/Thread.html
10:13DrakesonI mean, should I just kill it off, or there are more concerns?
10:13Chouser(.stop thread) -- it's deprecated and discouraged, but it works
10:13Chouserconcerns: http://java.sun.com/javase/6/docs/technotes/guides/concurrency/threadPrimitiveDeprecation.html
10:16Drakesonis it better to interrupt then? what does vimclojure do?
10:16AWizzArdIf it is deprecated, doesn't this mean that Sun could potentially remove this method from the next Java realease?
10:16ChouserAWizzArd: I assume so, yes
10:17ChouserDrakeson: 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:17kotarak_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:17rhickeyright
10:18ChouserDrakeson: is this a single runaway thread, or part of your design?
10:21DrakesonEvery 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:22Chouserhuh. are they cpu-intensive loops, or are they blocked on something?
10:22Drakesonin slime + sbcl we could just interrupt the thread and see a stacktrace. then we could abort or continue it.
10:23DrakesonChouser: they appear during "experimentation". In other words, they are stupid loops where the reason is often a simple mistake.
10:25Chouserif they're loops printing infinite seqs, you probably want to set *print-length* and *print-level*
10:26Drakesonyou shouldn't defend those processes :D They are just half-thought throw-away evals, that happen to loop forever.
10:28Chouserif 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:28Chouserthis might be helpful: http://groups.google.com/group/clojure/msg/b3d1d2fdd1cdc93d
10:32DrakesonChouser: that helps, thanks.
10:34Chouserbut setting *print-length* and *print-level* for interactive repls really is a good idea
10:34Chouseryou can set them once for the whole session. my repl startup script does it for me.
10:36Drakesonwhat values you use for them?
10:42Drakesonwhat does this mean: call to java.io.File ctor can't be resolved
10:43Drakeson(I activated warn on reflection in user.clj)
10:43AWizzArdrhickey: Are you the copyright owner of the Clojure logo, or is your brother? And is the use of that logo restricted?
10:43rhickeyI am - what do you want to do with it?
10:44AWizzArdI 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:46rhickeyas long as you are using it to refer to my Clojure, ok
10:47AWizzArdThanks. The german branch links directly in the group description to http://clojure.org/
10:47rhickeyif Microsoft ever makes IronClosure, then no :)
10:48AWizzArd*g*
10:49pjstadigembrace and extend
10:50ChouserDrakeson: (set! *print-length* 103) (set! *print-level* 15)
10:51Chouserthose are (obviously) pretty arbitrary
10:51Drakesonthanks, I wanted to get a sense of how large they should be.
10:58Chouserhm, actually I have not been setting *print-level*
11:14mihandhey guys. did somebody try clojure and jena?
11:17rhickeymihand: I fiddled with jena briefly - works fine
11:21Chouserrhickey: you're here today. Hi, how are ya? :-)
11:21rhickeyChouser: fine, thanks
11:21slashcomWhen the manual says combine, does it mean use the Combine Children script?
11:22rhickeyaccessing AWS from Clojure - a total blast
11:22slashcomoh shoot
11:23mihandrhickey: do you have some examples? I'm particulary interested in wrapping the iterators to seqs
11:23Chouserrhickey: ah, good. I've started a little GAE thing (because of the free pricepoint) but I'm still just swimming in foreign xml.
11:23Chouserslashcom: wrong channel?
11:23slashcomyes :)
11:23rhickeyI'm just dropping maps in Simple DB, querying with Clojure data literals...
11:24rhickeyno XML in sight
11:24Chouserlovely
11:24ChouserI think the web service xml stuff will be a one-time thing, hopefully.
11:24AWizzArdBtw, is there a helper for serializing refs? For example refs of hashmaps which can have values that are refs itself?
11:25rhickeyChouser: there's no Java lib wrapping that bit?
11:25RaynesWell, there goes using the Clojure logo as an avatar for forums :\
11:25rhickeymihand: 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:26Chouserrhickey: dunno, just following tutorials at this point. I've still done essentially no java servlets before.
11:26mihandrhickey:thanks for the pointer
11:26rhickeyChouser: oh that bit, yeah, one-time copy the config files...
11:27Chouserright, that bit.
11:28rhickeyParameterized query of simpledb:
11:28rhickey(let [cat "Clothes"]
11:28rhickey (query client
11:28rhickey `{:select * :from "test" :where (or (= :category ~cat) (= :category "Car Parts"))})))
11:28Chouseroh, yum
11:29rhickeysit at the repl and put your data in the cloud...
11:29Chousukeheh, clever.
11:29rhickeycreate an item:
11:29rhickey(put-attrs client "test"
11:29rhickey {:sdb/id (uuid "e76589f6-34e5-4a14-8af6-b70bf0242d7d"),
11:29rhickey :category "Clothes",
11:29rhickey :subcat "Pants",
11:29rhickey :Name "Sweatpants",
11:29rhickey :color #{"Yellow" "Pink" "Blue"},
11:29rhickey :size "Large"})
11:31ChousukeI would never have thought of using maps like that.
11:31rhickeybasically read/write Clojure data - no query strings, no conversions, no resultsets, no friction
11:32AWizzArdrhickey: 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:34Chouser,(for [[a b] [[1 2] [3 4]]] (+ a b))
11:34clojurebot(3 7)
11:38AWizzArdIt works if the collection is already packed correctly.
11:38Chouseryou expect destructuring to work on incorrectly formatted collections?
11:38AWizzArdif 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:39AWizzArd,(let [[a b] [1 2 3 4 5]] (list b a))
11:39clojurebot(2 1)
11:39Chouserthat's what partition is for
11:39AWizzArdWould partition be needed if for would support directly destructuring?
11:40AWizzArdI know there are workarounds, but for example my let from above didn't need to call partition.
11:40Chouseras 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:41AWizzArd,(let [[a b] [[1 2] [3 4]]] (+ a b))
11:41clojurebotjava.lang.ClassCastException: clojure.lang.LazilyPersistentVector cannot be cast to java.lang.Number
11:41Chouserand while we're on the topic, what are you doing with key/value pairs not in a map collection?!? :-)
11:41AWizzArdI thought destructuring in FOR could behave like it does in let.
11:42Chousuke,(for [[a b] [1 2 3 4]] [b a])
11:42clojurebotjava.lang.UnsupportedOperationException: nth not supported on this type: Integer
11:42AWizzArdChouser: k/v pairs are just one example.
11:42Chousuke,(let [[a b] [1 2 3 4]] [b a])
11:42clojurebot[2 1]
11:43Chouser'for' iterates, 'let' does not, so they can't be idential.
11:43Chouserah, and you switched to 'let', I hadn't caught that. hm...
11:43AWizzArdthe NTH thingy comes from the when-first
11:43AWizzArd~def for
11:43AWizzArdAlso see 5:13 at http://clojure-log.n01se.net/date/2009-04-09.html
11:43Chousukedestructuring 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:43Chouser,(for [[a b] [[1 2 3 4]]] (list b a))
11:43clojurebot((2 1))
11:44AWizzArdjdz, hiredman and I were talking about it
11:44Chousukeit makes perfect sense for for to behave like that.
11:44Chouser,(for [[a b] (partition 2 [1 2 3 4])] (list b a))
11:44clojurebot((2 1) (4 3))
11:44AWizzArdyes sure, with partition it works
11:44ChouserI wouldn't call that a workaround so much as just saying what you want
11:45Chouserbecause maybe that's not what you want, maybe you want: ,(for [[a b] (partition 2 1 [1 2 3 4])] (list b a))
11:45Chouser,(for [[a b] (partition 2 1 [1 2 3 4])] (list b a))
11:45clojurebot((2 1) (3 2) (4 3))
11:45ChousukeAWizzArd: in my opinion, it'd be wrong for (for [[a b] [1 2 3 4]] (list b a)) to work
11:46AWizzArdIt would be taking each time two things out of the list, instead of always the first.
11:46AWizzArdChousuke: what output would you expect from that for?
11:46Chousukebut that wouldn't make sense.
11:46ChousukeAWizzArd: an error.
11:46AWizzArdNot ((2 1) (4 3))?
11:46Chousukenope
11:46Chousukesince the semantics of the for binding form differs from let's
11:47Chousukethe destructuring on the right side applies to *each* element in the collection you provide, because that's how for works
11:47Chousukeand you can't destructure "1" as [a b] so it should give an error
11:48AWizzArd,(partition 2 "123")
11:48clojurebot((\1 \2))
11:48AWizzArd,(partition 2 "1")
11:48clojurebot()
11:49Chousukeit's not about doing automatic partitioning
11:50AWizzArd,(let [[a b] "1"] (list b a))
11:50clojurebot(nil \1)
11:50Chousukenote that I meant a literal 1 with "1" in that case :P
11:50AWizzArdI 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:51AWizzArd,(let [[a b] 1] (list b a))
11:51clojurebotjava.lang.UnsupportedOperationException: nth not supported on this type: Integer
11:51AWizzArdYes, in that case I would FOR also like to throw an Exception.
11:51Chousukeas 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:52Chousukeand adding this kind of hidden behaviour into for would in my opinion just make it more complicated and more error-prone :/
11:53Chousukeas then you might have your destructuring work for data you didn't *intend* it to work with in the first place.
11:53Chousukeif 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:54Chouserif 'for' tried to partition automatically, what would you want it do with something like: (for [{a :a} {:a 1 :b 2}] a)
11:54Chouserthat's a valid 'let' form:
11:54Chouser,(let [{a :a} {:a 1 :b 2}] a)
11:54clojurebot1
11:55Chousuke,(for [{a :a} {:a 1 :b 2}] a)
11:55clojurebot(nil nil)
11:55Chousukehmm :P
11:55Chousukenot surprising I guess.
11:55Chousuke,(for [{a :a} [{:a 1 :b 2}]] a)
11:55clojurebot(1)
11:55AWizzArdI find it a bit surprising
11:55ChousukeAWizzArd: I think you misunderstand how for works.
11:56ChousukeAWizzArd: the binding form is not like let.
11:56Chousukea let takes a simple list of a = b pairs
11:56AWizzArdI 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:57Chousukefor 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:57AWizzArdanyway, gtg
11:57Chousukedestructuring in for does not destructure the collection, it destructures each item in the collection
11:58Chousukemixing the different destructurings just makes it more complicated :/
11:58digashand then there are others that behave the same way as for, like doseq
11:58Chousukehow could you tell whether it's going to destructure the collection or the items?
11:59ChouserAWizzArd_: what would you expect from (for [[a b] [[1 2] 3 4]] (list b a))
12:05digashone thing that always trip me up on the destructuring form is
12:05digash,(let [{:a a} {:a "a" :b "b"}] a)
12:05clojurebotjava.lang.Exception: Unsupported binding form: :a
12:05digashvs
12:05digash,(let [{a :a} {:a "a" :b "b"}] a)
12:05clojurebot"a"
12:06Chouseryeah, it's easier to remember if you keep in mind features like :keys, :or, etc.
12:06Chouser,(let [{:keys [a]} {:a 1 :b 2}] a)
12:06clojurebot1
12:07digash,(let [{a :keys} {:a 1 :keys 2}] a)
12:07clojurebot2
12:08digash:)
12:08Chouserexactly my point
12:08digashmakes total sense to me now, thanks
12:20Cark"There are similar :strs and :syms directives for matching string and symbol keys."
12:20Carkbut there's no example of that
12:20Carkoh sorry i see !
12:21Cark,(let [{:strs [a]} {"a" 1}] a)
12:21clojurebot1
12:26digashi wish i could do something like = in Erlang
12:26digash,(if-let [[a :a] ["a" :a]] a)
12:26clojurebotjava.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.Exception: Unsupported binding form: :a
12:27digashthe common idiom in Erlang is to do asserts like {ok, S} = file:open("filename", [read])
12:38dakrone_hbthanks kotarak
12:46dakrone_hbkotarak, 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:47dakrone_hbkotarak, did you drop off?
12:47kotarak_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:48dakrone_hbokay, then probably missed my question
12:48dakrone_hbfirst, thanks for vimclojure :)
12:48kotarak_:) Thanks.
12:48dakrone_hbsecond, 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:49kotarak_yes. clojure.jar=/path/to/your/clojure.jar in local.properties should do the trick
12:50dakrone_hbI have it set to the correct jar, latest from svn, still getting that error
12:50kotarak_hmmm... let me check
12:56dakrone_hbcould '~'s in the path be confusing it? (ie, does it need full-path?)
13:03kotarak_dakrone_hb: no ~ please. That is shellism!
13:04dakrone_hbkotarak_, oka
13:04dakrone_hby
13:05dakrone_hbcool, that works, thanks kotarak_
13:05kotarak_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:06kotarak_dakrone_hb: np. :)
13:08kotarak_dakrone_hb: btw: you can use vim for path completion. clojure.jar = /<C-x><C-f> (note: whitespace around the =)
13:26gnuvinceHey 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:30Chouserhow do you define success? what if suggested naming him "George"?
13:31kotarakSombrero?
13:31grkzI'd go with "Billy-Bob"
13:32gnuvinceChouser: 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:32ChouserI think this could be correctly characterized as "without success"
13:33gnuvinceso far, your suggestions are pretty much the same as in other channels.
13:34Chouserwhere does one find a mathemetician?
13:34kotarakI am, but I don't know whether this specific function has a common name.
13:35Chouserthe combination of a curve below 1 and a line above 1 seems unusual
13:36dysinger#lol http://shouldiusescala.com
13:36Chousergnuvince: what are you using it for?
13:37gnuvinceChouser: 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:37gnuvinceconditionally using reciprocal looks nicer
13:37gnuvincebut I need a good name for it.
13:39Chousukewhat would you call the result of that function? is it used as a coefficient of some sort?
13:40cemerickkotarak will eventually regret having admitted to being a mathematician... ;-)
13:40gnuvinceit's to be used as a ratio for resizing an image.
13:40yasongnuvince: just use it first and when your program is finished enough you have come up with a good name
13:40gnuvinceyason: my program is finished :)
13:40yason=you will have
13:40gnuvincethe tests are done and pass
13:41gnuvinceI'm at the part where I take the code written hastily and refactor it into nice, understandable functions.
13:41Chousukegnuvince: 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:41yasongnuvince: well, it doesn't exactly ring a bell here. So just describe it based on how you're using it
13:42gnuvincenevermind.
13:42Chousukeso you could use it something like (* (scaling-factor) whatever)
13:42Chousuke(forgot the parameter, but meh)
13:42gnuvinceand Chousuke wins!
13:42gnuvincescaling-factor is perfect
13:44yasonglad you found it!
13:52Lau_of_DKHey guys
14:32hiredmanwoa
14:33pjstadigwoa, what?
14:34hiredmanvimclojure now spits out about two screens worth of errors when I try to open kevin.clj
14:34kotarakhiredman: what kind of errors?
14:36hiredmankotarak: 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:37kotarakhiredman: try :messages
14:37kotarakWas kevin.clj correctly in the classpath?
14:38kotarakVC really relies on this.
14:38hiredmanCouldn't execute Nail! java.lang.Exception: Unable to resolve symbol: lazy-cons in this context (kev
14:38hiredmanin.clj:19)
14:39hiredmanmakes sense
14:40hiredmanand it isn't on the classpath correctly, so I did not really expect vimclojure to handle it properly
14:40hiredmanalthough \eb works, but \et just seems to eval the first form in the file
14:41kotarakhmmm... \et should evaluate the form the cursor is in...
14:42hiredmanwait, kevin.clj is on the classpath, just no namespace declaration and it has lazy-cons in it
14:42hiredmanif 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:43hiredmanwhich is kind of annoying, I would hope even if vimclojure cannot do the nailgun thing it would still let me open the file
14:44kotarakHmm.. Ok. I'll see that I can make it more robust.
14:44hiredmanshit
14:45hiredmanI opened clojurebot.clj in vimclojure
14:45hiredman^-
14:45hiredmanI didn't hit \ef or anything
14:46hiredmanthat also explains why kevin.clj was throwing an error about lazy-cons
14:46hiredmanand it explaims why loading a clojure buffer was so much slower
14:47kotarakIt explains all these things?....
14:47hiredmanyeah
14:47hiredmanvimclojure is evaling the whole file when I open a clojure file
14:48hiredmanwhich is why PircBot showed up when I did :tabe clojurebot.clj
14:48kotarakIt's basically require'ing it. To set up the aliases, uses and requires. This is necessary for completion and syntax highlighting.
14:48hiredmanit is very annoying
14:48kotarakWell. You can turn it off: let clj_want_gorilla = 0
14:49hiredmanyeah
14:49hiredmanI just did
14:49hiredmanno wonder it was choking on kevin.clj
14:49hiredmanthat file is ancient
14:50hiredmanand full of syntax errors and what not
14:50brennanccan someone point me in the right direction on how to learn about Clojure's XML capabilities?
14:50hiredman well, there is clojure.xml
14:50hiredmancontrib has some xml processing related stuff too
14:51brennancany docs or tutorials?
14:52hiredman~google clojure xml
14:52clojurebotFirst, out of 48300 results is:
14:52clojurebotClojure � java_interop
14:52clojurebothttp://clojure.org/java_interop
14:52hiredmanwell, that's not very helpful
14:53brennancI found a little bit here and there in google but not much
14:53kotarakhiredman: yeah, I need a more robust incremental reader...
14:53hiredmanif you use clojure.xml/parse it turns xml into a map structure
14:54kotarakhiredman: currently I really on the stock clojure reader. So the files must be halfway sane...
14:54hiredmankotarak: the fact that they are read at all is a deal breaker
14:55hiredmanclojurebot.clj is perfectly sane
14:55hiredmanbut I don't want copies of clojurebot launching everytime I open it
14:55hiredman,(impot 'java.io.StringBufferInputStream)
14:55clojurebotjava.lang.Exception: Unable to resolve symbol: impot in this context
14:55hiredman,(import 'java.io.StringBufferInputStream)
14:55clojurebotnil
14:55hiredman,(clojure.xml/parse (StringBufferInputStream. "<foo>bar</foo>"))
14:55clojurebotEval-in-box threw an exception:java.lang.NoClassDefFoundError: clojure/lang/PersistentStructMap$Seq
14:56hiredmanwhoops
14:56kotarakhiredman: 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:57hiredmanok
14:57hiredmanvimclojure is not "reading" it is "evaling"
14:58kotarakhiredman: ok. point taken. Then you will have to live with static vimclojure and what vim itself gives you. Eg. <C-n>.
14:59hiredmanI would be surprised if you don't get more complaints about this
15:00lispblissIs there a way to use the xml-seq on non-perfect xml? (most html)
15:01kotarakhiredman: you are the first up to now...
15:01hiredmanxml-seq works on the map structure returned by clojure.xml/parse
15:01kotarakBut I will look into improve things in that respect.
15:01kotarakMaybe bailing out in case of a problem.
15:01lispblisshiredman: if parse won't take it, do you have any other options?
15:01hiredmanI forget exactly, but I think you can pass a parser to parse
15:02hiredmanso if you have a parser that can read broken xml you can pass it to parse
15:02hiredman,(doc clojure.xml/parse)
15:02clojurebot"([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:02Chouseryou can use tagsoup for example to get good parsed xml out of bad html
15:02brennanczippers the best way to go through it after that?
15:03brennancI'm basically going through XHTML and replacing certain tags with logic
15:03Chouserbrennanc: I like zippers and zip-filter for plucking out information
15:04Chouserbrennanc: if you're replacing content, zip-filter might be a bit too clumsy still. but zippers should work fine.
15:04hiredman,(doc clojure.zip/next)
15:04clojurebot"([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:04brennancahh, that could be useful :)
15:04Chouserbrennanc: 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:04hiredmanclojurebot: transform?
15:04clojurebottransform is http://github.com/hiredman/odds-and-ends/blob/8a84e6ddbad9d71f714ba16c3e1239633228a7eb/functional.clj
15:05lispblissChouser: great, looking into tagsoup right now. You don't happen to have a pasteable snippet that shows you combine tagsoup with parse?
15:05hiredmanbrennanc: transform, transforml and transformr might be useful as well
15:07brennancI basically have a tag like <blah:iterateCollection src="col" as "x"> <li><%= x.name %></li></blah:IterateCollection>
15:07brennanctrying to make a templating system so users can upload dynamic sites but not give them access to do anythign "bad"
15:08lisppaste8Chouser pasted "tagsoup -> parse -> xml-zip" at http://paste.lisp.org/display/78642
15:08lispblissChouser: thanks
15:13hiredmantransform is a helper function for a macro that does code transformation using zippers
15:16lispblissFrom 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:16hiredman~javadoc java.awt.Toolkit
15:21lispblissoh, I guess that is what getSystemSelection does, but it doesn't work on Windows.
15:36cemerickIn the "I can't believe I've gotten so far with so little" department: why do symbols and keywords exist in clojure?
15:36cemericks/and/*and*
15:37spacema__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:37hiredmancemerick: objects that evaluate to themselves are handy
15:37danlarkinspacema__: I haven't tried it recently, do the tests run? what's the error
15:38cemerickhiredman: symbols and keywords don't both evaluate to themselves?
15:38rhickey,rest
15:38clojurebot#<core$rest__3094 clojure.core$rest__3094@16181be>
15:38rhickey,:rest
15:38clojurebot:rest
15:38Drakeson,#{() nil}
15:38clojurebot#{nil ()}
15:39hiredmancemerick: nope
15:39cemerickright, right, what I'm driving at is, isn't there a big overlap in the usage of keywords and symbols?
15:39durka42,'rest
15:39clojurebotrest
15:40rhickeycemerick: no, symbols are usually used to designate something else, and keywords always to designate themselves
15:40hiredmancemerick: 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:40rhickeyhiredman: no, keywords are in CL for the same reasons
15:40cemerickrhickey: that's just a question of idioms, though, right?
15:41rhickeyno
15:41Drakesonis there a [mostly] declarative GUI toolkit for clojure, yet?
15:42spacema__danlarkin: nm, I got it; sorry abotu that. By the way, I haven't been following closely, but how's Madison coming?
15:42rhickeyit has to do with print/eval, with keywords that is value preserving, with symbols it isn't - they need quoting
15:43hiredmanah
15:43cemerickhuh
15:43pjstadiga quoted symbol is actually a list 'rest => (quote rest)
15:43pjstadig' is a reader macro
15:44pjstadig(eval 'rest) => rest
15:44danlarkinspacema__: 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:44rhickey,(eval (read-string (pr-str :foo)))
15:44clojurebotDENIED
15:44pjstadig(eval (eval 'rest)) => whatevery rest points to
15:44cemerickrhickey: 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:44rhickey(eval (read-string (pr-str 'foo)))
15:44pjstadig(eval (eval :key)) => :key
15:45pjstadig(eval (eval (eval :key))) => :key
15:46rhickeycemerick: eval is special for symbols and sequences, not for keywords/strings etc
15:47rhickeycemerick: there's no optional idiom about it, else no variables/locals in the language
15:48cemerickOK, I think I'm grokking it now.
15:49rhickeyuser=> (def x 42)
15:49rhickey#'user/x
15:49rhickeyuser=> {:x x}
15:49rhickey{:x 42}
15:49rhickeyuser=> {'x x}
15:49rhickey{x 42}
15:49rhickeyuser=> {x 42}
15:49rhickey{42 42}
15:50rhickeyquoted symbols don't round-trip
15:51cemericksure, 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:51cemericks/now/already
15:51rhickeycemerick: all var names as keywords?
15:52cemerickyeah (I think)
15:52cemerickIt does seem possible, but you'd end up doing a runtime lookup for every symbol in the expression you evaluate.
15:53cemerickwriting a lisp interpreter would likely clarify these things for me pretty quickly :-)
15:53rhickeyso how do you say {'x x}, and print it evaluably?
15:54rhickeyfor whatever syntax of foo and the-thing-named-by-foo you desire
15:55rhickeyit's keywords that are optional, you could instead use strings
15:57cemerick{'x x} drove it home, thanks
15:57cemerickwhew, I love asking dumb questions! :-D
15:58rhickeycemerick: lisp interpreter still a good exercise - once you've done that you are in a whole different place in thinking about lisp
15:58hiredmanI should finish mine
15:58cemerickyeah, it's in my long todo list :-/
15:58djkthxlisp compilers are where it's at!
15:59pjstadighow would I do something like (if (seq? x) (some-seq-stuff) (some-atom-stuff))?
15:59rhickeyhttp://www.amazon.com/Lisp-Small-Pieces-Christian-Queinnec/dp/0521562473
15:59rhickeyhttp://www.amazon.com/Essentials-Programming-Languages-Daniel-Friedman/dp/0262062798/ref=pd_sim_b_24
15:59pjstadigseq? only returns true if x implements ISeq
15:59pjstadig,(seq? [])
15:59clojurebotfalse
15:59pjstadig,(seq? (seq []))
15:59clojurebotfalse
16:00hiredman...
16:00kotarak,(seq? (seq [1]))
16:00clojurebottrue
16:00kotarak,(nil? (seq []))
16:00clojurebottrue
16:00rhickey,(doc coll?)
16:00clojurebot"([x]); Returns true if x implements IPersistentCollection"
16:00pjstadig(coll? ())
16:00hiredmanpjstadig: you might use instanceof?
16:00pjstadig,(coll? ())
16:00hiredmanor instanceof
16:00clojurebottrue
16:00pjstadig,(coll? [])
16:00clojurebottrue
16:00pjstadig,(coll? #{})
16:00clojurebottrue
16:01cemerickI read through lisp in small pieces years ago...I probably just took along the minimum of what I needed :-)
16:01pjstadigso CL would be (if (list? x) ...) and clojure would be (if (coll? x) ...)
16:02hiredmanpjstadig: (instance? java.util.Collection ...) is more general
16:03djkthxpjstadig: vectors won't return true to listp
16:03rhickeypjstadig: 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:03djkthx* (vector 1 2 3)
16:03djkthx#(1 2 3)
16:03djkthx* (listp (vector 1 2 3))
16:03djkthxNIL
16:03rhickeyit ends up atom is not a rich abstraction
16:03djkthxheh
16:03rhickeyCL atom
16:03pjstadigright sorry i meant listp
16:03rhickeyseq? is most similar to listp
16:03djkthxyeah
16:04pjstadigi'm trying to write a macro that does something to lists, but leaves numbers, strings, etc. alone
16:04pjstadigi guess seq? is all i need
16:04Chouserrhickey: did you notice you just recommended a $270 book?
16:04pjstadigi don't need to treat vectors, hashmaps, sets, etc. specially, they should probably fall through too
16:04hiredmanpjstadig: (instance? java.util.List ...)
16:05rhickeyif you want to catch vectors also, there's sequential?
16:05rhickeyfor all collections, coll?
16:05rhickeydepends on what you want to do
16:05pjstadigok
16:06hiredmanChouser: holy crap
16:07hiredmanI love how peter norvig is the most helpful review
16:09rhickeyhttp://books.google.com/books?id=81mFK8pqh5EC&amp;dq=lisp+in+small+pieces&amp;printsec=frontcover&amp;source=bn&amp;hl=en&amp;ei=IzzmSaLzLI6Mtgeh0sWXAg&amp;sa=X&amp;oi=book_result&amp;ct=result&amp;resnum=4
16:11cemerickChouser: $270 books aren't a problem. The real problem are theses that have never been printed.
16:12pjstadigcemerick: i know. I wrote a thesis about that.
16:12pjstadigbut i never printed it
16:12cemerickpjstadig, always part of the problem, never part of the solution ;-)
16:13Chouserhm, seems like a joke I'm not getting?
16:13cemerickI think it's all improv, anyway.
16:14pjstadigi wrote a thesis about things that seem like jokes too...
16:14pjstadig~but then suddenly
16:14clojurebotCLABANGO!
16:14kotarakmy thesis was a joke..
16:14Chousercertainly nobody's going to print cemerick's joke about theses.
16:15cemerickheh, no one is going to print ANY of MY jokes, EVAH!
16:16cemerickChouser: remember, my legendary bad sense of humor
16:16cemerickor, my grand sense of humor that I share with almost no one
16:17Chousukeisn't that functionally equivalent to having a bad sense of humour? :)
16:18cemerickonly to other people
16:18cemerickI find myself hilarious! :-P
16:18Chouseronly christophe's sense of humor can safely be called grand
16:18ChousukeWell, yeah. Sometimes it suffices to look in the mirror.
16:18cemerickboom. ouch.
16:25danlarkiny'all should stick to writing code
16:25hiredmanlisp in small pieces seems to be much cheaper on barnes and noble
17:21brennanchow 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:22kotarakbrennanc: (use 'clojure.contrib.zip-filter)
17:22clojurebotclojure is the bestest programming language available.
17:22brennancI get the following:
17:22brennancjava.lang.IllegalStateException: descendants already refers to: #'clojure.core/descendants in namespace: user (NO_SOURCE_FILE:0)
17:22brennancwhen I do that
17:22AWizzArdChouser: 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:23kotarakbrennanc: (use 'clojure.contrib.zip-filter :exclude (descendants))
17:40ChouserAWizzArd: 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:43Chouserbut 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:43cp2ugh, i cant believe i just woke up
17:51AWizzArdChouser: 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:52AWizzArd(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:52ChousukeAWizzArd: just make a version of partition that returns the remnant as well
17:53Chousukethen you'll get ((3 2 1) (nil 5 4)) for the first one
17:53Chouserseq-utils/partition-all
17:54Chousuke,`partition-all
17:54clojurebotsandbox/partition-all
17:54Chousukehm, no contrib still :/
17:55Chousukeor...
17:55Chousuke,clojure.contrib.seq-utils/partition-all
17:55clojurebotjava.lang.ClassNotFoundException: clojure.contrib.seq-utils
17:55Chousukemeh.
17:57AWizzArd(doc sandbox/partition-all)
17:57clojurebotTitim gan �ir� ort.
17:59hiredmanI swapped out the clojure and clojure-contrib jars out from under clojurebot so somethings are a little fubar
18:02dysingerso I am messing around with rabbitmq again today
18:02dysingerhttp://gist.github.com/96053
18:02dysingermy question
18:02dysingerhow do I create a seq out of something that uses a callback :/
18:03dysingerI was hoping to do (for [msg (repeat (consume-from-rabbitmq-queue)] .....
18:03dysingerrabbtimq's java api uses a callback for a msg consumer
18:04dysingerinstead of just a blocking call
18:04kotarakHmmm... isn't there seque or something which might be used?
18:05kotarak(doc seque)
18:05clojurebotCreates 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:05hiredmandysinger: have the callback push things onto a queue
18:05dysingerok - that's an idea
18:05hiredmanunless it is already a Queue
18:06dysingerseems strange to consume from rabbitmq queue and put on a java queue
18:06hiredmanwhich I guess it is
18:06dysingerwish they would have just provided a blocking queue -like interface to call
18:07hiredmandysinger: well, it is pretty easy to build one on top
18:07dysingerok I'll think about it more thanks
18:16dysingerhmm seque looks like it get's it's feed from another seq
18:16dysingerThis callback message api is upside-down from what I am used to (blocking queue)
18:52Carkdysinger : you can use (clojure.lang.PersistentQueue/EMPTY)
18:52Carkthen puch pop and peek
18:52Carkpush =/
19:41brennancI 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:43hiredmanyou wnat a function to turn "foo" into :foo ?
19:43brennanccorrect
19:43hiredman,(keyword "foo")
19:43clojurebot:foo
19:43brennancI tried symbol but it didn't work
19:43hiredman,(symbol ":foo")
19:43clojurebot:foo
19:43brennancahh, was thinking they wre called symbols
19:43hiredman:P
19:44hiredmansymbols and keywords are different
19:44brennancawesome, thanks
19:44hiredmanactually rhickey was in here earlier today and someone asked him about keywords
20:55stuhoodwhere can i find a good explanation of all the features of binding-forms, like destructuring, etc
20:55stuhoodshoot, special_forms on the website
21:34delitescereI'm at the first Chicago Clojure user group (yay!)
21:35delitescerehttp://onclojure.com/chicago/
21:36delitescereRich - any plans to be here this year?
21:51stuhoodin a gen-class'd class, it looks *ns* is always clojure.core
21:51stuhoodis there a way to have the methods of the class execute in the context of whatever namespace gen-class was run in?
22:02slashus2Is there something like pany in clojure's core? None parallel?
23:09lisppaste8slashus2 annotated #78128 "another test" at http://paste.lisp.org/display/78128#5
23:09slashus2I didn't mean to paste this here, sorry.
23:17montyhi. 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:18danlarkinmonty: you can use ant, not javac though
23:19montydanlarkin: so how do you initiate the compile call?
23:21montyi think i found it: clojure.lang.Compile
23:22danlarkinmonty: correct
23:22danlarkinmonty: here's an example http://github.com/danlarkin/clojure-json/blob/edf253b9231d3abecc93408c49e7349754da320f/build.xml
23:23montyawesome, thanks!
23:23hiredmanI would use: java clojure.main -e "(compile 'some.name.space)"
23:24montyhmm, that looks handy too
23:25montyive been learning clojure this week playing around with the google appengine
23:28montyhow would you set clojure.complie.path, if you were just doing it from the command line?
23:30hiredmanI would use: java clojure.main -e "(set! *compile-path* \"/some/path\") (compile 'some.name.space)"
23:30montyi see. thanks
23:31montysince it generates a few class files, ie. example__init.class, example$_main, are all this needed?
23:32hiredmanyes
23:33hiredmanone class per function, and then if you are using gen-class, another class named class you generated
23:34stuhoodmonty: i think you can also set a java system property for the compile path: aka `java -Dclojure.compile.path=classes`
23:36montyi wonder, since appengine has a limit of 1000 files, and 1 class file per function would add up
23:36montymaybe i can jar them all together
23:45montyone more question, anyone know how to set failonerror=true to java at the command line?
23:59stuhoodthe failonerror part is ant specific: it just causes ant to fail the build if the java binbary returns anything other than 0