2009-06-21
| 00:11 | durka42 | has anyone seen this while compiling clojure? |
| 00:11 | durka42 | [java] Compiling clojure.inspector to /Users/alex/Programming/clojure/classes |
| 00:11 | durka42 | [java] java.security.AccessControlException: access denied (java.lang.RuntimePermission modifyThread) |
| 00:46 | slashus2 | durka42: Are you running it inside of a sandbox? |
| 00:54 | durka42 | slashus2: no, just did a git pull |
| 02:35 | stuhood | it's hard to run in a sandbox. or on a beach |
| 02:36 | slashus2 | stuhood: The sand kind of gives when you run. |
| 04:46 | samuels | stuhood: are you stewart holloway |
| 04:46 | stuhood | samuels: sorry, no: his nick is stuarthalloway i believe |
| 04:46 | stuhood | ~seen stuarthalloway |
| 04:46 | clojurebot | stuarthalloway was last seen quiting IRC, 2134 minutes ago |
| 04:47 | stuhood | yea, that's him. |
| 04:47 | samuels | ~2134/60 |
| 04:47 | clojurebot | No entiendo |
| 04:48 | samuels | ~(/ 2134 60) |
| 04:48 | clojurebot | Excuse me? |
| 04:48 | stuhood | samuels: close |
| 04:48 | stuhood | ,(/ 2134 60) |
| 04:48 | clojurebot | 1067/30 |
| 04:48 | samuels | ... |
| 04:48 | samuels | ,(/ 2134 60.0) |
| 04:48 | clojurebot | 35.56666666666667 |
| 04:48 | samuels | ah ok |
| 04:48 | samuels | thx |
| 04:48 | stuhood | samuels: ratios =) |
| 04:49 | samuels | that's a weird aspect to clojure dont you agree |
| 04:49 | samuels | i mean wtf needs ratios? |
| 04:49 | samuels | (the wtf in the preceding sentence meaning 'who the f*ck' not 'what the f*ck' ) |
| 04:50 | stuhood | samuels: not me, heh... but floating point can be difficult to get right, so anytime you can avoid it, you're better off |
| 04:50 | stuhood | wrt accuracy |
| 04:50 | samuels | yeah |
| 04:50 | samuels | stuhood: do you know if clojure will be getting compile time type checking any time soon? |
| 04:51 | kotarak | maybe people needing exact numbers, eg. currency or so? |
| 04:51 | samuels | and do you konw of any lisp flavours that currently support it? |
| 04:51 | kotarak | 1) probably not, 2) Qi |
| 04:52 | stuhood | samuels: what he said... but people (Chouser?) are doing work in the area of types, to basically do automatic type hinting based on your imports |
| 04:53 | stuhood | so it seems like a logical next step would be to think about enforcement |
| 04:53 | samuels | yeah |
| 04:54 | samuels | stuhood: what editor do you use for your clojur code? |
| 04:55 | stuhood | samuels: vim, with an old version of VimClojure |
| 04:55 | samuels | oh ok |
| 04:55 | samuels | stuhood: do you know if SLIME works with clojure? |
| 04:55 | samuels | and if it's easy enough to setup? |
| 04:56 | stuhood | i believe so |
| 04:56 | samuels | great |
| 04:56 | stuhood | http://en.wikibooks.org/wiki/Clojure_Programming/Getting_Started#Emacs_.2F_Slime_.2F_Clojure_on_Ubuntu_-_Tutorial |
| 05:02 | samuels | thanks |
| 05:02 | samuels | stuhood: you dont like emacs? |
| 05:03 | stuhood | heh... never tried it |
| 05:03 | samuels | it's pretty c00l man |
| 05:03 | samuels | pr3tty* |
| 05:08 | stuhood | i probably haven't switched because i'm dumb enough to be up at 5am |
| 05:08 | stuhood | g'night! =) |
| 05:09 | samuels | night man!! |
| 10:10 | Chousuke | hmm, nobody has bothered to move old issues from contrib to assembla I see |
| 10:10 | Chousuke | wonder if it's worth it. :/ |
| 10:14 | durka42 | i got another permissions exception trying to compile contrib.zip-filter.xml |
| 10:25 | durka42 | so the problem is, clojure and contrib now require java 6 to compile! |
| 10:29 | durka42 | does anyone know of a good rss reader that can give me a threaded view of the clojure-dev messages? |
| 10:37 | Chousuke | hm |
| 10:59 | lenst | java version "1.5.0_19" works for me |
| 11:13 | durka42 | lenst: interesting, that was the one that threw exceptions for me. what OS? |
| 11:41 | krumholt | what is the most used ide with clojure? |
| 11:44 | Chouser | krumholt: my guess would be emacs, but I'm not sure. I don't use any. |
| 11:47 | rys | Netbeans seems pretty popular from the mailing list |
| 11:47 | hoeck | krumholt: I would say emacs + slime, because many of the early clojure adopters had some lisp background |
| 11:53 | krumholt | ok thanks |
| 12:17 | Chouser | rhickey: can we have a milestore or something for 1.0-bugfix? |
| 12:33 | durka42 | are any of the ticket comments going to be transferred from GC to Assembla? |
| 12:34 | Chousuke | not as comments |
| 12:34 | Chousuke | they are included in the description |
| 12:35 | Chousuke | but I wonder if someone's going to bother moving contrib issues :P |
| 12:35 | Chousuke | should be okay to ignore the closed ones. |
| 12:36 | durka42 | there is only one then :) |
| 12:36 | durka42 | ~ticket #3 |
| 12:36 | Chousuke | yeah. |
| 12:36 | clojurebot | {:url http://tinyurl.com/mewy4h, :summary "Test ticket", :status :invalid, :priority :normal, :created-on "2009-06-16T19:25:19+00:00"} |
| 12:37 | durka42 | just for fun |
| 12:39 | Chousuke | durka42: you'd have to parse google's web pages to do it :P |
| 12:39 | durka42 | well, maybe |
| 12:39 | durka42 | http://code.google.com/p/clojure-contrib/issues/csv?can=1&q=&colspec=ID%20Type%20Status%20Priority%20Milestone%20Owner%20Summary |
| 12:40 | Chousuke | durka42: you'd still need to manually get the comments and patches though :/ |
| 12:40 | durka42 | yeah, that could be a problem :p |
| 12:45 | kotarak | Do we now have a Core team? |
| 12:46 | durka42 | kotarak: bug report for you :) |
| 12:46 | kotarak | durka42: I hear. |
| 12:46 | kotarak | eh... I read.... |
| 12:46 | durka42 | *1 is broken |
| 12:48 | kotarak | durka42: I see. In the bleeding-edge branch right? |
| 12:49 | durka42 | yes |
| 12:49 | durka42 | *1, *2, and *3 are all the symbol 'user |
| 12:49 | kotarak | It's actually the namespace. |
| 12:49 | kotarak | Try (ns foo.bar) |
| 12:49 | durka42 | hmm, i see |
| 12:49 | durka42 | i do like the namespace display at the repl prompt though |
| 12:49 | kotarak | I know, what the problem is. |
| 13:21 | arasoft | Sorry, but I am at the end of Google's wit: |
| 13:21 | arasoft | What do I have to do to get this to work properly at the REPL |
| 13:21 | arasoft | (. "ä" toUpperCase ) (the String contains a lowercase "a umlaut") |
| 13:21 | arasoft | I have tried with different (and none at all) settings for file.encoding and console.encoding, but to no avail. |
| 13:21 | arasoft | Platform is WinXP with German keyboard. |
| 13:21 | gnuvince_ | ,(.toUpperCase "àé") |
| 13:21 | clojurebot | "ÀÉ" |
| 13:22 | gnuvince_ | ,(.toUpperCase "ä") |
| 13:22 | clojurebot | "Ä" |
| 13:22 | gnuvince_ | Works fine |
| 13:22 | arasoft | Not on my machine... |
| 13:22 | durka42 | Chousuke: http://code.google.com/p/support/issues/detail?id=148 |
| 13:23 | gnuvince_ | arasoft: which OS? |
| 13:24 | arasoft | WinXP English with German keyboard |
| 13:24 | gnuvince_ | arasoft: does cmd.exe input in unicode? |
| 13:29 | arasoft | I don't think so, therefore I tried -Dfile.encoding=ISO8859_1 -Dconsole.encoding=Cp1252 and others, but no luck. Even when calling a Java method that returns a hard-coded string with non-ANSI characters, the result is garbage (the specific garbage depends on the specified encodings). |
| 13:29 | arasoft | I looked at http://groups.google.com/group/clojure/browse_thread/thread/1ebe3c8f342f3abe/d0497724d342e27f and similar, but there seems to be no complete solution. |
| 13:32 | prospero_ | if I want to define a function with a name defined in a string, is there a standard way to do that? |
| 13:33 | prospero_ | I've seen an implementation that relies on "new clojure.lang.MultiFn" and defmethod, but it seems like there must be a better way |
| 13:33 | arohner | prospero_: you mean you want the name of the function to come from a string? |
| 13:33 | prospero_ | yes |
| 13:34 | arohner | one sec |
| 13:34 | maxthimus | from the book programming clojure: |
| 13:34 | maxthimus | (defn make-greeter [greeting-prefix] (fn [name] (str greeting-prefix ", " name))) |
| 13:35 | maxthimus | (def hello-greeting (make-greeter "Hello")) |
| 13:35 | maxthimus | (hello-greeting "world") |
| 13:35 | arohner | hrm, this works, but it uses eval |
| 13:36 | arohner | (eval `(defn (symbol "foo") [x] (* x x)) |
| 13:36 | prospero_ | arohner: eval is ok, I think |
| 13:36 | prospero_ | that's what I was looking for, thanks |
| 13:36 | Chousuke | you should use a macro. :/ |
| 13:37 | arohner | yeah, you can write a macro that does the same thing |
| 13:37 | Chousuke | (defmacro fn-string [name & the-rest] `(defn ~(symbol name) ~@the-rest) |
| 13:37 | arohner | Chousuke: you beat me to it |
| 13:38 | arohner | that's a better solution |
| 13:38 | prospero_ | arohner, Chousuke: thanks |
| 13:39 | arohner | hmm. macros are a controlled use of eval. that's interesting. |
| 13:39 | arohner | I never thought of it that way |
| 13:40 | Chousuke | well, kind of. |
| 13:42 | Chousuke | macros are special in that I don't think there's any other way to run code at macroexpansion (compile) time. |
| 13:43 | arohner | if I do (def foo expr...), expr gets run at compile time, right? |
| 13:44 | Chousuke | no, it's runtime. |
| 13:44 | Chousuke | otherwise, something like (def foo (+ x 1)) would not work :/ |
| 13:45 | prospero_ | so as a followup question, I was looking at this code here: http://github.com/ChickenProp/cloggle/blob/97270c0146a41dc7389a864d333cdaad7986c41b/src/net/philh/cloggle.clj |
| 13:45 | prospero_ | which reflects over the opengl libraries, and defines wrapper functions that invoke them |
| 13:46 | prospero_ | is he using that method for performance reasons? |
| 13:46 | prospero_ | I'm specifically referring to line 72 |
| 13:47 | arohner | prospero_: it's probably for readability/ to get other features |
| 13:47 | Chousuke | that seems a bit hackish |
| 13:49 | prospero_ | it doesn't seem particularly readable, but ok |
| 13:49 | Chousuke | I'm pretty sure what he's doing there should be possible with macros too |
| 13:49 | arohner | prospero_: I mean that the functions he creates are more readable than (.invoke foo opengl-context (to-array args)) |
| 13:50 | Chousuke | Depends on whether it's possible to use reflection in macros. |
| 13:51 | arohner | why wouldn't it be possible? |
| 13:51 | arohner | reflection is just a java method you call |
| 13:51 | prospero_ | arohner: certainly, but why the 1-to-1 MultiFn/defmethod approach? |
| 13:51 | prospero_ | is that functionally different than a defn somehow? |
| 13:53 | arohner | no, aside from 1) there is a dispatch fn on multifns, and 2) you can add to the multifn later |
| 13:53 | arohner | but yeah, I don't see that happening here |
| 13:53 | prospero_ | ok, extensibility seems like a fair reason |
| 13:55 | arohner | hrm, this would be easier to read in my ide |
| 13:55 | arohner | oh, I get it |
| 13:55 | Chousuke | There's probably a better way to do what cloggle does but I can't say it's obvious :/ |
| 13:55 | arohner | he either gets the existing multi-fn, or creates it if it doesn't exist |
| 13:56 | arohner | so if that gl-methods returns the same name with different arities, it will create two different methods |
| 13:56 | prospero_ | hmmm |
| 13:56 | prospero_ | that's weird, since as far as I know all opengl functions are suffixed with their parameters |
| 13:57 | prospero_ | glVertex3f, glVertex2i, etc. |
| 13:57 | Chousuke | perhaps not for the java bindings? |
| 13:57 | arohner | step 1 in fixing this would be to get rid of def-ev |
| 13:57 | prospero_ | I'm no expert, but based on my cursory look at JOGL the names of the functions are unchanged |
| 13:59 | arohner | the dispatch function is also interesting |
| 13:59 | prospero_ | in an ideal world, "vertex" would dispatch to whichever function is appropriate, based on type and arity |
| 13:59 | prospero_ | maybe he's building towards that point |
| 14:07 | emacsen | I'm redoing my clojure setup and I'n having some (what I'm guessing are) java issues |
| 14:07 | emacsen | I have my clojure jar and I have it on my classpath. |
| 14:08 | emacsen | but when I try to compile contribs, ant says it can't find clojure.jar |
| 14:08 | arohner | emacsen: does it work if you do ant -Dclojure.jar=... ? |
| 14:09 | emacsen | arohner, yes |
| 14:10 | arohner | how are you defining your classpath? |
| 14:11 | emacsen | export CLASSPATH=~/local/jars/* |
| 14:11 | arohner | the contrib build.xml appears to only pay attention to the -D flag |
| 14:11 | emacsen | okay, so that's fine, but then problem 2 |
| 14:11 | kotarak | If I remember correctly, ant doesn't pay attention to CLASSPATH. |
| 14:12 | emacsen | I run clojure thusly: java -cp $PATH_TO_CLOJURE_JAR:$PATH_TO_CONTRIB_JAR clojure.lang.Repl |
| 14:12 | emacsen | for the repl, obviously |
| 14:12 | emacsen | but: user=> (:use clojure.contrib.shell-out) |
| 14:12 | emacsen | java.lang.ClassNotFoundException: clojure.contrib.shell-out (NO_SOURCE_FILE:1) |
| 14:12 | clojurebot | ☕ |
| 14:13 | emacsen | contrib fail |
| 14:14 | arohner | hrm, shell-out isn't in my build.xml |
| 14:14 | emacsen | the keyboard cat is coming to watch me :) |
| 14:15 | emacsen | ah, lemme check mine |
| 14:15 | arohner | in that big list of arg value="clojure.contrib.foo", around line 100 |
| 14:15 | arohner | try adding it and recompiling |
| 14:16 | emacsen | it's in mine |
| 14:16 | emacsen | in the <sysproperty key="clojure.compile.path" value="${build}"/> |
| 14:16 | arohner | yeah |
| 14:17 | emacsen | yeah it's there already |
| 14:18 | arohner | did you type (:use clojure.contrib.shell-out) at the repl, or was it part of an ns declaration? |
| 14:18 | emacsen | in the repl |
| 14:18 | arohner | ah, yeah that won't work |
| 14:18 | arohner | (use 'clojure.contrib.shell-out) |
| 14:18 | arohner | or (ns my.package (:use clojure.contrib.shell-out)) |
| 14:18 | arohner | that's kind of confusing |
| 14:19 | emacsen | user=> (use 'clojure.contrib.shell-out) |
| 14:19 | emacsen | java.lang.NoSuchMethodError: clojure.lang.Namespace.importClass(Ljava/lang/Class;)Ljava/lang/Class; (NO_SOURCE_FILE:0) |
| 14:20 | arohner | hrm, that works for me |
| 14:23 | arohner | I don't know how to recreate that error message |
| 14:23 | emacsen | :-/ |
| 14:23 | emacsen | I don't know how not to ;) |
| 14:23 | emacsen | what's your clojure java command line? |
| 14:24 | arohner | I just copied what you did. java -cp jars/clojure.jar:jars/clojure-contrib.jar clojure.lang.Repl |
| 14:25 | arohner | java -cp jars/clojure.jar:jars/clojure-contrib.jar clojure.lang.Repl |
| 14:25 | arohner | Clojure 1.1.0-alpha-SNAPSHOT |
| 14:25 | arohner | user=> (use 'clojure.contrib.shell-out) |
| 14:25 | arohner | nil |
| 14:25 | arohner | user=> (sh "hostname") |
| 14:25 | arohner | "kjata.earthlink.net\n" |
| 14:26 | emacsen | it fails for me |
| 14:26 | clojurebot | for is not a loop |
| 14:26 | emacsen | *sigh* |
| 14:27 | arohner | what version of clojure are you using? |
| 14:27 | emacsen | 1.0.0 |
| 14:27 | arohner | so you downloaded the tarball, as opposed to svn or git? |
| 14:27 | emacsen | I forget |
| 14:28 | emacsen | svn |
| 14:28 | arohner | and where did you get contrib from? |
| 14:28 | emacsen | svn |
| 14:29 | emacsen | http://clojure-contrib.googlecode.com/svn |
| 14:30 | arohner | I would get the latest version of both from git, and make sure the clojure.jar you compile against is the same one you use at runtime |
| 14:30 | arohner | clojurebot: git |
| 14:30 | clojurebot | git is http://www.github.com |
| 14:30 | arohner | that's not useful, clojurebot |
| 14:31 | arohner | http://github.com/richhickey/clojure/tree/master |
| 14:31 | arohner | http://github.com/richhickey/clojure-contrib/tree/master |
| 14:31 | emacsen | I found the git version of clojure to be unstable |
| 14:32 | arohner | unstable how? |
| 14:32 | emacsen | does git clojure-contrib track git clojure |
| 14:32 | emacsen | I forget |
| 14:32 | emacsen | but it broke for me one time |
| 14:32 | arohner | yes, they track |
| 14:50 | Lau_of_DK | Question - Ive got a plain-text file on my system, (count (slurp file)) = 1064, (.length (File. file)) = 1078 - Why ? |
| 14:50 | Chousuke | Lau_of_DK: maybe its length as characters is not the same as its length in bytes? |
| 14:51 | opqdonut | which would be the case with for example UTF-8 encoding |
| 14:51 | Lau_of_DK | How could thei differ when its plain text ? |
| 14:51 | Chousuke | Lau_of_DK: for example, if you have double-byte characters in it. |
| 14:51 | opqdonut | s/would/might/ |
| 14:51 | Lau_of_DK | s/thei/they |
| 14:51 | Chousuke | Lau_of_DK: well, any non-ascii might be double-byte |
| 14:51 | Lau_of_DK | alright - I didnt think that occured with plain text files, but I understand that it would naturally be the cause of the problem |
| 15:20 | arohner | Lau_of_DK: are you on windows? |
| 15:28 | Lau_of_DK | Of course not :) |
| 15:28 | arohner | not everyone is so enlightened. :-) I was wondering if \r\n's accounted for your discrepancy |
| 15:30 | Lau_of_DK | That might actually be it, I got this from a windows system, and FTP downloaded it, in that process they migt have been stripped |
| 15:30 | Lau_of_DK | I think its 1 bytes per linie |
| 17:03 | arohner | danlarkin: how do you get clojure-json to print a json symbol? |
| 17:03 | arohner | i.e. prototype requires "new Ajax.Request(url, {method: 'get',..." |
| 17:04 | arohner | and if I try to use clojure-json, I end up with {"method":"get" rather than {method:"get" |
| 17:07 | Lau_of_DK | I have a clojure program which downloads a couple of files and then parses them. when I run it from the repl, this is a 1 second job, when I run it from command line like "java -cp clojure.jar clojure.lang.Script dl.clj" it takes forever... Its coming up on 5 minutes now and still now result...? |
| 17:10 | Chouser | do you use agents or pmap? |
| 17:13 | Lau_of_DK | Single threaded |
| 17:15 | Chouser | Lau_of_DK: I guess I'd either attach a debugger and break it after a couple seconds to see where it's spending it's time, or... |
| 17:15 | Chouser | sprinkle some println's around to see how far its getting. |
| 17:16 | Lau_of_DK | I've already wrapped the calls in a debug macro, and it gets a list of filenames from the server which works fine, then those names are mapped to download-file, and that doesnt even begin |
| 17:17 | Lau_of_DK | (map #(do |
| 17:17 | Lau_of_DK | (debug "Download message" "OK" (download-message %)) %) |
| 17:17 | Lau_of_DK | (debug "Retrieving list of messages" "OK" (get-messages)))) |
| 17:17 | Lau_of_DK | Sun Jun 21 23:18:10 CEST 2009: Retrieving list of messages |
| 17:17 | Lau_of_DK | Sun Jun 21 23:18:10 CEST 2009: OK |
| 17:18 | prospero_ | a few hours ago I asked about defining a function whose name was passed in as a string |
| 17:18 | prospero_ | and was told that the best solution was (defmacro fn-string [name & rest] `(defn ~(symbol name) ~@rest)) |
| 17:18 | Lau_of_DK | Its interesting, that when run from the REPL, the "Retrieving list of messages" message is never printed, the "Downloading message" is however....?! |
| 17:18 | prospero_ | which is great if I try (fn-string "square" [x] (* x x)) |
| 17:18 | Lau_of_DK | (and the opposite is true when run from commandline) |
| 17:18 | prospero_ | but if I try (def sqr "square") |
| 17:19 | prospero_ | and then (fn-string sqr [x] (* x x)) |
| 17:19 | prospero_ | it will create a function called sqr rather than "square" |
| 17:19 | prospero_ | I'm assuming there's something kind of basic about macros I'm missing here |
| 17:19 | prospero_ | but have no idea what it is |
| 17:20 | opqdonut | you need to eval the first arg |
| 17:21 | Chousuke | prospero_: macros can't depend on runtime arguments. |
| 17:21 | opqdonut | that is, name |
| 17:21 | opqdonut | ah, yeah, in case of def the name needs to be known beforehand |
| 17:21 | prospero_ | Chousuke: so would eval be the only way to accomplish what I'm trying to do? |
| 17:22 | Chousuke | you want to def functions based on some strings you read at runtime? |
| 17:22 | prospero_ | basically |
| 17:22 | Chousuke | are you sure you need global defs? :/ |
| 17:23 | Chousuke | couldn't you just generate a bunch of functions in a map or something? |
| 17:23 | Lau_of_DK | Before we drift too far off (my) topic - Can anybody enlighten me as do why clojure.lang.Repl and clojure.lang.Script seemingly executed clj's differently ? |
| 17:23 | prospero_ | would that lend itself to a better solution? |
| 17:24 | prospero_ | oh, by creating anonymous functions |
| 17:24 | prospero_ | right |
| 17:24 | Chousuke | yeah, in a map of strings to functions |
| 17:24 | prospero_ | well, I could do that |
| 17:25 | prospero_ | mostly I just wanted to mess around with opengl and cloggle seemed a bit creaky |
| 17:25 | Chousuke | the problem with generating global definitions is that you can't use them anyway unless you know that they're going to be there. |
| 17:26 | prospero_ | right |
| 17:26 | prospero_ | I don't know if it's the best solution |
| 17:27 | prospero_ | I'm mostly doing this because I'm trying to learn about macros and reflection in java |
| 17:27 | Chousuke | cloggle generates bindings, which I guess is one legit reason to generate global defs at runtime, but, you should be able to accomplish the same thing if you do the reflection in a macro and generate the necessary code based on the info you get from the reflection |
| 17:27 | Chousuke | it'll be a complex macro though |
| 17:27 | prospero_ | but I think there's some merit to having named functions that are bindings to the java libs |
| 17:28 | prospero_ | wouldn't it just be more straightforward to do an eval, then? |
| 17:28 | Chousuke | well, that's basically emulating what the macro would do anyway |
| 17:29 | prospero_ | but the eval can depend on runtime arguments, correct? |
| 17:29 | prospero_ | or are they both limited in that respect |
| 17:29 | Chousuke | eval works with runtime stuff, yes. |
| 17:30 | Chousuke | but if you're just generating bindings, you might not need them |
| 17:30 | Chousuke | reflection should be available during macro expansion time |
| 17:30 | prospero_ | hmm |
| 17:31 | Chousuke | macros are basically functions of a lisp form to clojure code. As long as you return valid clojure code, you can do pretty much anything you want. |
| 17:31 | prospero_ | so I'd pass the macro a class, and it would do all the reflection inside |
| 17:31 | prospero_ | that could be interesting |
| 17:31 | Chousuke | you can't pass it the class itself, but you can pass it the name of a class. |
| 17:32 | Chousuke | and inside the macro, you can look up the class object using that name with reflection |
| 17:32 | Chousuke | at least, in theory. I haven't tried. :/ |
| 17:32 | prospero_ | fair enough |
| 17:33 | prospero_ | is there a really good reason to do the more complicated macro approach instead of what seems like a simpler eval approach? |
| 17:33 | Chousuke | well, if you manage to pull it off with a macro, I think at the end you would know all you need to know about creating macros :) |
| 17:34 | prospero_ | ha |
| 17:34 | prospero_ | ok, I'll give it a shot |
| 17:34 | prospero_ | thanks |
| 17:34 | kotarak | prospero_: How do you call the function w/o knowing its name in advance? |
| 17:34 | Lau_of_DK | I've figured it out - The REPL (or SLIME) forces evaluation in places where Clojure doesnt |
| 17:34 | Chousuke | besides that, I'm not convinced eval is much easier than the macro system |
| 17:35 | kotarak | ~eval |
| 17:35 | clojurebot | eval is sometimes useful - but only sometimes |
| 17:35 | kotarak | -.- |
| 17:35 | prospero_ | kotarak: I'm playing around with creating bindings to the java opengl libraries |
| 17:35 | prospero_ | so I know there's a function called "glVertex3f", for instance |
| 17:36 | prospero_ | I'm just trying to skip over some of the indirection necessary to call it, using auto-generated functions |
| 17:36 | opqdonut | you can make a macro (export glVertex3f) that expands into (def glVertex3f (something "glVertex3f")) |
| 17:36 | opqdonut | by using name etc |
| 17:36 | kotarak | prospero_: when you know the name in advance you can convert it to a symbol in advance. |
| 17:37 | Lau_of_DK | prospero_: Check out SofiaBA on Github, it seems to me some of the work youre doing, has been done |
| 17:38 | prospero_ | Lau_of_DK: will do, thanks |
| 17:39 | prospero_ | kotarak: you're totally right, I was mostly just looking at cloggle, which does what I'm describing, and thinking that there must be a more elegant way to do it |
| 17:42 | Chouser | I'd recommend doing the namespace interning at runtime, rather than trying to force evalueation at compile time. |
| 17:44 | Chousuke | prospero_: http://gist.github.com/133660 maybe this'll get you started |
| 17:44 | Chousuke | you'll need to do much more complicated reflection to get something useful but it looks like it's possible. |
| 17:45 | prospero_ | Chousuke: thanks |
| 17:49 | Lau_of_DK | When my clojure.lang.Script script has finished, the process lingers for 5 minutes - do you guys forcefully terminate your scripts somehow? |
| 17:51 | Chouser | Lau_of_DK: you're absolutely sure you're not starting a an agent somewhere? using future or something? |
| 17:51 | Lau_of_DK | 100% |
| 17:51 | Lau_of_DK | Its a very straight forward program |
| 17:52 | Lau_of_DK | Hmm - There is connection though, which is opened in a global var (kludge) , that qualifies? |
| 17:52 | Chouser | Script has only ever lingered for me if one of the agent pools gets going. |
| 17:52 | Chouser | oh, a socket connection? hm... maybe make sure it gets closed? |
| 17:52 | Lau_of_DK | lemme try |
| 17:53 | Lau_of_DK | That did it :) |
| 18:05 | Jetien | hi kotarak! do you have 5 mins? i've got problems with vimclojure... |
| 18:06 | kotarak | sure |
| 18:06 | Jetien | two problems. first: when i try to load a clojure file which has a (ns ..) form in it i get errors |
| 18:07 | kotarak | Jetien: must be on the CLASSPATH |
| 18:07 | kotarak | .. of the server |
| 18:08 | Jetien | hm..okay |
| 18:09 | Jetien | second problem: I'm trying to get the snake example to run from within vim: http://java.ociweb.com/mark/clojure/ClojureSnake.html |
| 18:09 | kotarak | Jetien: this is a limitation of the dynamic part: it uses Clojure's introspection, which only works, when the file can loaded without problems. |
| 18:10 | Jetien | i see |
| 18:11 | kotarak | What is the problem with the Snake? |
| 18:11 | Jetien | the example works fine when i manually start a repl fromt the console, but not from within the repl from the server. i would to sth like (load-file "snake.clj") and then (com.ociweb.snake/main) and nothing happens |
| 18:11 | Jetien | no errors, nothing |
| 18:12 | Jetien | it's not so much about getting the example to work, but knowing why it isn't working |
| 18:12 | kotarak | Does Vim freeze? |
| 18:12 | Jetien | no |
| 18:12 | kotarak | Hmm... |
| 18:13 | Jetien | ..whoops. |
| 18:13 | kotarak | whoops? |
| 18:13 | Jetien | i accidently lef the channel, nevermind. |
| 18:15 | kotarak | Jetien: I must confess, I don't know, why the snake doesn't work. |
| 18:16 | kotarak | I would suspect Vim to freeze, since it waits for input from the server process. But this shouldn't happen until main returns. |
| 18:17 | Jetien | have you tried to run the file, too? maybe the error is on my side |
| 18:20 | kotarak | doesn't work for me neither... |
| 18:33 | gunnarahlberg | what web framework are you guys using? i'm a noob, exploring |
| 18:37 | arohner | gunnarahlberg: I'm using compojure |
| 18:38 | gunnarahlberg | nice it seems |
| 18:39 | arohner | yeah, it works well |
| 18:39 | arohner | it's a little low-level compared to rails, but what it does, it does well |
| 18:39 | arohner | and we're building in that direction |
| 18:39 | gunnarahlberg | and the deps and install seem really reasonable |
| 21:37 | grrrt | hi room! is anyone in to help me with filtering a map to weed out nil values? |
| 21:37 | grrrt | I came up with (reduce (fn [m [k v]] (if (nil? v) m (assoc m k v))) {} {:a 1 :b nil :c 3}) |
| 21:38 | grrrt | but I don't know if that's the most Clojure-y way of doing it? |
| 21:38 | Chouser | not shabby at all. |
| 21:38 | grrrt | heh thanks! |
| 21:39 | Chouser | have you looked at 'into'? |
| 21:39 | grrrt | hm no. |
| 21:40 | grrrt | (doing (doc into) right now) |
| 21:41 | Chouser | what you'd got has nice use of destructuring and reduce. |
| 21:41 | grrrt | Ah I see. had a look at the source, it's more readable with recur |
| 21:41 | grrrt | (source for 'into') |
| 21:42 | Chouser | do you specifically want only non-nils, or is filtering out false ok too? |
| 21:43 | grrrt | in this case I need non-nils, but it's easy to generalise I suppose (defn map-filter or something) |
| 21:44 | grrrt | with false or nil you could do 'if v' instead of 'if (nil? v)' right? |
| 21:47 | albino | window 13 |
| 21:51 | grrrt | hang on... this weed-out-nils is shorter: '(filter (fn [[k v]] (not (nil? v))) {:a 1 :b nil :c 3})' |
| 21:55 | danlarkin | arohner: ping |
| 21:57 | Chouser | grrrt: yeah, that's why I was asking -- unless you specifically mean to differentiate between nil and false, it's more idiomatic you just say 'if v' |
| 21:59 | grrrt | you're right, thanks. |
| 22:00 | grrrt | Actually this was slightly tangential to what I actually wanted to do: |
| 22:00 | grrrt | given maps m1 and m2, return a map with all elements of m2 with keys that exist in m1 |
| 22:01 | grrrt | solution is similar: '(filter (fn [[k v]] (contains? m1 k) m2)' |
| 22:17 | holmak | grrrt: Check out select-keys |
| 22:18 | grrrt | holmak: ah thanks! I suspected there'd be a function for this, it's just a matter of finding the right one :) |
| 22:18 | holmak | I just stumbled across it today by accident. |
| 22:19 | holmak | I've found it's a good habit to read a half-dozen surrounding functions on the Clojure web site for every one you mean to look up. |
| 22:19 | holmak | It has really paid off for me! |
| 22:20 | grrrt | I have the clojure sources permanently open in an editor. The things you learn when you're randomly browsing them! |
| 23:17 | bpattison | so why does (str-join "abc" "") return "" -- shouldn't it produce "abc" |
| 23:17 | hiredman | ,(doc str-join) |
| 23:17 | clojurebot | "clojure.contrib.str-utils/str-join;[[separator sequence]]; Returns a string of all elements in 'sequence', separated by 'separator'. Like Perl's 'join'." |
| 23:18 | hiredman | ,(seq "") |
| 23:18 | clojurebot | nil |
| 23:18 | hiredman | makes sense to me |
| 23:20 | bpattison | I must be confused as to what it does |
| 23:20 | bpattison | I'm looking for a method that concat to strings together |
| 23:21 | Chouser | ,(str "abc" "123") |
| 23:21 | hiredman | ,(doc str) |
| 23:21 | clojurebot | "abc123" |
| 23:21 | clojurebot | "([] [x] [x & ys]); With no args, returns the empty string. With one arg x, returns x.toString(). (str nil) returns the empty string. With more than one arg, returns the concatenation of the str values of the args." |
| 23:21 | hiredman | bpattison: function |
| 23:21 | hiredman | not methods |
| 23:22 | bpattison | lol -- okay thanks -- yep str does what I want -- duh I knew that |