#clojure logs

2010-01-01

00:01chouserHappy new year!
00:02piccolinoHappy new year, Mr. East Coaster!
00:02chouser:-)
00:02dandersenHappy New Year =]
00:42replacaHappy new year, #clojure. Looking forward to 2010!
01:54optimizerwhat's a good resource for java gui's with clojure?
01:54pdkthe java_interop page on the clojure site illustrates using swing with clojure
01:55optimizerurl?
01:55pdkremember that you can call java code directly within clojure so you can just pick whatever you want that already works with java and use it in a very similar way in clojure
01:55optimizeryeah; but I don't know java; lol
01:55pdkhttp://clojure.org/jvm_hosted
01:55pdka little example of how swing code in clojure looks basically the same as in java
01:56optimizeri heard bad things about awt/swing
01:56optimizerwhat gui library should I ue?
01:56optimizer*use*
01:56pdkjava comes with awt and swing out of the box for gui programming, you should be able to find plenty of tutorials
01:56optimizermy background is c/c++/scheme /opengl
01:56pdkwe'll have to know what sort of things you want out of your gui library, what sort of application you expect to write with it etc
01:57pdkwhat sort of things in a widget toolkit are important for the program youre writing, things like native look and feel, speed, portability etc
01:57optimizeris there a central refernce that lists the options & tradeoffs?
01:57optimizeri want to write a text editor that supports wysiwyg math rendering
01:57optimizerkinda like texmacs / lyx
01:57optimizerbut in clojure
01:57piccolinoWell, I'm pretty sure you can knock AWT right off the list.
01:58optimizerpiccolino: why?
01:58pdkas far as i know the most well-known alternative to awt/swing is SWT
01:58piccolinoIt's not really adequate for anything.
01:58optimizerpdk: the one by eclipse/ibm?
01:58pdkeclipse for example is entirely swt based
01:58pdkyeah
01:58pdkand i assume there'd be a wxwidgets binding
01:58optimizereclipse looks pretty nice
01:58piccolinoHave they packaged SWT up so it's easy to use on it's own yet?
01:59pdkthere's a slashdot post discussing swing vs swt in the comments
01:59pdkhttp://developers.slashdot.org/article.pl?sid=06/02/25/2110220&from=rss
01:59optimizeryou know what? if it's good enough for eclipse; it's good enough for me
01:59optimizerbut I will read the link; thanks
01:59pdkhere's a java binding to wxwidgets http://jwx.sourceforge.net/
02:00optimizerpdk: you realize this is irc and not a $$$/hr consulting job right? :-D
02:00pdkif you want native look and feel on every platform you're delivering the program for then yes you'll want swt or wxwidgets
02:00pdkwell you want to make picking up clojure not painful :p
02:01pdkswing has its own look and feel so it's the same on every platform but doesn't really mesh with any of them
02:01optimizerfavorite comment:
02:01optimizerBuoy [sourceforge.net] is your friend. It's built on top of Swing, but it's actually sanely usable. I recommend it on the grounds that it is the only Java GUI toolkit I have ever used that did not leave me longing for the sweet embrace of death. Developing an application using Buoy is substantially less painful then stabbing yourself in the eye with a fork. In the world of Java GUI development, this is high praise indeed.
02:01pdkexcept for probably solaris or something
02:01optimizerman; reading this makes me want to juse use jogl :-)
02:02pdkprovided you're up for writing your own widgets :p
02:02piccolinoI suspect you'll wind up on wxwidgets.
02:02pdkactually iirc there should be little windowing libraries for lwjgl
02:02pdkjust as there were for pygame
02:03pdkin terms of running fast swt and wxwidgets will probably trump swing
02:03pdkthough swt might not have the kitchen sink or be as concise in code
02:10optimizerhttp://www.dragmath.bham.ac.uk/index.html#Download
02:10optimizerhmm; looks like someone already invnted it
02:11pdkit can be a language learning exercise at least
02:15optimizeris enclojure written in clojure?
02:15pdkthat's its claim to fame
02:16pdkoh wait
02:16pdki thought you meant compojure there, i'd assume enclojure would be a mix of java/clojure as it's a netbeans module
02:16optimizerwait; this is weird; i see a clojure-1.1.0.zip that is uplaoded in may 2009 ... but i recall reading the changelog for 1.1 just today
02:16pdkcompojure is a clojure based web server
02:16pdkthe older one would most likely be a poorly labeled release candidate
02:17hiredmanframework
02:17pdkwell web server framework
02:17optimizerhttp://code.google.com/p/clojure/downloads/list
02:17optimizerwhere do I get the latest?
02:17optimizeroh
02:17hiredmanpdk: nope
02:17optimizeri see the 17 hours ago one
02:17optimizerokay
02:17pdkbut yes you'll want the most recently dated 1.1.0
02:17pdkthat one looks like 1.0.0 to me :p
02:18optimizeryeah; perhaps i need new glasse
02:18optimizerhmm, i just built clojure with ant
02:18optimizeris there no 'ant install' ?
02:19pdkhttp://en.wikibooks.org/wiki/Clojure_Programming/Getting_Started this part talks about installing clojure through ant
02:19pdkand git
02:20optimizerThe state of the art in using Vim to edit Clojure code is the VimClojure plugin (recently merged with the Gorilla plugin, and depends on having a Ruby-enabled Vim (A Windows build of vim including Ruby support can be found here)).
02:20optimizerthat sounds like such a hack
02:20pdkone thing you learn from it all is
02:20pdklispers love emacs :p
02:21optimizertoo bad emacs love elisp
02:24defnelisp is a lisp
02:24defnwhat's not to like?
02:25defnelisp is the ruby to my clojure
02:32optimizerdoes clojure run on java 7? (i use xmonad; and apparently xmonad dislikes java gui's on java 6)
02:34pdkit runs on at least 6
02:34pdkif i recall possibly 5 to
02:34pdktoo
02:34pdkthough i wasn't aware of a 7 haha
02:40hiredmandefn: lack of lexical scoping
05:59LauJensenMorning team
06:24MecHow might I make a sequence that is the running total of another sequence? ex [1 2 3 4 5] -> [1 3 6 10 15]
06:30cark,(doc reductions)
06:30clojurebot"([f coll] [f init coll]); Returns a lazy seq of the intermediate values of the reduction (as per reduce) of coll by f, starting with init."
06:31Mecis that in contrib?
06:32hoeckMec: in clojure.contrib.seq-utils
06:33Mecthanks
06:48LauJensenclojurebot: source reductions
06:48LauJensenBeautiful
06:56Mecwow i have no idea what thats doing
06:57Mecit seems like you should be able to use reduce to do that
07:05cark,(reductions + [1 2 3 4 5])
07:05clojurebot(1 3 6 10 15)
07:06carksorry i had to go afk and couldn't follow up
07:23Mec,(reduce #(conj %1 (+ (last %1) %2)) [1] [2 3 4 5])
07:23clojurebot[1 3 6 10 15]
07:23Mecbut that would be really inefficient i think
07:38Mecis for expanded upon anywhere besides the api docs?
07:39carkwhy wouldn't you use reductions ?
07:40carkyou can check the source
07:40carkclojurebot: source for
07:40carkor use macroexpand
07:41MecI can't get clojurebox to load contrib
07:42carkyou need to make sure that clojure-contrib is in your classpath
07:42Mecand for some reason that link wont load past line 1908
07:42carki'm not using clojurebox so i can't help on that
07:43carkhum the link is working for me !
07:43carkfor is a very complex macro anyways
07:43Mechumm
07:44Meci remember reading something before saying like you cant use :while and :when in the same one, but i cant find that now
07:46cark,(for [i [1 2 3 4 5 6 7 8] :when (odd? i) :while (< i 4) ] i)
07:46clojurebot(1 3)
07:46carki don't know, looks like it's working =P
07:46Mechmm im also useing :let ;p
07:47carki think when you have an hardcore for, it might be bad smell
07:47Mec,(for [i [1 2 3 4 5 6 7] :let [j (inc i)] :when (odd? j) :while (< j 5)] [i j])
07:47clojurebot([2 3])
07:49Mecweird, that works for me too, gotta be something else
07:49Mecdoes the order of when and while matter?
07:50Chousukeprobably :P
07:50carkwell it wouldn't be very nice if it did
07:51Mecbah infix error strikes again
07:51Meci had a :when (total = 200)
07:51Chousuke,(for [i (range 10) :when (even? i) :while (odd? i)] i)
07:51clojurebot()
07:52Chousuke,(for [i (range 10) :while (odd? i) :when (even? i)] i)
07:52clojurebot()
07:52gurudoes anybody know sth like assert, which returns expr, if its not nil and throws an exception otherwise?
07:53Chousuke(or expr (throw ...))? :)
07:53guru(assert-ret '(1 2)) -> (1 2)
07:53Mec(and exp (throw)
07:53Mecbah
07:53Mectoo slow
07:53guruyo
07:53gurui prefer or
07:53Mecerr ya or
07:53Chousukeit also fails if expr is false though
07:53guruthe assert exception would be the same as (throw .Exception)?
07:54Chousukeassert throws AssertionError actually
07:54guru,(println "test")
07:54clojurebottest
07:54guru(println "test")
07:54metvopmec, re: clojurebox:i had the same issue with not loading contrib. I put a freshly built clojure 1.1 jar and contrib jar in their respective directories in the Clojurebox dir and it seems to work fine now. *shrugs*.
07:55gurutest (println "test")
07:55Mecmy clojurebox has them in the /lib folder, is that where you put yours?
07:57metvopMec, mine hasC:\Program Files\Clojure Box\clojure and
07:57metvop[07:56] <guru> ,(println "test")
07:57metvop[07:56] <clojurebot> test
07:57guruok
07:57metvopoops
07:57guru,(println "test")
07:57clojurebottest
07:57guruah cool
07:58Mecmetvop: do you know if you're using clojurebox v1.1.0 or a different one?
07:58metvopMec, mine hasC:\Program Files\Clojure Box\clojure and C:\Program Files\Clojure Box\clojure-contrib I see no lib folder anywhere
07:59Mecactually thats not even the one i'm using, that was built yesterday
08:00metvopMec, mine is from october. it had 1.0 clojure default..
08:11MecI'll give this new version a try, and if that doesnt work i'll go to 1.0
08:16Mechow do i properly import something form contrib to see if it'll load
08:27hoeckMec: (use 'clojure.contrib.seq-utils), or (require ...)
08:27Mecsucess!
08:30MecThat leaves one last problem with clojurebox. Any idea why M-. takes me to the middle of a jar file instead of source code?
08:59hoeckMec: probably the source is not located on the classpath, only a jar with AOT compiled namespaces
09:21Mecis there a way to get the numerator/denominator of a ratio
09:26hoeckMec: almost literally: (.numerator 1/3)
09:27hoeckMec:
09:27hoeck,(.denominator 1/4)
09:27clojurebot4
09:27Mechey thats useful
09:28Mecis that kind of thing documented anywhere?
09:50hoeckMec: no, I only found them after looking at the clojure.lang.Ratio source
09:50hoeckMec: but the other numeric functions are documented properly on clojure.org/data_structures
09:51guruis there a macro to print the source of clojure.lang.Ratio?
09:51gurusource doesnt work
09:51Chousuke~def c.l.Ratio
09:52Chousukewill that do? :P
09:52guruhm, actually no :-D
09:52gurui was looking for sth for the repl
09:57chouserguru: java source code is generally not available via classpath from a JVM
09:57guruok, ty
09:57chouseryou can use (show clojure.lang.Repl) to see the public fields and methods of the class.
09:58guru,(show clojure.lang.Repl)
09:58clojurebotjava.lang.Exception: Unable to resolve symbol: show in this context
09:58guruworks in my Repl though
09:58chouserand 'javadoc' to launch a browser looking at the javadocs for the class
09:58guruthat helped, thx
09:58chouserI don't know why I said Repl. :-P Ratio of course...
09:59guruhehe :-)
10:07chouserI suppose there could be something that pulls up github pages for clojure's own sources, like javadoc does for sun's docs.
10:11guru~def c.l.PersistentVector
10:21Mec_if I call count on a lazy-seq will it put the whole seq in memory?
10:21Chousuke,(count (range 10000000))
10:22clojurebot10000000
10:22Chousukeapparently not
10:22chouserMec_: yes
10:22Chousukeit will realise the entire seq though.
10:22Chousukeso if you hold the head, you will have the whole thing in memory
10:22chouserhm.
10:22chouserChousuke's right.
10:23Mec_excellent, thanks
10:25devlinsfchouser: Hello
10:25Mec_so count a filter, or reduce with a counter
10:25chouserso (if (< (count my-lazy-seq) 100) my-lazy-seq ...) will realize the entirety of my-lazy-seq.
10:40chouserdevlinsf: hi
10:40devlinsfchouser: Got a sec for visitors?
10:40chousersure
10:41devlinsfOkay, did you get my note about "same"?
10:44chouserah, yes.
10:44chouserI think I had some reactions. Let me see if I can remember them. :-)
10:45chouseroh, my comment about 'empty' came from that email I think.
10:45devlinsfWhat's the date?
10:45chouserand it's all fixed now in core.clj now, so did you use it?
10:45devlinsfYeah, in a big way
10:46devlinsfchouser: See the one 12/24?
10:49chouseryeah, that's what I've got up.
10:50devlinsfchouser: That's the one I want to push forward. Is this heading the right direction, or am I nuts?
10:51devlinsfchouser: Check out the test script
10:52chouseroh!
10:52devlinsfYeah
10:52chouserI'm sorry, I'm not sure I'd read this one. hang on.
10:53devlinsfIt's cool. Each of those tests pass, btw
10:57chousersorry, I'm a bit distracted at the moment.
10:58chouserOk, I'd read this but haven't looked at your implementation.
11:09chouserthe implementation you're proposing is the one in your core.clj?
11:09devlinsfYeah
11:09devlinsfAt least to start with
11:10devlinsfsame, same-dispatch, hof-args and hof-target are the interesting fns
11:11devlinsfhof-args & hof-target handle the optional index stuff
11:12chouserI don't really like the arg-index stuff, but I don't yet have a better suggestion.
11:12devlinsfIt's the only comprise I could think of
11:13devlinsfespecially w/ the concat example I gave in the email
11:26chouserdevlinsf: do you have use cases that are themselves polymorphic?
11:26devlinsfchouser: Like where I don't know the input?
11:27chouserright
11:27chouserwell, the type of the input.
11:27devlinsfYeah, if I add symbols & keywords
11:27devlinsfjoining a list of maps, database style
11:28devlinsfthe keys might be a keyword or string
11:28devlinsfand there could a collision between the two keyspaces
11:29devlinsfso you call something like (inner-join left-table right-table)
11:29devlinsfand if a collision is detected, you pre-pend left and right
11:29devlinsfi.e. :left.key :right.key
11:29devlinsfThis way the info is preserves, classic SQL
11:30devlinsf(I need to update my table lib to do this)
11:30chouserhmm.
11:30devlinsfbut it might be "left.key" "right.key"
11:30devlinsfAs the lib designer, I don't know if it's strings or keywords
11:31devlinsfbut if I want it to be useful, I have to support both
11:31chouserbut in that case, isn't it likely the user would want to be able to provide their own "combining" function?
11:32devlinsfYeah, probably. But providing a left-prefix & right prefix works for 99% of use cases
11:33Mecis there a way to do like a threaded partial?
11:38chouserMec: perhaps with 'future'?
11:40Mecerr not that kind of thread, i mean like #(somefunc % n) wherewas (partial somefunc n) would be #(somefunc n %)
11:40chouserMec: ah. I suppose you could write such a thing. But normally I just use #() directly.
11:41chouserthat's what it's there for.
11:41Mectrue, its not particularly shorter
11:42chouserdevlinsf: I think this requires more thought. Using a number to refer to an argument by index is awkward, and I wonder if this is an indication that 'same' is trying to do too much in one function.
11:43devlinsfchouser: Yeah, I know. It defaults to last, and that works for 90%
11:43chouserFor example, both the concat examples you provide can be done more easily without using 'same' at all.
11:43vyHow do you guys spot memory leaks (probably caused by lazy evaluation forced caching, etc.) in your Clojure programs? Which tools do you use?
11:44devlinsftrue
11:44devlinsfIt's for str that I'd want to use the indexing
11:45devlinsfMaybe #() will work better
11:46Licenserwhat about something like (partial function :value 42 :value :value "bla") where it works like #(function %1 42 %2 %3 "bla") - of cause :value isn't very well choosen
11:46chouserdevlinsf: I do think you're on to something with a multimethod that defaults to something like (into (empty c) (f args c))
11:46devlinsfSo bring it up on the dev list?
11:47chouservy: jvisualvm makes it easy to spot what kinds of objects are consuming the most memory.
11:48chouserLicenser: that ties you pretty tightly to 'function's argument order.
11:48chouserdevlinsf: you don't need my permission for that! :-)
11:48devlinsfI know, but I'm gonna need support
11:48devlinsfAnyway
11:48Licenserchouser: of cause, but isn't that a good thing too, I mean for later understanding of the code? 
11:49chouserdevlinsf: when clojure starts using protocols for native abstractions, it's reasonable to think (into "" ...) will be able to do the right thing.
11:50Licenserat least I could read that better then something like (partial function {2 42, 5 "bla"})
11:50chouserat which point it may not even need to be a multimethod. Though I guess a multimethod still wouldn't hurt much.
11:51devlinsfchouser: There will always be corner cases
11:51devlinsfOkay, time to write something up
11:51chouserbut with protocols, you could extend your own types to work with 'into' and 'empty'
11:51devlinsfHmmm... true
11:52chouserbut again, a multimethod still wouldn't hurt much. Especially when such use of protocols is still theoretical. :-)
11:52devlinsfThe only two real use casas for the multimethod are String & Lazyseq
11:52Licenserhmm is there any good explenation of how rotocils will work and what they will do exactly?
11:53devlinsfEh, and you know what? The multimethod works now. It can always be upgraded later
11:53chouserright
11:54chouserI'm a little nervous about the auto-sensing lazy-seq though too. It might be a great idea, but it's not done elsewhere in Clojure yet I think.
11:55devlinsfIs it needed elsewhere?
11:55chouserright now, any given function either returns a lazy seq or it doesn't.
11:55gcvquick question about writing custom error handlers: c.c.error-kit vs c.c.condition. I'm leaning towards c.c.error-kit because it doesn't require AOT compilation, but was wondering about prevailing opinion here.
11:56devlinsfchouser: If I get a lazy-seq, I can't recreate the original type
11:56chouserto choose between them implicitly might either be really nice or a source of confusion.
11:56devlinsfEh, let's see what happens
11:58chousergcv: only contrib needs to be AOT compiled, not your own code.
11:59gcvchouser: thanks, I didn't realize that
12:01chouserThat's for c.c.condition of course.
12:03gcvI assume you use error-kit since you wrote it? :)
12:03chouserheh. you'd think.
12:05chousererror-kit tries to do too much. If you don't need the continue or continue-with features, I'd avoid error-kit
12:09gcvchouser: thanks for the advice
13:46cmbntrhi, is there a shortcut to (first (remove nil? s))
13:53devlinsf(some identity s)
13:57Licenserthe full disclojure videos are briliant
13:57Licenservery very nice!
13:58cmbntrdevlinsf: thanks
14:00devlinsfLicenser: Thank for
14:00devlinsferr, you
14:00Licenserdevlinsf: you're welcome
14:00Licenserso may I add an idea/wish
14:00devlinsfYeah, shoot
14:01LicenserSo I love them but I took the time to work myself into clojure and claim to be at least a somewhat versed coder. What would be really cool too, would be something like full disclojure for compleat newcommers - hence I know only about 1 person who would even have heared something like s-expression before .
14:02devlinsfThat's exactly where I want to go
14:02LicenserAh very nice :D
14:02devlinsfThe goal is an "intermediate developer"
14:03devlinsfYou need to be able to do (+ 2 2), (map #(* 2 %) [1 2 3])
14:03devlinsfetc
14:03devlinsf(That material is better covered elsewhere)
14:03LicenserI don't mean it as critique of the existing videos, they are great, just that I would love ot have something that nice to show people who wish to start with clojure without reading an entire book on it :P
14:03devlinsfStay tuned the next few weeks then
14:04LicenserI will ;)
14:04Anniepoo anybody had any luck getting enclojure's repl to work with the head RC?
14:04Licenserhmm also something like a emacs-clojure quick howto video would be cool :P
14:04Licenserevery source that I found about that expects you to be proficient with EMACS
14:06devlinsfLicenser: If I was qualified to write about emacs, I would
14:06devlinsfDid you check out LauJensen's stuff?
14:06LicenserThat is the exact problem, people who are qualified make it too complicated :P
14:07Licensernot that I'd know of, is it about EMACS and Clojure?
14:07devlinsfIt's mostly Clojure, with some emacs
14:08devlinsfHe also shows different stuff, worth checking out
14:08Licenserlet's ask Mr. G about it ^^
14:09Licenserhah okay I managed to subscribe to your cahnnel :P
14:11Licenserah very nice thank you devlinsf!
14:29Licensergnaw
14:30Licenserthings seem so easy when they work :P
14:31gurui want to create a state 'object' that can have itself as next state
14:31gurulike:
14:32guru{ :date "bla" next-states [ self ] }
14:33guruis this were promises shine?
14:34stuartsierrasounds like a lazy sequence to me
14:35guruatom is rather funny, didnt try refs
14:36guru,(let [a (atom 0)] (swap! a (fn [_] a)))
14:36clojurebot#<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Ato
14:37gurui dunno how a lazy seq comes into play here
14:37guruill think about it
14:38chouserguru: each item of a lazy seq can be thought of as a "state", where the sequence as a whole represents the succession of states.
14:38chouser,(iterate inc 1) ; here the state starts as 1, next state computed by applying 'inc' to the old state.
14:38clojurebotEval-in-box threw an exception:java.lang.OutOfMemoryError: Java heap space
14:39chouser,(take 10 (iterate inc 1))
14:39clojurebot(1 2 3 4 5 6 7 8 9 10)
14:39guruyes
14:39gurumy problem might still be different
14:39gurulet me think a sec
14:41chouserthe benefit of a lazy-seq over atoms or refs transitioning through a series of values is a lazy seq like this can stay purely functional, while updating reference objects is mutating shared state.
14:41guruyep
14:43guruok, a tiny example: i have a map of states, a state is a list of possible follow-up states:
14:43guru{:loop-state [:loop-state :some-other-state] :some-other-state []}
14:44gurui want to transfrom that map into sth like:
14:46guruok, bad example, again: {:loop-state [:loop-state :some-other-state] :some-other-state [:1 :2]}
14:47gurushould become {:loop-state [[[...]] [next-states of :1, next-states of :2]}
14:48guruok, basically i want to create a seq which contains itself
14:48chouserhm. why? the first way seems good -- what the reason for the transform?
14:49gurui would have to do a map lookup, each time a make a transition
14:49guruplus i have to pass that map to my functions
14:50chouserhm.
14:50guruwhere reason 2 is worse for me
14:50gurupromise seems to do the job really well here
14:51chouserpromise is usually for flow-control -- deref blocks.
14:52chouserI guess it could work, as could atom.
14:53rrc7czwhy does "(map #(array-map % (char %)) (range 1 10))" work, but "(map #({% (char %)}) (range 1 10))" fails with IllegalArgumentException: Wrong number of args passed to: PersistentArrayMap?
14:54chouseryou want current-state and the list of next-states to be a single object?
14:55chouserrrc7cz: #(foo) is (fn [] (foo)) ... #() eliminates the need for one set of parens, but therefore always expands to a form that starts with "(" (not "{" or "[")
14:55Licensernice
14:57rrc7czchouser: okay that makes sense
15:00guruwhats the reasoning behind assert not returning a value in case it evals to logical true?
15:00chouserasserts can disappear if compiled with *assert* false
15:01guruyes, but the code inside doesnt have to
15:01guru(defmacro assert-ret
15:01guru "Evaluates expr and returns it if it evaluates to logical true,
15:01guru throws an exception otherwise."
15:01guru [x]
15:01guru (if *assert*
15:01guru `(if ~x
15:01guru ~x
15:01guru (throw (new Exception (str "Assert failed: " (pr-str '~x)))))
15:01guru x))
15:01guruis the version i use
15:06gurumaybe sth like that already exists, being able to provide an optional message would be even nicer and still shorter than if...throw (.Exception...
15:08chouserI think people generally want the code inside the assert to disappear as well. It's often doing work just for the assert.
15:09chouserthough the need for manual use of assert has gone way down with :pre and :post
15:10guruok, i guess its the whole point of assert, to make some maybe expensive calculations, and in case *assert* is false, this code should just disappear
15:10chouserI think that's the common usage, yes.
15:11chouserI can see that there might be times that you'd like to sprinkle asserts inside nested, working code, but I guess that's been somewhat less common.
15:11guruok, thx
15:35lazy1is *command-line-args* still the best way to check if we're imported or being run as main script?
15:38chouserhm -- you can't tell whether you're being run as a script or being 'require'd by something that's being rung as a script
15:39lazy1OK, thanks
16:25tolstoyI keep getting: java.lang.IllegalArgumentException: No matching method found: println for class swank.util.io.proxy$java.io.StringWriter$0
16:25tolstoyThe clojars version of swank hasn't been updated in a while.
16:25tolstoyIs there something I can do with that stuff?
16:26the-kennytolstoy: When you require something?
16:26the-kennys/something/something from your project)
16:27tolstoythe-kenny: Mainly when I get errors using derby. Or some sort of errors.
16:28the-kennytolstoy: I have a very strange error involving this class too
16:28the-kenny(swank.util.io.proxy$java.io.StringWriter$0)
16:28the-kennyLooks like something there is really broken
16:29rrc7czcan anyone imagine why (take 5 (p29))
16:29rrc7cz(4.0 4.0 8.0 9.0 16.0)
16:29the-kennyrrc7cz: What's "p29"?
16:30rrc7czoops, sorry - output got scred up. why (take 5 (p29)) -> (4.0 4.0 8.0 9.0 16.0) but (take 5 (set (p29))) -> (8.589934592E9 3.6893488147419103E19 1.5845632502852868E29 6.805647338418769E38 5.391989333430128E67)
16:31rrc7czp29 is the start of some Euler solution: (defn p29 [] (flatten (let [vals (range 2 101)] (for [a vals b vals] [(Math/pow a b) (Math/pow b a)]))))
16:31hiredmansets are not sorted, so the order going into a set is not the same as coming out
16:31rrc7czI can switch to sorted-set, but it's not the order I care about; the values are changed
16:32hiredmanhow do you know?
16:32rrc7czhiredman: (4.0 4.0 8.0 9.0 16.0) vs. (8.589934592E9 3.6893488147419103E19 1.5845632502852868E29 6.805647338418769E38 5.391989333430128E67)
16:33rrc7czoh
16:33rrc7czwait
16:33rrc7czI'm stupid
16:33rrc7czwell
16:33rrc7czhiredman: i get it now what you mean about sorted
16:33rrc7czhiredman: since I'm taking only 5, it could be a different 5 each time
16:34rrc7czbut all values _should_ be whole numbers since I'm only doing powers of ints
16:34Chousukepow returns floats though, doesn't it?
16:34Chousukethey are imprecise.
16:34rrc7czChousuke: it does, but I'd expect all X.0, Y.0. Z.0, etc
16:34rrc7czaha, you're right
16:35rrc7czI should use BigInt instead
16:35defnhttp://www.devinwalters.com/admin/posts/24 -- Can anyone think of anything to add to this? I'm sure there's a lot more to talk about, just curious if anyone has any opinions...
16:35the-kennydefn: Username/Password? ;)
16:36defnoh wrong URL :)
16:36defnhttp://www.devinwalters.com/posts/24
16:40defnhttp://www.paulgraham.com/rootsoflisp.html
16:42tolstoythe-kenny: That "No matching method found: println for class swank.util.io.proxy$java.io.StringWriter$0" error is, I think, a clojure-mode/slime prob, not in swank. Don't get it when running from a straight-ahead repl.
16:42the-kennytolstoy: No, I don't get the same error, but a similar. Some casting-error
16:43defnoh no the-kenny not this problem again
16:43defnthis is still persisting?
16:43the-kennydefn: Not again
16:43defnso you fixed it?
16:43the-kennyNo
16:43the-kennyIst persists, it never disappeared
16:43the-kenny;)
16:44defnugh!
16:44the-kennyI'm requiring my code in the *inferior lisp* buffer now.. ugly workaround
16:44defnyou're on OSX you said?
16:44the-kennyYes
16:44defn10.6?
16:44defnnot that it matters really, just curious
16:44the-kennyYes, 10.6
16:45the-kennyIt must be something wrong with one of the dependencies here.. I wonder why no one here has the same problem
16:46the-kennyI wonder if it's the same if I use a self-built swank-clojure...
16:46defndude i have tried to replicate it
16:47defni blew away my elpa and tried again, but it works perfectly
16:47technomancywdouglas: do you have a copy of slime-fuzzy.el that's been modified to work as an elpa package?
16:48defntechnomancy: did that go up on elpa?
16:49technomancydefn: not yet
16:49defnwill adding the slime-fuzzy.el to my elpa/slime/ dir make it so i can't update the slime package
16:49ordnungswidrighny!
16:50technomancydefn: it shouldn't, but slime-fuzzy.el still needs a few tweaks before it's really made into a proper package
16:50the-kennytechnomancy: Any idea why this happens? http://gist.github.com/267270 A stacktrace goes down onto call-on-flush-stream.
16:51technomancythe-kenny: no, never seen that; sorry
16:51the-kenny:(
16:52the-kennyI'm the only person where this is happening as far as I know.. I already tried a complete fresh slime, elpa and swank setup
16:52technomancywhat JVM?
16:52tolstoythe-kenny: I think I've seen something similar along the way.
16:54the-kennytechnomancy: java version "1.6.0_17" 32 or 64bit, doesn't matter
16:54the-kennytolstoy: Really?
16:54tolstoyI think I also get my version of that issue when derby prints straight to stderr or stdout or something.
16:55tolstoyAh, I don't know. Best thing would be to create a tiny test case that causes it.
16:56the-kennytolstoy: It's wasy: Create a project with leiningen, pull the deps from elpa, start a repl with swank-clojure-project and (require yourns.yourpackage)
16:56the-kennyThis happens in every project I have here
16:57the-kennyHere is one with a stacktrace: http://gist.github.com/267278
17:01technomancythe-kenny: sun's JVM, openjdk, or some other one?
17:02the-kennytechnomancy: Should be sun. The default one on osx
17:02the-kennyI never had any problems.. this just started some days ago
17:02congreve/?
17:02technomancydoesn't Apple ship their own modifications?
17:03the-kennytechnomancy: Yes, but it worked without any problem for a long time.
17:03the-kennyI don't remember any java-update or something similiar which could have broken it
17:04technomancydunno; sorry. I can't do much without a repro-case.
17:04defnthe-kenny: maybe try getting java from macports
17:04the-kennyhm.. ok, thanks anyway
17:05tolstoythe-kenny: I just run swank stand-alone (with all my jars on the cp), then use slime-connect to reach it. A lot fewer problems that way.
17:05defnsudo port install openjdk6
17:07the-kennyI'm almost sure I've tried that
17:08the-kennytolstoy: yes.. that works
17:09the-kennyThat all doesn't make sense for me
17:10technomancythe average function length in swank_fuzzy.clj makes my stomach churn
17:10technomancywhat a mess
17:12technomancyat least there are a few tests
17:15technomancycourse a test that just tells me "hey, there is a null pointer exception somewhere in this 100+LOC function" is not a lot of help
17:18hiredmanclojurebot: problem?
17:18clojurebotPeople have a problem and think "Hey! I'll use a regular expression!". Now they have two problems....
17:19hiredmanclojurebot: problem?
17:19clojurebotPeople have a problem and think "Hey! I'll use a regular expression!". Now they have two problems....
17:19hiredmanbah
17:21arohnerhrm, jswat is not highlighting lines for
17:21arohnerfor me
17:22arohnerhas anyone else had that problem with jswat 4.5? it doesn't highlight the lines with breakpoints, nor show the current line
17:22the-kennytechnomancy: Should I use [org.clojure/swank-clojure "1.0"] or [swank-clojure "1.1.0-SNAPSHOT"]?
17:27arohnerah, jswat behaves normally when viewing .java files, but not .clj
17:28arohneris there some configuration I have to do?
17:32the-kennyI just don't get this...
17:32the-kennyIt also breaks if I evaluate a (ns)-declaration
17:33the-kennywhere I import something from my project
17:33the-kennyIt works if I just import things from other projects
17:40the-kennyCan someone please zip me a simple project with some files where he uses swank-clojure-project with leiningen successfully?
17:42the-kenny(with all dependencies please)
17:46the-kennyWeeee
17:46the-kennyLooks like it's a configuration issue
17:48the-kennyThat can't be..
17:49the-kennydefn: Interested in the source of the problem?
17:51the-kennytechnomancy: I found the problem - Really strange.. should I write some instructions to reproduce it?
17:52the-kennyIt's really simple.. but I don't get why it throws such a strange exception
18:06the-kennyHow to break swank-clojure: http://gist.github.com/267299 :)
18:06the-kennyI had these three lines in an init-file to customize my repl.. these three lines were the source of all problems
18:13ordnungswidrigthe-kenny: interesting.
18:13ordnungswidrighowever, I'll take a nap now.
19:53lazy1Is there a way for me to check if an object supports an interface?
19:53lazy1(Java object)
19:54cark,(doc isa?)
19:54clojurebot"([child parent] [h child parent]); Returns true if (= child parent), or child is directly or indirectly derived from parent, either via a Java type inheritance relationship or a relationship established via derive. h must be a hierarchy obtained from make-hierarchy, if not supplied defaults to the global hierarchy"
19:54kotarak,(doc instanceß)
19:54clojurebotexcusez-moi
19:54kotarak,(doc instance?)
19:54clojurebot"([c x]); Evaluates x and tests if it is an instance of the class c. Returns true or false"
19:54kotarak,(instance? CharSequence "foo")
19:54clojurebottrue
19:54kotarakIs that an interface?
19:55lazy1thanks
19:56kotarak,(isa? (type "foo") CharSequence)
19:56clojurebottrue
20:53chouseranyone here know enlive?
21:07replacachouser: yeah, some
21:08chouserI'm trying to add an attribute to all tags of a given name
21:08chouserthe value of the attribute will depend on the content of the tag element.
21:09replacaby name do you mean the tag name (like <a>) or an id or class?
21:12chouserright, tag name
21:12chouserit looks like I want sniptest, but it appears to be gone?
21:12chouserso I'm starting with 'at' for now, though that looks like it'll return maps of some kind that need to be converted back to strings
21:13chouser(at (first (xml-resource ..a..)) [:para] ..b..)
21:13chouserI think I've got ..a.. right, but I'm still trying to figure out what to put for ..b.
21:17replacayou should be able to do something like (fn [n] (apply (set-attr :attr-name (transform (:content n))) n))
21:18replacaI'm not sure I got the indirection right just there - the idea is that you're trying to get a function that will act on each of the selected nodes)
21:19replaca"transform" would be your func that looks at the content and derives the value for the attribute
21:19chouserok thanks
21:20replacaset-attr itself returns a func which is what makes some of these things tricky
21:23chouserany idea how to get from what 'at' returns back to a string?
21:23chouseror something better to use instead of 'at'?
21:23replacawell, if you know the file at compile time, you can use deftemplate
21:24replacathat's alot faster if you're doing it a bunch
21:24chouserThere's no file. The xml is built at runtime into a string.
21:24replacathen at is probably what you want
21:25replacahang on, I think I found a ref for you.
21:25replaca(while I'm chasing that out...)
21:27replacause (apply str (at ...)) to get a whole regular string
21:28replacaat least that works on deftemplate and I think it works on at too
21:28chouserno, at returns a seq of hashes
21:28chouserhash-maps, that is.
21:28chouseroh, they're string clojure.xml things
21:28chouserI should be able to use emit
21:29replacayup, that should be right
21:29chouseremit is not public
21:30replacause emit*
21:31replacait's public and it's what's used in the def of deftemplate
21:31chouserok, looks good.
21:33replacafor the (apply (at ...)) thing look at http://github.com/tomfaulhaber/autodoc/blob/master/src/autodoc/build_html.clj#L74
21:34chouserohhhh... I see.
21:34replacaI'm adding a prefix (like ../../) to hrefs there to make up for putting pages in subdirectories
21:36replaca(That's actually my own version of deftemplate that memoizes instead of working at compile time)
21:36replacabut the syntax is otherwise the same
21:37chouserok! I've got it sketched out now.
21:37replacacool. glad to hear it
21:37chouserThanks, I'm sure you just saved me at least a couple of frustrating hours. :-)
21:38replacagotta run now, but I should be back later if you have more q's
21:38chousergreat, thanks.
21:38replaca(well I already spent those frustrating hours so you don't have to :-))
21:38chouser:-)
23:33chouserany way to "or" a bunch of tags in an enlive selector?
23:33chouserI have [:para] and I want something like [(or :para :sect1 :sect2)]
23:42replacachouser: the readme shows using a set as working -> #{selector1, selector2}
23:42replacawhere each selector is itself a vector, as usual
23:44replacaI don't use that technique myself anywhere, though
23:47chouserah, thanks.