2010-01-01
| 00:01 | chouser | Happy new year! |
| 00:02 | piccolino | Happy new year, Mr. East Coaster! |
| 00:02 | chouser | :-) |
| 00:02 | dandersen | Happy New Year =] |
| 00:42 | replaca | Happy new year, #clojure. Looking forward to 2010! |
| 01:54 | optimizer | what's a good resource for java gui's with clojure? |
| 01:54 | pdk | the java_interop page on the clojure site illustrates using swing with clojure |
| 01:55 | optimizer | url? |
| 01:55 | pdk | remember 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:55 | optimizer | yeah; but I don't know java; lol |
| 01:55 | pdk | http://clojure.org/jvm_hosted |
| 01:55 | pdk | a little example of how swing code in clojure looks basically the same as in java |
| 01:56 | optimizer | i heard bad things about awt/swing |
| 01:56 | optimizer | what gui library should I ue? |
| 01:56 | optimizer | *use* |
| 01:56 | pdk | java comes with awt and swing out of the box for gui programming, you should be able to find plenty of tutorials |
| 01:56 | optimizer | my background is c/c++/scheme /opengl |
| 01:56 | pdk | we'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:57 | pdk | what sort of things in a widget toolkit are important for the program youre writing, things like native look and feel, speed, portability etc |
| 01:57 | optimizer | is there a central refernce that lists the options & tradeoffs? |
| 01:57 | optimizer | i want to write a text editor that supports wysiwyg math rendering |
| 01:57 | optimizer | kinda like texmacs / lyx |
| 01:57 | optimizer | but in clojure |
| 01:57 | piccolino | Well, I'm pretty sure you can knock AWT right off the list. |
| 01:58 | optimizer | piccolino: why? |
| 01:58 | pdk | as far as i know the most well-known alternative to awt/swing is SWT |
| 01:58 | piccolino | It's not really adequate for anything. |
| 01:58 | optimizer | pdk: the one by eclipse/ibm? |
| 01:58 | pdk | eclipse for example is entirely swt based |
| 01:58 | pdk | yeah |
| 01:58 | pdk | and i assume there'd be a wxwidgets binding |
| 01:58 | optimizer | eclipse looks pretty nice |
| 01:58 | piccolino | Have they packaged SWT up so it's easy to use on it's own yet? |
| 01:59 | pdk | there's a slashdot post discussing swing vs swt in the comments |
| 01:59 | pdk | http://developers.slashdot.org/article.pl?sid=06/02/25/2110220&from=rss |
| 01:59 | optimizer | you know what? if it's good enough for eclipse; it's good enough for me |
| 01:59 | optimizer | but I will read the link; thanks |
| 01:59 | pdk | here's a java binding to wxwidgets http://jwx.sourceforge.net/ |
| 02:00 | optimizer | pdk: you realize this is irc and not a $$$/hr consulting job right? :-D |
| 02:00 | pdk | if you want native look and feel on every platform you're delivering the program for then yes you'll want swt or wxwidgets |
| 02:00 | pdk | well you want to make picking up clojure not painful :p |
| 02:01 | pdk | swing has its own look and feel so it's the same on every platform but doesn't really mesh with any of them |
| 02:01 | optimizer | favorite comment: |
| 02:01 | optimizer | Buoy [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:01 | pdk | except for probably solaris or something |
| 02:01 | optimizer | man; reading this makes me want to juse use jogl :-) |
| 02:02 | pdk | provided you're up for writing your own widgets :p |
| 02:02 | piccolino | I suspect you'll wind up on wxwidgets. |
| 02:02 | pdk | actually iirc there should be little windowing libraries for lwjgl |
| 02:02 | pdk | just as there were for pygame |
| 02:03 | pdk | in terms of running fast swt and wxwidgets will probably trump swing |
| 02:03 | pdk | though swt might not have the kitchen sink or be as concise in code |
| 02:10 | optimizer | http://www.dragmath.bham.ac.uk/index.html#Download |
| 02:10 | optimizer | hmm; looks like someone already invnted it |
| 02:11 | pdk | it can be a language learning exercise at least |
| 02:15 | optimizer | is enclojure written in clojure? |
| 02:15 | pdk | that's its claim to fame |
| 02:16 | pdk | oh wait |
| 02:16 | pdk | i thought you meant compojure there, i'd assume enclojure would be a mix of java/clojure as it's a netbeans module |
| 02:16 | optimizer | wait; 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:16 | pdk | compojure is a clojure based web server |
| 02:16 | pdk | the older one would most likely be a poorly labeled release candidate |
| 02:17 | hiredman | framework |
| 02:17 | pdk | well web server framework |
| 02:17 | optimizer | http://code.google.com/p/clojure/downloads/list |
| 02:17 | optimizer | where do I get the latest? |
| 02:17 | optimizer | oh |
| 02:17 | hiredman | pdk: nope |
| 02:17 | optimizer | i see the 17 hours ago one |
| 02:17 | optimizer | okay |
| 02:17 | pdk | but yes you'll want the most recently dated 1.1.0 |
| 02:17 | pdk | that one looks like 1.0.0 to me :p |
| 02:18 | optimizer | yeah; perhaps i need new glasse |
| 02:18 | optimizer | hmm, i just built clojure with ant |
| 02:18 | optimizer | is there no 'ant install' ? |
| 02:19 | pdk | http://en.wikibooks.org/wiki/Clojure_Programming/Getting_Started this part talks about installing clojure through ant |
| 02:19 | pdk | and git |
| 02:20 | optimizer | The 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:20 | optimizer | that sounds like such a hack |
| 02:20 | pdk | one thing you learn from it all is |
| 02:20 | pdk | lispers love emacs :p |
| 02:21 | optimizer | too bad emacs love elisp |
| 02:24 | defn | elisp is a lisp |
| 02:24 | defn | what's not to like? |
| 02:25 | defn | elisp is the ruby to my clojure |
| 02:32 | optimizer | does clojure run on java 7? (i use xmonad; and apparently xmonad dislikes java gui's on java 6) |
| 02:34 | pdk | it runs on at least 6 |
| 02:34 | pdk | if i recall possibly 5 to |
| 02:34 | pdk | too |
| 02:34 | pdk | though i wasn't aware of a 7 haha |
| 02:40 | hiredman | defn: lack of lexical scoping |
| 05:59 | LauJensen | Morning team |
| 06:24 | Mec | How 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:30 | cark | ,(doc reductions) |
| 06:30 | clojurebot | "([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:31 | Mec | is that in contrib? |
| 06:32 | hoeck | Mec: in clojure.contrib.seq-utils |
| 06:33 | Mec | thanks |
| 06:48 | LauJensen | clojurebot: source reductions |
| 06:48 | LauJensen | Beautiful |
| 06:56 | Mec | wow i have no idea what thats doing |
| 06:57 | Mec | it seems like you should be able to use reduce to do that |
| 07:05 | cark | ,(reductions + [1 2 3 4 5]) |
| 07:05 | clojurebot | (1 3 6 10 15) |
| 07:06 | cark | sorry i had to go afk and couldn't follow up |
| 07:23 | Mec | ,(reduce #(conj %1 (+ (last %1) %2)) [1] [2 3 4 5]) |
| 07:23 | clojurebot | [1 3 6 10 15] |
| 07:23 | Mec | but that would be really inefficient i think |
| 07:38 | Mec | is for expanded upon anywhere besides the api docs? |
| 07:39 | cark | why wouldn't you use reductions ? |
| 07:40 | cark | you can check the source |
| 07:40 | cark | clojurebot: source for |
| 07:40 | cark | or use macroexpand |
| 07:41 | Mec | I can't get clojurebox to load contrib |
| 07:42 | cark | you need to make sure that clojure-contrib is in your classpath |
| 07:42 | Mec | and for some reason that link wont load past line 1908 |
| 07:42 | cark | i'm not using clojurebox so i can't help on that |
| 07:43 | cark | hum the link is working for me ! |
| 07:43 | cark | for is a very complex macro anyways |
| 07:43 | Mec | humm |
| 07:44 | Mec | i remember reading something before saying like you cant use :while and :when in the same one, but i cant find that now |
| 07:46 | cark | ,(for [i [1 2 3 4 5 6 7 8] :when (odd? i) :while (< i 4) ] i) |
| 07:46 | clojurebot | (1 3) |
| 07:46 | cark | i don't know, looks like it's working =P |
| 07:46 | Mec | hmm im also useing :let ;p |
| 07:47 | cark | i think when you have an hardcore for, it might be bad smell |
| 07:47 | Mec | ,(for [i [1 2 3 4 5 6 7] :let [j (inc i)] :when (odd? j) :while (< j 5)] [i j]) |
| 07:47 | clojurebot | ([2 3]) |
| 07:49 | Mec | weird, that works for me too, gotta be something else |
| 07:49 | Mec | does the order of when and while matter? |
| 07:50 | Chousuke | probably :P |
| 07:50 | cark | well it wouldn't be very nice if it did |
| 07:51 | Mec | bah infix error strikes again |
| 07:51 | Mec | i had a :when (total = 200) |
| 07:51 | Chousuke | ,(for [i (range 10) :when (even? i) :while (odd? i)] i) |
| 07:51 | clojurebot | () |
| 07:52 | Chousuke | ,(for [i (range 10) :while (odd? i) :when (even? i)] i) |
| 07:52 | clojurebot | () |
| 07:52 | guru | does anybody know sth like assert, which returns expr, if its not nil and throws an exception otherwise? |
| 07:53 | Chousuke | (or expr (throw ...))? :) |
| 07:53 | guru | (assert-ret '(1 2)) -> (1 2) |
| 07:53 | Mec | (and exp (throw) |
| 07:53 | Mec | bah |
| 07:53 | Mec | too slow |
| 07:53 | guru | yo |
| 07:53 | guru | i prefer or |
| 07:53 | Mec | err ya or |
| 07:53 | Chousuke | it also fails if expr is false though |
| 07:53 | guru | the assert exception would be the same as (throw .Exception)? |
| 07:54 | Chousuke | assert throws AssertionError actually |
| 07:54 | guru | ,(println "test") |
| 07:54 | clojurebot | test |
| 07:54 | guru | (println "test") |
| 07:54 | metvop | mec, 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:55 | guru | test (println "test") |
| 07:55 | Mec | my clojurebox has them in the /lib folder, is that where you put yours? |
| 07:57 | metvop | Mec, mine hasC:\Program Files\Clojure Box\clojure and |
| 07:57 | metvop | [07:56] <guru> ,(println "test") |
| 07:57 | metvop | [07:56] <clojurebot> test |
| 07:57 | guru | ok |
| 07:57 | metvop | oops |
| 07:57 | guru | ,(println "test") |
| 07:57 | clojurebot | test |
| 07:57 | guru | ah cool |
| 07:58 | Mec | metvop: do you know if you're using clojurebox v1.1.0 or a different one? |
| 07:58 | metvop | Mec, mine hasC:\Program Files\Clojure Box\clojure and C:\Program Files\Clojure Box\clojure-contrib I see no lib folder anywhere |
| 07:59 | Mec | actually thats not even the one i'm using, that was built yesterday |
| 08:00 | metvop | Mec, mine is from october. it had 1.0 clojure default.. |
| 08:11 | Mec | I'll give this new version a try, and if that doesnt work i'll go to 1.0 |
| 08:16 | Mec | how do i properly import something form contrib to see if it'll load |
| 08:27 | hoeck | Mec: (use 'clojure.contrib.seq-utils), or (require ...) |
| 08:27 | Mec | sucess! |
| 08:30 | Mec | That leaves one last problem with clojurebox. Any idea why M-. takes me to the middle of a jar file instead of source code? |
| 08:59 | hoeck | Mec: probably the source is not located on the classpath, only a jar with AOT compiled namespaces |
| 09:21 | Mec | is there a way to get the numerator/denominator of a ratio |
| 09:26 | hoeck | Mec: almost literally: (.numerator 1/3) |
| 09:27 | hoeck | Mec: |
| 09:27 | hoeck | ,(.denominator 1/4) |
| 09:27 | clojurebot | 4 |
| 09:27 | Mec | hey thats useful |
| 09:28 | Mec | is that kind of thing documented anywhere? |
| 09:50 | hoeck | Mec: no, I only found them after looking at the clojure.lang.Ratio source |
| 09:50 | hoeck | Mec: but the other numeric functions are documented properly on clojure.org/data_structures |
| 09:51 | guru | is there a macro to print the source of clojure.lang.Ratio? |
| 09:51 | guru | source doesnt work |
| 09:51 | Chousuke | ~def c.l.Ratio |
| 09:52 | Chousuke | will that do? :P |
| 09:52 | guru | hm, actually no :-D |
| 09:52 | guru | i was looking for sth for the repl |
| 09:57 | chouser | guru: java source code is generally not available via classpath from a JVM |
| 09:57 | guru | ok, ty |
| 09:57 | chouser | you can use (show clojure.lang.Repl) to see the public fields and methods of the class. |
| 09:58 | guru | ,(show clojure.lang.Repl) |
| 09:58 | clojurebot | java.lang.Exception: Unable to resolve symbol: show in this context |
| 09:58 | guru | works in my Repl though |
| 09:58 | chouser | and 'javadoc' to launch a browser looking at the javadocs for the class |
| 09:58 | guru | that helped, thx |
| 09:58 | chouser | I don't know why I said Repl. :-P Ratio of course... |
| 09:59 | guru | hehe :-) |
| 10:07 | chouser | I suppose there could be something that pulls up github pages for clojure's own sources, like javadoc does for sun's docs. |
| 10:11 | guru | ~def c.l.PersistentVector |
| 10:21 | Mec_ | if I call count on a lazy-seq will it put the whole seq in memory? |
| 10:21 | Chousuke | ,(count (range 10000000)) |
| 10:22 | clojurebot | 10000000 |
| 10:22 | Chousuke | apparently not |
| 10:22 | chouser | Mec_: yes |
| 10:22 | Chousuke | it will realise the entire seq though. |
| 10:22 | Chousuke | so if you hold the head, you will have the whole thing in memory |
| 10:22 | chouser | hm. |
| 10:22 | chouser | Chousuke's right. |
| 10:23 | Mec_ | excellent, thanks |
| 10:25 | devlinsf | chouser: Hello |
| 10:25 | Mec_ | so count a filter, or reduce with a counter |
| 10:25 | chouser | so (if (< (count my-lazy-seq) 100) my-lazy-seq ...) will realize the entirety of my-lazy-seq. |
| 10:40 | chouser | devlinsf: hi |
| 10:40 | devlinsf | chouser: Got a sec for visitors? |
| 10:40 | chouser | sure |
| 10:41 | devlinsf | Okay, did you get my note about "same"? |
| 10:44 | chouser | ah, yes. |
| 10:44 | chouser | I think I had some reactions. Let me see if I can remember them. :-) |
| 10:45 | chouser | oh, my comment about 'empty' came from that email I think. |
| 10:45 | devlinsf | What's the date? |
| 10:45 | chouser | and it's all fixed now in core.clj now, so did you use it? |
| 10:45 | devlinsf | Yeah, in a big way |
| 10:46 | devlinsf | chouser: See the one 12/24? |
| 10:49 | chouser | yeah, that's what I've got up. |
| 10:50 | devlinsf | chouser: That's the one I want to push forward. Is this heading the right direction, or am I nuts? |
| 10:51 | devlinsf | chouser: Check out the test script |
| 10:52 | chouser | oh! |
| 10:52 | devlinsf | Yeah |
| 10:52 | chouser | I'm sorry, I'm not sure I'd read this one. hang on. |
| 10:53 | devlinsf | It's cool. Each of those tests pass, btw |
| 10:57 | chouser | sorry, I'm a bit distracted at the moment. |
| 10:58 | chouser | Ok, I'd read this but haven't looked at your implementation. |
| 11:09 | chouser | the implementation you're proposing is the one in your core.clj? |
| 11:09 | devlinsf | Yeah |
| 11:09 | devlinsf | At least to start with |
| 11:10 | devlinsf | same, same-dispatch, hof-args and hof-target are the interesting fns |
| 11:11 | devlinsf | hof-args & hof-target handle the optional index stuff |
| 11:12 | chouser | I don't really like the arg-index stuff, but I don't yet have a better suggestion. |
| 11:12 | devlinsf | It's the only comprise I could think of |
| 11:13 | devlinsf | especially w/ the concat example I gave in the email |
| 11:26 | chouser | devlinsf: do you have use cases that are themselves polymorphic? |
| 11:26 | devlinsf | chouser: Like where I don't know the input? |
| 11:27 | chouser | right |
| 11:27 | chouser | well, the type of the input. |
| 11:27 | devlinsf | Yeah, if I add symbols & keywords |
| 11:27 | devlinsf | joining a list of maps, database style |
| 11:28 | devlinsf | the keys might be a keyword or string |
| 11:28 | devlinsf | and there could a collision between the two keyspaces |
| 11:29 | devlinsf | so you call something like (inner-join left-table right-table) |
| 11:29 | devlinsf | and if a collision is detected, you pre-pend left and right |
| 11:29 | devlinsf | i.e. :left.key :right.key |
| 11:29 | devlinsf | This way the info is preserves, classic SQL |
| 11:30 | devlinsf | (I need to update my table lib to do this) |
| 11:30 | chouser | hmm. |
| 11:30 | devlinsf | but it might be "left.key" "right.key" |
| 11:30 | devlinsf | As the lib designer, I don't know if it's strings or keywords |
| 11:31 | devlinsf | but if I want it to be useful, I have to support both |
| 11:31 | chouser | but in that case, isn't it likely the user would want to be able to provide their own "combining" function? |
| 11:32 | devlinsf | Yeah, probably. But providing a left-prefix & right prefix works for 99% of use cases |
| 11:33 | Mec | is there a way to do like a threaded partial? |
| 11:38 | chouser | Mec: perhaps with 'future'? |
| 11:40 | Mec | err not that kind of thread, i mean like #(somefunc % n) wherewas (partial somefunc n) would be #(somefunc n %) |
| 11:40 | chouser | Mec: ah. I suppose you could write such a thing. But normally I just use #() directly. |
| 11:41 | chouser | that's what it's there for. |
| 11:41 | Mec | true, its not particularly shorter |
| 11:42 | chouser | devlinsf: 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:43 | devlinsf | chouser: Yeah, I know. It defaults to last, and that works for 90% |
| 11:43 | chouser | For example, both the concat examples you provide can be done more easily without using 'same' at all. |
| 11:43 | vy | How do you guys spot memory leaks (probably caused by lazy evaluation forced caching, etc.) in your Clojure programs? Which tools do you use? |
| 11:44 | devlinsf | true |
| 11:44 | devlinsf | It's for str that I'd want to use the indexing |
| 11:45 | devlinsf | Maybe #() will work better |
| 11:46 | Licenser | what 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:46 | chouser | devlinsf: I do think you're on to something with a multimethod that defaults to something like (into (empty c) (f args c)) |
| 11:46 | devlinsf | So bring it up on the dev list? |
| 11:47 | chouser | vy: jvisualvm makes it easy to spot what kinds of objects are consuming the most memory. |
| 11:48 | chouser | Licenser: that ties you pretty tightly to 'function's argument order. |
| 11:48 | chouser | devlinsf: you don't need my permission for that! :-) |
| 11:48 | devlinsf | I know, but I'm gonna need support |
| 11:48 | devlinsf | Anyway |
| 11:48 | Licenser | chouser: of cause, but isn't that a good thing too, I mean for later understanding of the code? |
| 11:49 | chouser | devlinsf: when clojure starts using protocols for native abstractions, it's reasonable to think (into "" ...) will be able to do the right thing. |
| 11:50 | Licenser | at least I could read that better then something like (partial function {2 42, 5 "bla"}) |
| 11:50 | chouser | at which point it may not even need to be a multimethod. Though I guess a multimethod still wouldn't hurt much. |
| 11:51 | devlinsf | chouser: There will always be corner cases |
| 11:51 | devlinsf | Okay, time to write something up |
| 11:51 | chouser | but with protocols, you could extend your own types to work with 'into' and 'empty' |
| 11:51 | devlinsf | Hmmm... true |
| 11:52 | chouser | but again, a multimethod still wouldn't hurt much. Especially when such use of protocols is still theoretical. :-) |
| 11:52 | devlinsf | The only two real use casas for the multimethod are String & Lazyseq |
| 11:52 | Licenser | hmm is there any good explenation of how rotocils will work and what they will do exactly? |
| 11:53 | devlinsf | Eh, and you know what? The multimethod works now. It can always be upgraded later |
| 11:53 | chouser | right |
| 11:54 | chouser | I'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:55 | devlinsf | Is it needed elsewhere? |
| 11:55 | chouser | right now, any given function either returns a lazy seq or it doesn't. |
| 11:55 | gcv | quick 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:56 | devlinsf | chouser: If I get a lazy-seq, I can't recreate the original type |
| 11:56 | chouser | to choose between them implicitly might either be really nice or a source of confusion. |
| 11:56 | devlinsf | Eh, let's see what happens |
| 11:58 | chouser | gcv: only contrib needs to be AOT compiled, not your own code. |
| 11:59 | gcv | chouser: thanks, I didn't realize that |
| 12:01 | chouser | That's for c.c.condition of course. |
| 12:03 | gcv | I assume you use error-kit since you wrote it? :) |
| 12:03 | chouser | heh. you'd think. |
| 12:05 | chouser | error-kit tries to do too much. If you don't need the continue or continue-with features, I'd avoid error-kit |
| 12:09 | gcv | chouser: thanks for the advice |
| 13:46 | cmbntr | hi, is there a shortcut to (first (remove nil? s)) |
| 13:53 | devlinsf | (some identity s) |
| 13:57 | Licenser | the full disclojure videos are briliant |
| 13:57 | Licenser | very very nice! |
| 13:58 | cmbntr | devlinsf: thanks |
| 14:00 | devlinsf | Licenser: Thank for |
| 14:00 | devlinsf | err, you |
| 14:00 | Licenser | devlinsf: you're welcome |
| 14:00 | Licenser | so may I add an idea/wish |
| 14:00 | devlinsf | Yeah, shoot |
| 14:01 | Licenser | So 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:02 | devlinsf | That's exactly where I want to go |
| 14:02 | Licenser | Ah very nice :D |
| 14:02 | devlinsf | The goal is an "intermediate developer" |
| 14:03 | devlinsf | You need to be able to do (+ 2 2), (map #(* 2 %) [1 2 3]) |
| 14:03 | devlinsf | etc |
| 14:03 | devlinsf | (That material is better covered elsewhere) |
| 14:03 | Licenser | I 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:03 | devlinsf | Stay tuned the next few weeks then |
| 14:04 | Licenser | I will ;) |
| 14:04 | Anniepoo | anybody had any luck getting enclojure's repl to work with the head RC? |
| 14:04 | Licenser | hmm also something like a emacs-clojure quick howto video would be cool :P |
| 14:04 | Licenser | every source that I found about that expects you to be proficient with EMACS |
| 14:06 | devlinsf | Licenser: If I was qualified to write about emacs, I would |
| 14:06 | devlinsf | Did you check out LauJensen's stuff? |
| 14:06 | Licenser | That is the exact problem, people who are qualified make it too complicated :P |
| 14:07 | Licenser | not that I'd know of, is it about EMACS and Clojure? |
| 14:07 | devlinsf | It's mostly Clojure, with some emacs |
| 14:08 | devlinsf | He also shows different stuff, worth checking out |
| 14:08 | Licenser | let's ask Mr. G about it ^^ |
| 14:09 | Licenser | hah okay I managed to subscribe to your cahnnel :P |
| 14:11 | Licenser | ah very nice thank you devlinsf! |
| 14:29 | Licenser | gnaw |
| 14:30 | Licenser | things seem so easy when they work :P |
| 14:31 | guru | i want to create a state 'object' that can have itself as next state |
| 14:31 | guru | like: |
| 14:32 | guru | { :date "bla" next-states [ self ] } |
| 14:33 | guru | is this were promises shine? |
| 14:34 | stuartsierra | sounds like a lazy sequence to me |
| 14:35 | guru | atom is rather funny, didnt try refs |
| 14:36 | guru | ,(let [a (atom 0)] (swap! a (fn [_] a))) |
| 14:36 | clojurebot | #<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:37 | guru | i dunno how a lazy seq comes into play here |
| 14:37 | guru | ill think about it |
| 14:38 | chouser | guru: 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:38 | chouser | ,(iterate inc 1) ; here the state starts as 1, next state computed by applying 'inc' to the old state. |
| 14:38 | clojurebot | Eval-in-box threw an exception:java.lang.OutOfMemoryError: Java heap space |
| 14:39 | chouser | ,(take 10 (iterate inc 1)) |
| 14:39 | clojurebot | (1 2 3 4 5 6 7 8 9 10) |
| 14:39 | guru | yes |
| 14:39 | guru | my problem might still be different |
| 14:39 | guru | let me think a sec |
| 14:41 | chouser | the 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:41 | guru | yep |
| 14:43 | guru | ok, a tiny example: i have a map of states, a state is a list of possible follow-up states: |
| 14:43 | guru | {:loop-state [:loop-state :some-other-state] :some-other-state []} |
| 14:44 | guru | i want to transfrom that map into sth like: |
| 14:46 | guru | ok, bad example, again: {:loop-state [:loop-state :some-other-state] :some-other-state [:1 :2]} |
| 14:47 | guru | should become {:loop-state [[[...]] [next-states of :1, next-states of :2]} |
| 14:48 | guru | ok, basically i want to create a seq which contains itself |
| 14:48 | chouser | hm. why? the first way seems good -- what the reason for the transform? |
| 14:49 | guru | i would have to do a map lookup, each time a make a transition |
| 14:49 | guru | plus i have to pass that map to my functions |
| 14:50 | chouser | hm. |
| 14:50 | guru | where reason 2 is worse for me |
| 14:50 | guru | promise seems to do the job really well here |
| 14:51 | chouser | promise is usually for flow-control -- deref blocks. |
| 14:52 | chouser | I guess it could work, as could atom. |
| 14:53 | rrc7cz | why 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:54 | chouser | you want current-state and the list of next-states to be a single object? |
| 14:55 | chouser | rrc7cz: #(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:55 | Licenser | nice |
| 14:57 | rrc7cz | chouser: okay that makes sense |
| 15:00 | guru | whats the reasoning behind assert not returning a value in case it evals to logical true? |
| 15:00 | chouser | asserts can disappear if compiled with *assert* false |
| 15:01 | guru | yes, but the code inside doesnt have to |
| 15:01 | guru | (defmacro assert-ret |
| 15:01 | guru | "Evaluates expr and returns it if it evaluates to logical true, |
| 15:01 | guru | throws an exception otherwise." |
| 15:01 | guru | [x] |
| 15:01 | guru | (if *assert* |
| 15:01 | guru | `(if ~x |
| 15:01 | guru | ~x |
| 15:01 | guru | (throw (new Exception (str "Assert failed: " (pr-str '~x))))) |
| 15:01 | guru | x)) |
| 15:01 | guru | is the version i use |
| 15:06 | guru | maybe sth like that already exists, being able to provide an optional message would be even nicer and still shorter than if...throw (.Exception... |
| 15:08 | chouser | I think people generally want the code inside the assert to disappear as well. It's often doing work just for the assert. |
| 15:09 | chouser | though the need for manual use of assert has gone way down with :pre and :post |
| 15:10 | guru | ok, 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:10 | chouser | I think that's the common usage, yes. |
| 15:11 | chouser | I 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:11 | guru | ok, thx |
| 15:35 | lazy1 | is *command-line-args* still the best way to check if we're imported or being run as main script? |
| 15:38 | chouser | hm -- 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:39 | lazy1 | OK, thanks |
| 16:25 | tolstoy | I keep getting: java.lang.IllegalArgumentException: No matching method found: println for class swank.util.io.proxy$java.io.StringWriter$0 |
| 16:25 | tolstoy | The clojars version of swank hasn't been updated in a while. |
| 16:25 | tolstoy | Is there something I can do with that stuff? |
| 16:26 | the-kenny | tolstoy: When you require something? |
| 16:26 | the-kenny | s/something/something from your project) |
| 16:27 | tolstoy | the-kenny: Mainly when I get errors using derby. Or some sort of errors. |
| 16:28 | the-kenny | tolstoy: I have a very strange error involving this class too |
| 16:28 | the-kenny | (swank.util.io.proxy$java.io.StringWriter$0) |
| 16:28 | the-kenny | Looks like something there is really broken |
| 16:29 | rrc7cz | can anyone imagine why (take 5 (p29)) |
| 16:29 | rrc7cz | (4.0 4.0 8.0 9.0 16.0) |
| 16:29 | the-kenny | rrc7cz: What's "p29"? |
| 16:30 | rrc7cz | oops, 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:31 | rrc7cz | p29 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:31 | hiredman | sets are not sorted, so the order going into a set is not the same as coming out |
| 16:31 | rrc7cz | I can switch to sorted-set, but it's not the order I care about; the values are changed |
| 16:32 | hiredman | how do you know? |
| 16:32 | rrc7cz | hiredman: (4.0 4.0 8.0 9.0 16.0) vs. (8.589934592E9 3.6893488147419103E19 1.5845632502852868E29 6.805647338418769E38 5.391989333430128E67) |
| 16:33 | rrc7cz | oh |
| 16:33 | rrc7cz | wait |
| 16:33 | rrc7cz | I'm stupid |
| 16:33 | rrc7cz | well |
| 16:33 | rrc7cz | hiredman: i get it now what you mean about sorted |
| 16:33 | rrc7cz | hiredman: since I'm taking only 5, it could be a different 5 each time |
| 16:34 | rrc7cz | but all values _should_ be whole numbers since I'm only doing powers of ints |
| 16:34 | Chousuke | pow returns floats though, doesn't it? |
| 16:34 | Chousuke | they are imprecise. |
| 16:34 | rrc7cz | Chousuke: it does, but I'd expect all X.0, Y.0. Z.0, etc |
| 16:34 | rrc7cz | aha, you're right |
| 16:35 | rrc7cz | I should use BigInt instead |
| 16:35 | defn | http://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:35 | the-kenny | defn: Username/Password? ;) |
| 16:36 | defn | oh wrong URL :) |
| 16:36 | defn | http://www.devinwalters.com/posts/24 |
| 16:40 | defn | http://www.paulgraham.com/rootsoflisp.html |
| 16:42 | tolstoy | the-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:42 | the-kenny | tolstoy: No, I don't get the same error, but a similar. Some casting-error |
| 16:43 | defn | oh no the-kenny not this problem again |
| 16:43 | defn | this is still persisting? |
| 16:43 | the-kenny | defn: Not again |
| 16:43 | defn | so you fixed it? |
| 16:43 | the-kenny | No |
| 16:43 | the-kenny | Ist persists, it never disappeared |
| 16:43 | the-kenny | ;) |
| 16:44 | defn | ugh! |
| 16:44 | the-kenny | I'm requiring my code in the *inferior lisp* buffer now.. ugly workaround |
| 16:44 | defn | you're on OSX you said? |
| 16:44 | the-kenny | Yes |
| 16:44 | defn | 10.6? |
| 16:44 | defn | not that it matters really, just curious |
| 16:44 | the-kenny | Yes, 10.6 |
| 16:45 | the-kenny | It must be something wrong with one of the dependencies here.. I wonder why no one here has the same problem |
| 16:46 | the-kenny | I wonder if it's the same if I use a self-built swank-clojure... |
| 16:46 | defn | dude i have tried to replicate it |
| 16:47 | defn | i blew away my elpa and tried again, but it works perfectly |
| 16:47 | technomancy | wdouglas: do you have a copy of slime-fuzzy.el that's been modified to work as an elpa package? |
| 16:48 | defn | technomancy: did that go up on elpa? |
| 16:49 | technomancy | defn: not yet |
| 16:49 | defn | will adding the slime-fuzzy.el to my elpa/slime/ dir make it so i can't update the slime package |
| 16:49 | ordnungswidrig | hny! |
| 16:50 | technomancy | defn: it shouldn't, but slime-fuzzy.el still needs a few tweaks before it's really made into a proper package |
| 16:50 | the-kenny | technomancy: Any idea why this happens? http://gist.github.com/267270 A stacktrace goes down onto call-on-flush-stream. |
| 16:51 | technomancy | the-kenny: no, never seen that; sorry |
| 16:51 | the-kenny | :( |
| 16:52 | the-kenny | I'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:52 | technomancy | what JVM? |
| 16:52 | tolstoy | the-kenny: I think I've seen something similar along the way. |
| 16:54 | the-kenny | technomancy: java version "1.6.0_17" 32 or 64bit, doesn't matter |
| 16:54 | the-kenny | tolstoy: Really? |
| 16:54 | tolstoy | I think I also get my version of that issue when derby prints straight to stderr or stdout or something. |
| 16:55 | tolstoy | Ah, I don't know. Best thing would be to create a tiny test case that causes it. |
| 16:56 | the-kenny | tolstoy: 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:56 | the-kenny | This happens in every project I have here |
| 16:57 | the-kenny | Here is one with a stacktrace: http://gist.github.com/267278 |
| 17:01 | technomancy | the-kenny: sun's JVM, openjdk, or some other one? |
| 17:02 | the-kenny | technomancy: Should be sun. The default one on osx |
| 17:02 | the-kenny | I never had any problems.. this just started some days ago |
| 17:02 | congreve | /? |
| 17:02 | technomancy | doesn't Apple ship their own modifications? |
| 17:03 | the-kenny | technomancy: Yes, but it worked without any problem for a long time. |
| 17:03 | the-kenny | I don't remember any java-update or something similiar which could have broken it |
| 17:04 | technomancy | dunno; sorry. I can't do much without a repro-case. |
| 17:04 | defn | the-kenny: maybe try getting java from macports |
| 17:04 | the-kenny | hm.. ok, thanks anyway |
| 17:05 | tolstoy | the-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:05 | defn | sudo port install openjdk6 |
| 17:07 | the-kenny | I'm almost sure I've tried that |
| 17:08 | the-kenny | tolstoy: yes.. that works |
| 17:09 | the-kenny | That all doesn't make sense for me |
| 17:10 | technomancy | the average function length in swank_fuzzy.clj makes my stomach churn |
| 17:10 | technomancy | what a mess |
| 17:12 | technomancy | at least there are a few tests |
| 17:15 | technomancy | course 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:18 | hiredman | clojurebot: problem? |
| 17:18 | clojurebot | People have a problem and think "Hey! I'll use a regular expression!". Now they have two problems.... |
| 17:19 | hiredman | clojurebot: problem? |
| 17:19 | clojurebot | People have a problem and think "Hey! I'll use a regular expression!". Now they have two problems.... |
| 17:19 | hiredman | bah |
| 17:21 | arohner | hrm, jswat is not highlighting lines for |
| 17:21 | arohner | for me |
| 17:22 | arohner | has anyone else had that problem with jswat 4.5? it doesn't highlight the lines with breakpoints, nor show the current line |
| 17:22 | the-kenny | technomancy: Should I use [org.clojure/swank-clojure "1.0"] or [swank-clojure "1.1.0-SNAPSHOT"]? |
| 17:27 | arohner | ah, jswat behaves normally when viewing .java files, but not .clj |
| 17:28 | arohner | is there some configuration I have to do? |
| 17:32 | the-kenny | I just don't get this... |
| 17:32 | the-kenny | It also breaks if I evaluate a (ns)-declaration |
| 17:33 | the-kenny | where I import something from my project |
| 17:33 | the-kenny | It works if I just import things from other projects |
| 17:40 | the-kenny | Can someone please zip me a simple project with some files where he uses swank-clojure-project with leiningen successfully? |
| 17:42 | the-kenny | (with all dependencies please) |
| 17:46 | the-kenny | Weeee |
| 17:46 | the-kenny | Looks like it's a configuration issue |
| 17:48 | the-kenny | That can't be.. |
| 17:49 | the-kenny | defn: Interested in the source of the problem? |
| 17:51 | the-kenny | technomancy: I found the problem - Really strange.. should I write some instructions to reproduce it? |
| 17:52 | the-kenny | It's really simple.. but I don't get why it throws such a strange exception |
| 18:06 | the-kenny | How to break swank-clojure: http://gist.github.com/267299 :) |
| 18:06 | the-kenny | I had these three lines in an init-file to customize my repl.. these three lines were the source of all problems |
| 18:13 | ordnungswidrig | the-kenny: interesting. |
| 18:13 | ordnungswidrig | however, I'll take a nap now. |
| 19:53 | lazy1 | Is there a way for me to check if an object supports an interface? |
| 19:53 | lazy1 | (Java object) |
| 19:54 | cark | ,(doc isa?) |
| 19:54 | clojurebot | "([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:54 | kotarak | ,(doc instanceß) |
| 19:54 | clojurebot | excusez-moi |
| 19:54 | kotarak | ,(doc instance?) |
| 19:54 | clojurebot | "([c x]); Evaluates x and tests if it is an instance of the class c. Returns true or false" |
| 19:54 | kotarak | ,(instance? CharSequence "foo") |
| 19:54 | clojurebot | true |
| 19:54 | kotarak | Is that an interface? |
| 19:55 | lazy1 | thanks |
| 19:56 | kotarak | ,(isa? (type "foo") CharSequence) |
| 19:56 | clojurebot | true |
| 20:53 | chouser | anyone here know enlive? |
| 21:07 | replaca | chouser: yeah, some |
| 21:08 | chouser | I'm trying to add an attribute to all tags of a given name |
| 21:08 | chouser | the value of the attribute will depend on the content of the tag element. |
| 21:09 | replaca | by name do you mean the tag name (like <a>) or an id or class? |
| 21:12 | chouser | right, tag name |
| 21:12 | chouser | it looks like I want sniptest, but it appears to be gone? |
| 21:12 | chouser | so 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:13 | chouser | (at (first (xml-resource ..a..)) [:para] ..b..) |
| 21:13 | chouser | I think I've got ..a.. right, but I'm still trying to figure out what to put for ..b. |
| 21:17 | replaca | you should be able to do something like (fn [n] (apply (set-attr :attr-name (transform (:content n))) n)) |
| 21:18 | replaca | I'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:19 | replaca | "transform" would be your func that looks at the content and derives the value for the attribute |
| 21:19 | chouser | ok thanks |
| 21:20 | replaca | set-attr itself returns a func which is what makes some of these things tricky |
| 21:23 | chouser | any idea how to get from what 'at' returns back to a string? |
| 21:23 | chouser | or something better to use instead of 'at'? |
| 21:23 | replaca | well, if you know the file at compile time, you can use deftemplate |
| 21:24 | replaca | that's alot faster if you're doing it a bunch |
| 21:24 | chouser | There's no file. The xml is built at runtime into a string. |
| 21:24 | replaca | then at is probably what you want |
| 21:25 | replaca | hang on, I think I found a ref for you. |
| 21:25 | replaca | (while I'm chasing that out...) |
| 21:27 | replaca | use (apply str (at ...)) to get a whole regular string |
| 21:28 | replaca | at least that works on deftemplate and I think it works on at too |
| 21:28 | chouser | no, at returns a seq of hashes |
| 21:28 | chouser | hash-maps, that is. |
| 21:28 | chouser | oh, they're string clojure.xml things |
| 21:28 | chouser | I should be able to use emit |
| 21:29 | replaca | yup, that should be right |
| 21:29 | chouser | emit is not public |
| 21:30 | replaca | use emit* |
| 21:31 | replaca | it's public and it's what's used in the def of deftemplate |
| 21:31 | chouser | ok, looks good. |
| 21:33 | replaca | for the (apply (at ...)) thing look at http://github.com/tomfaulhaber/autodoc/blob/master/src/autodoc/build_html.clj#L74 |
| 21:34 | chouser | ohhhh... I see. |
| 21:34 | replaca | I'm adding a prefix (like ../../) to hrefs there to make up for putting pages in subdirectories |
| 21:36 | replaca | (That's actually my own version of deftemplate that memoizes instead of working at compile time) |
| 21:36 | replaca | but the syntax is otherwise the same |
| 21:37 | chouser | ok! I've got it sketched out now. |
| 21:37 | replaca | cool. glad to hear it |
| 21:37 | chouser | Thanks, I'm sure you just saved me at least a couple of frustrating hours. :-) |
| 21:38 | replaca | gotta run now, but I should be back later if you have more q's |
| 21:38 | chouser | great, thanks. |
| 21:38 | replaca | (well I already spent those frustrating hours so you don't have to :-)) |
| 21:38 | chouser | :-) |
| 23:33 | chouser | any way to "or" a bunch of tags in an enlive selector? |
| 23:33 | chouser | I have [:para] and I want something like [(or :para :sect1 :sect2)] |
| 23:42 | replaca | chouser: the readme shows using a set as working -> #{selector1, selector2} |
| 23:42 | replaca | where each selector is itself a vector, as usual |
| 23:44 | replaca | I don't use that technique myself anywhere, though |
| 23:47 | chouser | ah, thanks. |