2009-03-25
| 00:01 | slashus21 | Anyone thought of adding some examples to clojure's wikipedia page? |
| 00:05 | durka42 | clojurebot: examples? |
| 00:05 | clojurebot | examples is http://en.wikibooks.org/wiki/Clojure_Programming/Examples/API_Examples |
| 00:06 | durka42 | those may be kind of old |
| 00:06 | slashus21 | I made a syntax highlighting lang file for gedit. |
| 00:07 | slashus21 | It works pretty well. Still working on it. |
| 00:07 | durka42 | nice |
| 01:44 | Gilbert987 | does anyone know if there's a clojure interface for couchdb? |
| 02:50 | blbrown | Gilbert987, isn't couchdb a rest interface. probably wouldn't be too hard to cook one up using Java's URL libs |
| 02:51 | hiredman | there are java couchdb libs too |
| 02:54 | blbrown | hiredman, I have java code and I am invoking the clojure interpreter (legacy_script) is there a way to pass a Java object to that instance of the clojure script) Kind of as a global |
| 02:55 | hiredman | your java code is calling the clojure runtime? |
| 02:56 | blbrown | yea, just a copy of the clojure.main.java code |
| 02:57 | blbrown | nevermind, I got it |
| 03:04 | blbrown | OK, nevermind, dont have it. I thought I could do something with Var.invoke |
| 03:06 | Raynes | hiredman: You're still my hero. |
| 03:06 | hiredman | you want Var.intern I think |
| 03:06 | hiredman | something like |
| 03:06 | hiredman | Var.intern(Namespace.findOrCreate(Symbol.create("clojure")), Symbol.create("*console*"), console); |
| 03:07 | blbrown | nice |
| 03:34 | Raynes | c.c.duck-streams is the best thing evar. |
| 03:41 | Raynes | All your clojure contrib are belong to us. |
| 03:55 | Raynes | "Web browser in VB.NET" Failure failure, beep beep blue screen of death. |
| 04:40 | AWizzArd | ~seen cemerick |
| 04:40 | clojurebot | cemerick was last seen quiting IRC, 644 minutes ago |
| 04:51 | antifuchs | hmm, opening pages on the clojure wiki is a bit tedious with its cache control headers. who runs the server? (: |
| 04:52 | antifuchs | (opening /api takes 1.35 seconds. every time I load it. agh /-:) |
| 04:54 | AWizzArd | I think its hosted on a commercial wiki provider. |
| 04:54 | antifuchs | ah, wikispaces |
| 04:55 | AWizzArd | yup, that was the one |
| 04:55 | antifuchs | I'll ask them if they know their page load times are annoying (: |
| 04:55 | AWizzArd | *g* |
| 05:05 | antifuchs | right. hopefully they'll respond; this is getting slightly annoying /-: |
| 05:21 | hjlee | are there easy way to change radix? specifically decimal to binary. |
| 05:38 | AWizzArd | ,16rff |
| 05:38 | clojurebot | 255 |
| 05:39 | AWizzArd | ,16r2 |
| 05:39 | clojurebot | 2 |
| 05:39 | AWizzArd | ,2r1611001 |
| 05:39 | clojurebot | For input string: "1611001" |
| 05:39 | AWizzArd | nah |
| 05:40 | AWizzArd | ,2r101011 |
| 05:40 | clojurebot | 43 |
| 05:40 | AWizzArd | hjlee: does that help? |
| 05:40 | hjlee | i want to get 101011 from 43 ... |
| 05:40 | antifuchs | hjlee: also, I see that cl-format has print radix control |
| 05:41 | AWizzArd | ,(Integer/toBinaryString 43) |
| 05:41 | clojurebot | "101011" |
| 05:41 | hjlee | that's it, thank you! |
| 06:22 | antifuchs | ok, so hm. is there a way to create a .class file (via compile of a .clj file containing a gen-class form) from swank-clojure without tearing my hair out over classpath issues? |
| 06:29 | Holcxjo | I get the impression that the classpath problems are one of the biggest hurdles for clojure -- why oh why can't that be adjusted at runtime? |
| 06:31 | antifuchs | suppose that would require a custom classloader thing and then other things would break |
| 06:32 | antifuchs | under the circumstances, it may be the best thing for now. it's just a pretty grating experience (: |
| 06:34 | antifuchs | ok, so how /do/ I add a directory (not a jar) to the classpath with swank-clojure? |
| 06:34 | hoeck | antifuchs: just set your classpath with [m-x] customize-variable [ret] swank-clojure-extra-classpaths |
| 06:35 | hoeck | and restart emacs and slime |
| 06:35 | antifuchs | hoeck: but that will disable autoloading of the stuff in ~/.clojure - right? |
| 06:35 | antifuchs | or let's say auto-classpathing |
| 06:36 | hoeck | I don't know, who calls ~/clojure, swank-clojure or clojure.lang.main? |
| 06:36 | antifuchs | that's swank-clojure, IIANM |
| 06:38 | antifuchs | ok. I may have made an error setting the current classpath. is there a way to inspect the classpath that's currently set? |
| 06:43 | hoeck | there is (System/getProperty "java.class.path") |
| 06:44 | antifuchs | oh, thats cool |
| 06:44 | antifuchs | seems like the extra paths I'm pushing to swank-clojure-extra-classpaths isn't getting passed through to java. |
| 06:45 | antifuchs | so... is anybody using swank-clojure? |
| 06:45 | antifuchs | from the things I'm encountering, it looks like it's not really actively improved. /-: |
| 06:46 | hoeck | you need to restart emacs, swank-clojure-extra-classpaths is only evaluated when emacs loads the swank-clojure.el file |
| 06:47 | antifuchs | yes |
| 06:48 | antifuchs | I'm familiar with emacs. been using it for lisp development for 10 years (: |
| 06:48 | antifuchs | I also need to restart emacs after ,quit in the clojure swank repl. this is what was giving me that above impression (: |
| 06:49 | antifuchs | (need to restart because the next time I run clojure with slime, connecting to the swank port will hang) |
| 06:52 | hoeck | and you're right about the jars in ~/.clojure, they are ignored if you customize the extra classpath |
| 06:53 | antifuchs | what did was remove the 'clojure implementation from the swank impl alist, and add another one which works to my specifications |
| 06:53 | antifuchs | this isn't hyper-ideal, but for now it'll work well enough (: |
| 06:55 | hoeck | I have written a function for to do that for me, restarting emacs after changing the classpath for clojure is a bit odd |
| 06:56 | antifuchs | yeah. it's a bit annoying having to restart emacs after quitting clojure, too, let me tell you (: |
| 06:57 | hoeck | are the classpaths showing up in the string produced from the swank-clojure-cmd function? |
| 06:58 | antifuchs | now they are. |
| 06:58 | antifuchs | I'm thinking this may be easier if I just define one command to start clojure for each project |
| 07:03 | hoeck | I have always one clojure instance running, the classpath and clojure-package system works very well in separating all the projects |
| 07:08 | antifuchs | yeah, I was (naively) hoping I could avoid the whole initial setup cost. |
| 07:08 | mib_5zec882q | Anyone know if the ants demo still works with the latest version of clojure? |
| 07:08 | mib_5zec882q | http://clojure.googlegroups.com/web/ants.clj?gda=AH2v2joAAAC2LrkjeC7f10uHiY7GOiyx4PWDLdmXu1edmOpq5JPfP-9OU0NQiFWgQuhmPR7veGf97daDQaep90o7AOpSKHW0 |
| 07:08 | mib_5zec882q | I just get a swing window with a blue square on it |
| 07:08 | mib_5zec882q | but no ants |
| 07:09 | AWizzArd | did you look at the comments at the bottom? |
| 07:09 | AWizzArd | (def ants (setup)) |
| 07:09 | mib_5zec882q | no, I started at the top and didn't get to the bottom yet :) |
| 07:09 | AWizzArd | there you find commented out some calls that create the ants and start the simulation |
| 07:09 | mib_5zec882q | thanks, that should help |
| 07:12 | AWizzArd | Although that file could really need a little update. For example we find (. Thread (sleep evap-sleep-ms)) |
| 07:12 | mib_5zec882q | Cool, I have ants now! |
| 07:12 | mib_5zec882q | Thanks |
| 07:12 | AWizzArd | But today we would say: (Thread/sleep evap-sleep-ms) |
| 07:13 | AWizzArd | Btw antifuchs, nice to have you here :) |
| 07:14 | mib_5zec882q | Also, a comment at the top saying "see the bottom of the file for how to run it" would have helped |
| 07:14 | antifuchs | AWizzArd: and you (: |
| 07:14 | antifuchs | I'm glad I finally have the time to work with clojure a bit (: |
| 07:31 | antifuchs | hm, how can I get the full path of a file whose (compile ) failed? |
| 07:33 | AWizzArd | What error message do you get when you try to compile? |
| 07:36 | AWizzArd | It should tell you at least the filename + linenumber |
| 07:46 | AWizzArd | clojurebot: max people |
| 07:46 | clojurebot | max people is 164 |
| 07:48 | antifuchs | just the basename. I was hoping for a full path |
| 07:52 | leafw | antifuchs: grep is your friend then |
| 07:56 | antifuchs | leafw: like pathnames are never ambiguous |
| 07:58 | AWizzArd | but should there not be just one .clj file of that name in your classpath? |
| 07:59 | antifuchs | not sure |
| 08:05 | hoeck | AWizzArd: not necessarily, there could be hoeck/lib.clj and awizzard/lib.clj in the classpath, and the compiler just says error in "lib.clj" |
| 08:17 | AWizzArd | hoeck: but they will sit in different namespaces? (ns de.clojure.hoeck.lib ...) vs (ns de.clojure.awizzard.lib ...) |
| 08:18 | AWizzArd | and when /home/clj/src/ is in the classpath, and when I know what I am compiling, I could dive into those dirs: emacs /home/clj/scr/de/clojure/hoeck/lib.clj |
| 08:21 | antifuchs | I think my problem was related to now knowing what I was compiling (: |
| 08:21 | antifuchs | anyway... that works now, thank goodness |
| 08:21 | antifuchs | now I'm getting odd ClassFormatErrors when I try to load the class files that compile emits |
| 08:21 | antifuchs | java.lang.ClassFormatError: Repetitive method name/signature in class file org/reprap/artofillusion/SwankTool (NO_SOURCE_FILE:0) |
| 08:23 | antifuchs | what is up with that? (-: |
| 08:24 | Holcxjo | Very Ruby-esque: Don't repeat yourself! |
| 08:25 | antifuchs | I wasn't meaning to (: |
| 08:26 | antifuchs | huh, seems like the :methods clause in ns does that. will debug further |
| 08:26 | Holcxjo | The error messages often have a hint of a Zen-like riddle. |
| 08:26 | Holcxjo | How new-age is that? |
| 08:31 | antifuchs | it goes away once I remove the method declaration clause in ns. no idea if it's really needed. hm (: |
| 08:34 | hoeck | antifuchs: are you generating a class with additional methods? |
| 08:53 | antifuchs | yes, I am |
| 08:56 | antifuchs | oh wow, and look here. I have created my first .jar plugin to Art of Illusion that includes clojure (: |
| 08:57 | antifuchs | didn't have to write any java code at all; that wasn't too hard, let's see if I can get a Swank repl now (: |
| 09:12 | antifuchs | thanks - most of what kept me were misunderstandings that you all helped clear up (: |
| 09:28 | AWizzArd | antifuchs: grats to your .jar |
| 10:08 | cconstantine | Does anyone know a good resource for a high school kid who wants to get into programming (not clojure programming, programming in general) |
| 10:11 | leafw | cconstantine: a shell, gcc, an good text editor, and python/java/sbcl ... and their webpages with docs, that can give you most of what you need to tinker. Having a task in mind to accomplish will help a lot too. |
| 10:11 | gnuvince | cconstantine: http://greenteapress.com/thinkpython/thinkCSpy/html/ |
| 10:12 | cconstantine | leafw: I'm pretty sure this kid only has a windows machine so things like a decent shell and/or gcc could be hard to get working and just a frustration before they hit any kind of 'real' programming |
| 10:12 | Holcxjo | cconstantine: Squeak is meant for that sort of audience as well I believe |
| 10:13 | cconstantine | gnuvince: that looks like it might be useful |
| 10:14 | cconstantine | Holcxjo: thanks, looking into it |
| 10:14 | antifuchs | cconstantine: squeak is a really cool environment to get impressive results quickly |
| 10:14 | cconstantine | antifuchs: that'll be important :) |
| 10:14 | antifuchs | immensely. you get a really nice multimedia environment, and modifying it is really quite easy |
| 10:17 | Holcxjo | Danger is of course, that Smalltalk is much like Lisp in that it spoils you for life -- going back to other languages will be difficult |
| 10:18 | cconstantine | lol |
| 10:18 | cconstantine | hook 'em while they're young! |
| 10:19 | Holcxjo | You laugh -- but then they'll be made to program in Java or similar. Their peers will think it's cool to churn out mega bytes of interfaces, declarations etc but they are doomed to a life of misery. |
| 10:20 | gnuvince | Holcxjo: don't you know that IDE-oriented programming is the best new programming paradigm? |
| 10:20 | gnuvince | Why have a better language when you can click on a button and Eclipse spits out the 20 lines of code you need, every time you need them? |
| 10:21 | antifuchs | s/misery/productivity/ (-: |
| 10:24 | AWizzArd | Well, as they have no macros they need the ide to insert/maintain the code. |
| 10:24 | AWizzArd | People want Lisp, they just don't know it. |
| 10:24 | gnuvince | AWizzArd: they don't even have closures |
| 10:25 | cconstantine | and to think there was a time that I thought having code blocks that looked almost identical was a good thing |
| 10:26 | gnuvince | that looked almost identical? |
| 10:27 | cconstantine | function after function, or class after class that were identical except for a single minor detail (like a different type) |
| 10:27 | Chouser_ | sure, it indicates you've found a key pattern in your design |
| 10:27 | gnuvince | cconstantine: oh |
| 10:27 | Chouser_ | ...and failed to abstract it. ;-) |
| 10:27 | cconstantine | right |
| 10:28 | AWizzArd | Although, I think Java had closures right from the beginning. |
| 10:29 | gnuvince | Java doesn't have closures |
| 10:29 | hoeck | but java has objects |
| 10:29 | AWizzArd | via anonymous inner classes |
| 10:29 | AWizzArd | they are just an ugly syntax for closures |
| 10:31 | digash | Anonymous classes are not clojures. |
| 10:31 | cconstantine | would you call that a language feature though? I believe you can do that in C++ too |
| 10:31 | AWizzArd | http://kawagner.blogspot.com/2006/08/closures-for-java.html |
| 10:32 | Chouser_ | wow, Java's had those much longer than I thought |
| 10:32 | AWizzArd | digash: In Java closures are called anonymous inner classes. |
| 10:33 | digash | As I said anonymous inner classes are not closures. |
| 10:33 | cconstantine | You can use closures in any language, even ASM... (a turing complete language is a turing complete language and all) but I wouldn't say ASM has closures |
| 10:33 | digash | They do no enclose environment. |
| 10:33 | gnuvince | http://video.google.com/videoplay?docid=4051253555018153503&hl=en |
| 10:33 | AWizzArd | digash: wrong, they do |
| 10:33 | gnuvince | That guy explains why anonymous inner classes fail at being closures. |
| 10:34 | AWizzArd | The guy in the blog explains why they are closures :) |
| 10:34 | gnuvince | AWizzArd: who's that guy? |
| 10:34 | AWizzArd | gnuvince: http://kawagner.blogspot.com/2006/08/closures-for-java.html |
| 10:35 | gnuvince | I linked you Neal Gafter |
| 10:35 | AWizzArd | and funny, Neal Gafter, who made your video, commented in the blog :) |
| 10:35 | gnuvince | http://gafter.blogspot.com/2006/08/closures-for-java.html |
| 10:35 | SethTisue | fwiw, inner classes weren't in Java "in the beginning" (Java 1.0) |
| 10:36 | SethTisue | they were added in Java 1.1. just a minor point |
| 10:36 | cconstantine | that's still pretty early |
| 10:37 | digash | AWizzArd: http://en.wikipedia.org/wiki/Closure_(computer_science) |
| 10:42 | digash | AWizzArd: by that definition Java anonymous classes are not closure, but of cause you can call object closure and Java is a dialect of List because it has GC. |
| 10:42 | AWizzArd | Gafter seems to have no arguments for what his Closures can do and which is not possible yet with anon inner classes. He has good arguments why it is more practical. |
| 10:43 | AWizzArd | But if we log at his blog entry, then we see Karsten Wagner responding there, explaining why Java already has full closures and why Gafters proposal is a bad idea. |
| 10:43 | sellout | I'm pretty sure Java doesn't have closures, since they recently decided not to add closures in Java 7. |
| 10:44 | AWizzArd | sellout: you can use anonymous inner classes to close over some environment. |
| 10:45 | digash | the main point is that closures are functions and not objects. |
| 10:45 | AWizzArd | Or even better: use Clojure :) |
| 10:45 | AWizzArd | digash: yes, ugly to use |
| 10:45 | AWizzArd | if the language had explicit support for closures it would make it much more usable. |
| 10:46 | Chouser_ | but in clojure, functions *are* objects |
| 10:46 | AWizzArd | anyway, as we see, some people are still against explicit support, because that will also come with disadvantages. |
| 10:46 | AWizzArd | http://gafter.blogspot.com/2006/08/closures-for-java.html?showComment=1156164900000#c115616492091390744 |
| 10:47 | digash | Chouser_: that is an implementation detail. |
| 10:47 | AWizzArd | Chouser_: hidden from the Clojure user |
| 10:48 | AWizzArd | here another nice example: http://kawagner.blogspot.com/2006/08/some-more-remarks-on-closures-in-java_22.html |
| 10:48 | digash | I will ask Guy Steel once the talk is over if he thinks that anonymous classes in Java are closures. |
| 10:49 | leafw | digash: don't waste his time, it's semantics. |
| 10:49 | jsankey | at the end of the day, it doesn't matter whether they are closures or not, really |
| 10:49 | jsankey | they still suck for various reasons :) |
| 10:50 | Chouser_ | right, java anon classes do what they do, Clojure fns do what they do. Doesn't matter too much what they're called. |
| 10:50 | AWizzArd | I really suggest to write the application in Clojure instead of Java. |
| 10:51 | jsankey | arguing against the closures for java proposals on the basis that anonymous inners are closures misses the point |
| 10:52 | AWizzArd | jsankey: he mentioned other arguments |
| 10:52 | Chouser_ | a better argument might be: if you want to write that kind of code why not use Clojure? |
| 10:52 | jsankey | Awizzard: sure, there are valid arguments against them to weigh |
| 10:53 | jsankey | but saying java already has closures is meaningless |
| 10:53 | Chouser_ | jsankey: how about: java already has anonymous inner classes that can be used in a lot of cases where you might otherwise use a closure? |
| 10:54 | jsankey | because the fact is that using anonymous inners to implement higher-order functions and custom control structures ranges between painful and impossible |
| 10:54 | Chouser_ | hm. |
| 10:54 | digash | if you have closures you do not need Visitor pattern and some other ones. |
| 10:55 | jsankey | higher order functions are painful because functions aren't first class |
| 10:55 | AWizzArd | jsankey: I can agree on that humans don't like to do it this way, as there is too much syntax. But they still can technically be used for what one wants to do with closures. |
| 10:55 | Chouser_ | Java doesn't have functions, does it? |
| 10:55 | jsankey | so you need to define interfaces describing your function types |
| 10:56 | jsankey | (not to mention that almost none of these have a standard defintion, so lots of peopledefine their own) |
| 10:56 | Chouser_ | it has methods instead |
| 10:56 | AWizzArd | digash: But the visitor pattern is mostly about method dispatch. What does this have to do with closures? |
| 10:56 | jsankey | AWizzArd: technically is right. but i care more about practically :) |
| 10:57 | jsankey | Chouser_: yes, there are no free functions, everything is a method on some type |
| 10:57 | AWizzArd | I think nearly 100% of all people care about this. That is probably the reason why anon inner clases are very rarely used in place of closures. |
| 10:57 | AWizzArd | So yeah, forget Java, write it in Clojure :) |
| 10:57 | jsankey | :) |
| 10:58 | brianh2 | it is possible (if incredibly painful) to do functional programming in raw java code |
| 10:58 | jsankey | i guess i would say i understand the desire to add more support for closures to Java, as is would allow higher-level abstractions |
| 10:58 | AWizzArd | brianh2: yes, although this is now coming closer to the turing argument :) |
| 10:58 | cconstantine | brianh2: first step; write a clojure compiler in java. |
| 10:58 | jsankey | but in reality, yeah, just use clojure! |
| 10:59 | Chouser_ | second step: write a clojure compiler in clojure |
| 10:59 | brianh2 | cconstantine: even without a compile step ;) |
| 11:00 | cconstantine | hehe |
| 11:02 | brianh2 | the main problem is the poor sucker who has to come behind me and re-write all my code 'cuz they don't have a clue about what the code is really doing. |
| 11:03 | AWizzArd | apropos closures: very often, it seems, people think that anon functions are closures. Things like #(...) or (fn [x y] ...). In general this is not the case. |
| 11:04 | Chouser_ | more semantics? when it closes over one binding it becomes a closure? |
| 11:04 | AWizzArd | Well, at least I personally I would find this to be a better definition. |
| 11:04 | AWizzArd | Because otherwise really every function is a closure, even if it just captures the empty environment. |
| 11:05 | Chouser_ | but that's how it actually is, at least in clojure -- every FnExpr has a 'closes' map, which is frequently empty. |
| 11:06 | AWizzArd | Yeah, in that case I would call it a function. |
| 11:06 | AWizzArd | Closures are a subset of functions, and not the set of functions. |
| 11:06 | AWizzArd | A true subset I mean |
| 12:52 | Cark | ~def str |
| 12:54 | Cark | are ou there hirdeman ? |
| 12:56 | Cark | ~seen hiredman |
| 12:56 | clojurebot | hiredman was last seen in #clojure, 589 minutes ago saying: Var.intern(Namespace.findOrCreate(Symbol.create("clojure")), Symbol.create("*console*"), console); |
| 13:19 | st3fan | ola .. is there a downloadable copy of the documentation available? |
| 13:19 | st3fan | i'm traveling and i would like to read things while not online |
| 13:19 | leafw | st3fan: there's a pdf somewhere in the website |
| 13:19 | leafw | otherwise, wget spider is your friend :) |
| 13:19 | st3fan | hmyeah |
| 13:24 | st3fan | what is the official clojure-contrib project? there is one on github, sf and google code |
| 13:26 | Cark | google code |
| 13:28 | st3fan | got it |
| 13:34 | dhea | has anyone had any luck getting clojure + processing working? |
| 13:36 | hoeck | dhea: yes |
| 13:37 | hoeck | dhea: http://github.com/rosado/clj-processing/tree/master |
| 13:37 | dhea | using it, im having a problem getting the core.jar and processing.jar loaded |
| 13:37 | dhea | added it to classpath, cant find it though |
| 13:40 | hoeck | is it in (System/getProperty "java.class.path") |
| 13:42 | hoeck | are you using clojure with emacs-slime or another ide or just from the shell? |
| 13:42 | dhea | emacs-slime |
| 13:42 | dhea | its not in the java.class.path, but ive added the jars with add-classpath |
| 13:49 | st3fan | is clojure-mode good to start? i'm a little afraid of slime and for now i just want to type and eval things |
| 13:49 | Cark | that's what i'm using |
| 13:50 | Chouser_ | st3fan: that's what rhickey uses. |
| 13:52 | dhea | I get the error: java.lang.RuntimeException: You need to use "Import Library" to add processing.core.PGraphicsJava2D to your sketch. (NO_SOURCE_FILE:0) |
| 13:54 | hoeck | dhea: are you trying the example from clj-processing? |
| 13:54 | dhea | i've add a (:import (processing.core PGraphicsJava2D)) |
| 13:54 | dhea | yes, simple.clj |
| 13:55 | dhea | the swing frame is up and running, its only when the (.init p5-applet) line is called |
| 13:55 | hoeck | mhh, maybe better adding the jars to the clojure-swank-extra-classpaths or into ~/.clojure/ |
| 13:56 | dhea | jars in ~/.clojure are auto added to classpath? |
| 13:57 | hoeck | yes, by default, swank-clojure builts a list of all jars from ~/.clojure/ |
| 13:58 | hoeck | or you do [m-x] customize-variable [ret] swank-clojure-extra-classpaths |
| 13:59 | hoeck | but you must to restart emacs after resetting the classpath |
| 13:59 | dhea | yup, that did it |
| 14:00 | dhea | excellent |
| 14:00 | dhea | thank you sven hoeck |
| 14:02 | lisppaste8 | hoeck pasted "swank-clojure-cmd-update-classpath" at http://paste.lisp.org/display/77591 |
| 14:02 | hoeck | np, or use ^^^ that function instead of restarting emacs |
| 14:03 | hoeck | btw, for processing, the P3D renderer is much faster (for me) than the default P2D |
| 14:13 | antifuchs | haha, the wikispaces.com guys deny that clojure.com is hosted by them... should I be worried? (-: |
| 14:13 | Chouser_ | clojure.org? |
| 14:14 | antifuchs | erm, yeah |
| 14:14 | antifuchs | mistypo'd (: |
| 14:14 | Chouser_ | well, I guess it redirects |
| 14:16 | cads | may I load a jar into the classpath from inside the repl? |
| 14:16 | antifuchs | it's probably just a little misunderstanding, but I'm amused that their helpdesk guy would point me to a page that has their email prominently displayed (-: |
| 14:17 | hiredman | cads: there is add-classpath but it is not reliable |
| 14:18 | antifuchs | is there a rule for when add-classpath will work or not? |
| 14:22 | cads | thanks hiredman, I'll try it out |
| 14:24 | cemerick | antifuchs: short of having control over your classloader (moreso than you get from java's boot classloader), I think it's generally best to assume that add-classpath will never work. |
| 14:24 | antifuchs | good to know. thanks |
| 14:24 | cemerick | if you have stuff in a jar, there's no reason to not simply include it in your classpath. |
| 14:24 | antifuchs | right |
| 14:25 | hiredman | cconstantine has the highest non bot url count |
| 14:25 | cemerick | if you want to be able to hot-deploy clojure code that depends on a new jar, then set up your deployment environment so that the classpath points at a directory, and unzip your jar(s) into that directory before attempting to load them from your (completely dynamically loadable) clojure. |
| 14:26 | cemerick | that's likely something that could be made very clean with a library, but I don't think anyone's bothered with such a mechanism yet. |
| 14:27 | cconstantine | hiredman: hu? |
| 14:29 | hiredman | cconstantine: for the channel, the only nick that has pasted more urls then you is lisppaste8 |
| 14:29 | hiredman | (this is only in the last week or so) |
| 14:30 | cconstantine | ah |
| 15:25 | lisppaste8 | slashus2 pasted "with-out-file" at http://paste.lisp.org/display/77597 |
| 15:28 | slashus2 | Accidentally hit enter when trying to format it :-( |
| 15:28 | slashus2 | Would it be good practice to make the boolean-append to be optional? |
| 15:31 | Chouser_ | maybe an optional :append flag? maybe put it before the filename? |
| 15:39 | Chouser_ | pop quiz: what does the following return? (no fair trying it out): (binding [* '+] (* '{1 / - * + 6})) |
| 15:39 | gnuvince | probably an error? |
| 15:39 | gnuvince | You can't call a symbol |
| 15:40 | kotarak | I would think so, too. |
| 15:40 | hiredman | fools |
| 15:40 | hiredman | + |
| 15:40 | Raynes | I'll go with Error. |
| 15:40 | gnuvince | oh |
| 15:40 | cemerick | hrm |
| 15:40 | hiredman | you can call a symbol |
| 15:40 | kotarak | Symbols are functions of maps? |
| 15:40 | gnuvince | ,(ifn? 'foo) |
| 15:40 | clojurebot | true |
| 15:40 | hiredman | just like a keyword |
| 15:40 | Raynes | It returns 6. |
| 15:40 | gnuvince | 6 then? |
| 15:40 | Raynes | >_> |
| 15:41 | hiredman | fine |
| 15:41 | Chouser_ | 6 it is. |
| 15:41 | Chouser_ | now wasn't that fun? |
| 15:41 | cemerick | Chouser_: that could be a regular blog series for you :-P |
| 15:41 | gnuvince | Pop quiz: what does this do: zip.ap fmap.(id &&& wtf) |
| 15:42 | Raynes | gnuvince: Eats my kittehs. |
| 15:45 | kotarak | The depths of undocumented features... |
| 15:47 | gnuvince | What's undocumented? |
| 15:47 | Raynes | Why are virtually all twitter clients built on AIR? |
| 15:48 | Raynes | :| |
| 15:48 | Raynes | I don't like AIR. |
| 15:48 | Raynes | It's too AIRy. |
| 15:48 | slashus2 | plus is assigned 6, but since the symbol plus is bound to * retrieving * is actually retrieving '+ from the map. |
| 15:48 | kotarak | gnuvince: I think that Symbols are callable. I only knew for keywords. |
| 15:48 | kotarak | gnuvince: or did I miss that on the api page? |
| 15:49 | hiredman | http://clojure.org/data_structures <-- under Symbols |
| 15:49 | gnuvince | Yeah they are |
| 15:50 | gnuvince | I was confusing with the fact that lists are not callable |
| 15:50 | gnuvince | ,(ifn? ()) |
| 15:50 | clojurebot | false |
| 15:50 | kotarak | Hmm... I should reread that from time to time. |
| 15:50 | hiredman | clojurebot: symbols? |
| 15:50 | clojurebot | It's greek to me. |
| 15:50 | hiredman | clojurebot: symbols is <reply>http://clojure.org/data_structures#toc10 |
| 15:50 | clojurebot | Alles klar |
| 15:51 | slashus2 | ,(ifn? '+) |
| 15:51 | clojurebot | true |
| 15:51 | hiredman | ,(ifn? +) |
| 15:51 | clojurebot | true |
| 15:51 | slashus2 | ,(ifn? 'a) |
| 15:51 | clojurebot | true |
| 15:52 | Chouser_ | ,(ifn? #'+) |
| 15:52 | clojurebot | true |
| 15:52 | Chouser_ | ,(#'+ 2 4) |
| 15:52 | clojurebot | 6 |
| 15:52 | Chouser_ | ,(@#'+ 2 4) |
| 15:52 | clojurebot | 6 |
| 15:52 | hiredman | ,(class +) |
| 15:52 | clojurebot | clojure.core$_PLUS___3313 |
| 15:53 | hiredman | bah |
| 15:53 | hiredman | ,(class #'+) |
| 15:53 | clojurebot | clojure.lang.Var |
| 15:53 | Chouser_ | ,(class @#'+) |
| 15:53 | clojurebot | clojure.core$_PLUS___3313 |
| 15:53 | hiredman | ,(map #(.getName %) (.getMethods clojure.lang.Var)) |
| 15:53 | clojurebot | ("applyTo" "call" "alter" "bindRoot" "pushThreadBindings" "popThreadBindings" "setTag" "setMeta" "setMacro" "isMacro" "fn" "internPrivate" "setValidator" "doSet" "hasRoot" "unbindRoot" "commuteRoot" "alterRoot" "releaseThreadBindings" "invoke" "invoke" "invoke" "invoke" "invoke" "invoke" "invoke" "invoke" "invoke" "invoke" "invoke" "invoke" "invoke" "invoke" "invoke" "invoke" "invoke" "invoke" "invoke" "invoke" "invoke" " |
| 15:56 | slashus2 | ,@#'*ns* |
| 15:56 | clojurebot | #<Namespace sandbox> |
| 17:44 | lisppaste8 | rich_holygoat pasted "Confusing sort behavior" at http://paste.lisp.org/display/77605 |
| 17:45 | rich_holygoat | could someone more experienced than I comment on this apparently-odd behavior of sort on a map? |
| 17:45 | rich_holygoat | the default comparator sorts just fine, but explicitly specifying a comparator does not. |
| 17:45 | rich_holygoat | this is with r1337. |
| 17:46 | stuhood | rich_holygoat: the comparator would need to accept Map.Entry |
| 17:46 | stuhood | i think |
| 17:46 | kotarak | The map is turned into sequence of map entries. Obviously the Comparator expects a String => Failure. (at least the is my understanding of the error messages) |
| 17:46 | kotarak | Maybe you want a sorted-map? |
| 17:47 | rich_holygoat | ah yes, and the ordinary sort actually calls compare on the map entries |
| 17:47 | rich_holygoat | kotarak: apparently I do :) |
| 17:48 | rich_holygoat | is there literal syntax for a sorted map, or a function to turn an associate thing into one without having to pass the contents as args to sorted-map? |
| 17:48 | rich_holygoat | s/associate/associative |
| 17:49 | hiredman | ,(class (into (sorted-map) {:a 1 :b 2})) |
| 17:49 | clojurebot | clojure.lang.PersistentTreeMap |
| 17:49 | kotarak | (into (sorted-map) a-normal-map) |
| 17:49 | rich_holygoat | ah, thank you folks |
| 18:41 | stuhood | ~def into |
| 18:42 | stuhood | ~def c.l.PersistentTreeMap |
| 19:34 | cconstantine | ~def union |
| 19:36 | cconstantine | So, how is into different from union... from a caller's perspective? |
| 19:38 | hiredman | ,(doc clojure.set/union) |
| 19:38 | hiredman | clojurebot: ping? |
| 19:38 | cmvkk | sudden death |
| 19:38 | clojurebot | "([] [s1] [s1 s2] [s1 s2 & sets]); Return a set that is the union of the input sets" |
| 19:38 | clojurebot | PONG! |
| 19:39 | sohail | the JVM was collecting garbage |
| 19:39 | antifuchs | there can be a lot of that on irc channels (: |
| 19:51 | antifuchs | yes, hello sohail (: |
| 19:52 | cconstantine | Gotta love seeing java take 200+% CPU |
| 21:11 | cconstantine | ~def time |
| 22:06 | cconstantine | I'm making a macro, and I"m using '"`" to quote a block, how do I get a sub-expression to unquote and execute at macro-expand time? |
| 22:07 | Chouser | ~ |
| 22:07 | clojurebot | rest never returns a unicorn |
| 22:07 | Chouser | ha! |
| 22:10 | cconstantine | thanks |
| 22:11 | cconstantine | grr, it appears to work in macroexpand.. and doesn't when I make the call |
| 22:13 | cconstantine | ,(defmacro foo [expr] `([ ~expr ~(str expr)])) (macroexpand '(foo asdf)) |
| 22:13 | clojurebot | DENIED |
| 22:14 | durka42 | when you do (foo asdf) it says unable to resolve asdf, which is true |
| 22:14 | durka42 | ([asdf "asdf"]) isn't going to work |
| 22:14 | cmvkk | you're beter of doing `([ ~expr (str ~expr)]) |
| 22:17 | cconstantine | bah, getting the right "layer" of macro execution is hard |
| 22:17 | cmvkk | it is slightly annoying because you can't do macros that require the value of the arguments passed to them; |
| 22:18 | cmvkk | since those values aren't available at compile-time. in common lisp you could do it that way i'm pretty sure |
| 22:18 | cmvkk | because in CL there's no distinction between compile time and run time, etc.. |
| 22:19 | cconstantine | cmvkk: there is... I just want the expression as a string, and the expression and is confusing |
| 22:20 | cmvkk | oh i see. you don't want the value, you just want the string of the expression itself. |
| 22:20 | cconstantine | right |
| 22:21 | cconstantine | I'm writing a macro that records runtimes for expressions to a global map of accumulcated time-to-execute |
| 22:23 | cmvkk | (def(defmacro foo [expr] vector ~expr ~(str expr))) |
| 22:23 | cmvkk | err, ignore the first 4 characters |
| 22:23 | cmvkk | and it's missing `( |
| 22:23 | cmvkk | darn you 'screen' |
| 22:24 | cconstantine | hehe |
| 22:24 | cmvkk | that should do it though, the problem i was getting was that you were expanding to a vector inside a list...meaning it was trying to call the vector |
| 22:25 | cmvkk | ....and i now see that durka42 already explained this. |
| 22:32 | cconstantine | so I'm doing my first sync, and ref-set inside my first macro... yay fun tim! |
| 22:32 | cconstantine | time |
| 22:33 | Chouser | :-) |
| 22:34 | cconstantine | i wanted ~(str expr) |
| 22:35 | cmvkk | ~(str expr) works, right? |
| 22:36 | cconstantine | yeah |
| 22:36 | cconstantine | I did (str ~expr) at first and got a string of the result |
| 22:36 | cconstantine | which for :a was the same ;) |
| 22:38 | cconstantine | now I have a macro (with-timing [expr]) that will return the result of expr, and accumulate time-to-execute and store it in a map keyed off the expr as a string |
| 22:39 | cmvkk | out of curiosity, how do you store the time to execute? i know (time ...) prints it out but... |
| 22:39 | lisppaste8 | cconstantine pasted "with-timing" at http://paste.lisp.org/display/77615 |
| 22:40 | lisppaste8 | cconstantine annotated #77615 "untitled" at http://paste.lisp.org/display/77615#1 |
| 22:40 | cconstantine | that's stolen from the implementation of the 'time' macro |
| 22:41 | durka42 | did you also write time-val |
| 22:41 | durka42 | also, (sync nil ==> (dosync |
| 22:41 | cmvkk | is there any different currently between sync and dosync-- |
| 22:41 | cconstantine | oh right! |
| 22:41 | cmvkk | you read my mind |
| 22:42 | durka42 | cmvkk: what i said is the definition of dosync |
| 22:42 | lisppaste8 | cconstantine annotated #77615 "time-val" at http://paste.lisp.org/display/77615#2 |
| 22:43 | cconstantine | yeah... I'm always suspicious when an API doc says "just pass null/nil for this argument"... or when str-tok's docs say "don't use this" |
| 22:43 | cmvkk | one day, though, there might be flags for sync |
| 22:43 | cconstantine | I know, but in the meantime it raises flags for me ;) |
| 22:44 | durka42 | "reserved for future use" means i can use that field for my own app-specific settings, right? ;) |
| 22:44 | cconstantine | lol |
| 22:45 | cconstantine | so, I would love for this to make it into clojure... is it reasonable to have that global reference to a map? |
| 22:45 | cconstantine | or would it be better form to make some kind of structure that needs to be passed in? |
| 22:46 | durka42 | global variables, two thubs down |
| 22:46 | durka42 | thumbs |
| 22:47 | durka42 | i dunno, carrying the structure around sounds unwieldy though |
| 22:47 | Chouser | you mean like *out*, *err*, *warn-on-reflection*, etc? |
| 22:47 | cconstantine | yeah |
| 22:47 | durka42 | this macro smells like the beginning of a profiler library |
| 22:47 | cconstantine | part of hte problem is that timings are kind of intrinsically a side-effect |
| 22:47 | cconstantine | durka42: yes |
| 22:48 | cconstantine | durka42: with that raw data (or better data) you could get hings like average runtime, number of execs, max, min, yada yada |
| 22:48 | durka42 | that would be cool |
| 22:49 | cconstantine | on any form... not just functions (which I'm assuming all the java-level profilers limit you too) |
| 22:49 | durka42 | then you'd have clojure.contrib.timings/*all-timings* which sounds more reasonable |
| 22:49 | cconstantine | I'm a programmer by trade... so I understand how hurtful bad code can be to a code-base. |
| 22:50 | cconstantine | hell, I suffered through a 3 hour code review of stuff that was forced to be terrible by the terrible APIs it had to work with.... |
| 22:50 | cconstantine | today |
| 22:50 | cmvkk | do most of the people in here program professionally, I wonder |
| 22:50 | durka42 | i don't |
| 22:50 | durka42 | not yet anyway |
| 22:51 | cconstantine | hehe |
| 22:51 | cmvkk | me neither |
| 22:51 | cconstantine | I'm threatening to rewrite our testing framework in clojure :) |
| 22:51 | cconstantine | No one there knows it, but the current java framework is pretty bad |
| 22:51 | cconstantine | *it == clojure |
| 22:52 | cconstantine | ah... clojure.contrib.timings... that would mean I'd need to learn namespaces :/ |
| 22:53 | durka42 | they're like java packages |
| 22:53 | durka42 | correspond to folders |
| 22:53 | cconstantine | packages... I know what folders are *bush* |
| 22:53 | cconstantine | *blush* |
| 22:53 | cmvkk | I get namespaces but I totally don't understand all this classpath stuff |
| 22:54 | cmvkk | what annoys me is if I load a file with load-file, and that file defines a namespace, then i try to (use ...) that namespace |
| 22:54 | cmvkk | it doesn't work if the file isn't in the classpath. |
| 22:54 | cconstantine | hehe |
| 22:54 | durka42 | right because use goes straight for the file |
| 22:54 | durka42 | not that that's logical... |
| 22:54 | cconstantine | (use ...) tries to find the compiled clojure/java stuff? |
| 22:55 | durka42 | if the files defines a namespace isn't it already used |
| 22:55 | cmvkk | I guess. |
| 22:55 | cmvkk | well it would be loading a file with a different namespace than the one i'm in already. |
| 22:55 | cmvkk | then what i really want to do is refer everything. |
| 22:57 | Chouser | if you loaded it with load-file, you can bring the symbols into your namespace with refer |
| 22:57 | Chouser | (doc refer) |
| 22:57 | clojurebot | refers to all public vars of ns, subject to filters. filters can include at most one each of: :exclude list-of-symbols :only list-of-symbols :rename map-of-fromsymbol-tosymbol For each public interned var in the namespace named by the symbol, adds a mapping from the name of the var to the var to the current namespace. Throws an exception if name is already mapped to something else in the current namespace. Filters can be |
| 22:57 | cmvkk | so something like (load-file "bar-namespace.clj") (ns foo) (refer bar) |
| 22:58 | Chouser | I suppose. |
| 22:59 | Chouser | you've got essentially different levels of api |
| 22:59 | cmvkk | i know it's the wrong way to do things, i don't actually do it that way. |
| 22:59 | cmvkk | but the fact of the matter is, i often know where my other files are much better than i know what the classpath is. |
| 23:00 | cmvkk | i like a system where all I need to know is where the other code is, rather than knowing what the classpath is. |
| 23:00 | Chouser | load-file works on files directly and in-ns and refer work on namespaces directly |
| 23:01 | Chouser | ns, use, and require work on "libs" which are an abstraction that combine files and namespaces. |
| 23:03 | duderdo | What's the equivalent to 'assoc' from cl in clojure? |
| 23:03 | cmvkk | assoc |
| 23:04 | duderdo | really? Hm |
| 23:04 | cmvkk | ,(doc assoc) |
| 23:04 | clojurebot | "([map key val] [map key val & kvs]); assoc[iate]. When applied to a map, returns a new map of the same (hashed/sorted) type, that contains the mapping of key(s) to val(s). When applied to a vector, returns a new vector that contains val at index. Note - index must be <= (count vector)." |
| 23:04 | cmvkk | (assoc [1 2 3] 1 4) |
| 23:04 | durka42 | no, CL's assoc is "get" |
| 23:05 | durka42 | http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/fun_assoccm_a_assoc-if-not.html |
| 23:05 | cmvkk | ohh yeah. |
| 23:05 | duderdo | ah that's what I thought |
| 23:05 | durka42 | maps are callable too |
| 23:05 | duderdo | thanks. |
| 23:05 | durka42 | ,({:a 1 :b 2} :a) |
| 23:05 | clojurebot | 1 |
| 23:05 | durka42 | ,(:b {:a 1 :b 2}) |
| 23:05 | clojurebot | 2 |
| 23:05 | cmvkk | i can't believe i've forgotten that much about CL already |
| 23:06 | duderdo | I'm trying forget, I keep getting mixed up |
| 23:07 | Chouser | you already forgot "to", so you're well on your way. |
| 23:09 | duderdo | heh |
| 23:11 | Chouser | :-) |
| 23:14 | duderdo | How can I make a keyword from a string? Is this possible? |
| 23:14 | durka42 | ,(keyword "boo") |
| 23:14 | clojurebot | :boo |
| 23:14 | duderdo | Sweet |
| 23:15 | duderdo | Thanks guys. night. |
| 23:15 | cconstantine | ooo with a rich programmable timing infrastructure you could make something that takes a set of expressions that implement the same functionality and do automatic detection of fastest algorithm/source (like, an expression for each server to issue requests to, and it could choose the server that's tending to respond faster) |
| 23:16 | durka42 | that would be really cool |
| 23:16 | cconstantine | or the parallel/non-parallel algorithms |
| 23:19 | durka42 | (defmacro halts? [expr] `(= Double/POSITIVE_INFINITY (time-val ~expr)) |
| 23:19 | durka42 | i mean |
| 23:19 | durka42 | (defmacro halts? [expr] `(< Double/POSITIVE_INFINITY (time-val ~expr)) |
| 23:19 | durka42 | no still backwards |
| 23:19 | durka42 | failed joke :( |
| 23:20 | cconstantine | (defmacro halts? [expr] `(> Double/POSITIVE_INFINITY (first (rest (time-val ~expr))))) |
| 23:20 | cconstantine | there ya go :) |
| 23:21 | durka42 | frest |
| 23:21 | durka42 | also that macro might need some optimization :) |
| 23:21 | Chouser | fnext |
| 23:21 | durka42 | oh yeah that |
| 23:21 | cconstantine | and should probably return the value of ~expr |
| 23:22 | cconstantine | but I get it... if it's runtime is less that positive infinity it halted |
| 23:22 | cconstantine | oh right, returns a bool |
| 23:23 | cconstantine | didn't halt... bah |
| 23:25 | cconstantine | ahh, the halting problem |
| 23:25 | cconstantine | someone at work today claimed they had a turing complete language that had solved it. |
| 23:25 | cconstantine | shockingly they were mistaken |
| 23:26 | durka42 | (defmacro does-halt [expr] `(if (halts? ~expr) (loop [] (recur)) "Logical fallacy complete.")) |
| 23:27 | durka42 | http://www.reddit.com/r/programming/comments/6wamg/the_terminator_project_taking_on_the_halting/ |
| 23:27 | cconstantine | that reminds me of using exec() in C... exec( ...); exit(1); |
| 23:29 | cconstantine | ie, if exec() returns, you have a problem. |