2009-02-05
| 00:02 | blbrown | is there a way to select an atom in a struct/map through a string. E.g. (def a { :abc-one 1 :abc-two 2 }) and then (a (str ":abc-one")) ...or something similar |
| 00:02 | blbrown | maybe like a way to convert a string to an atom |
| 00:03 | Chouser | ,(keyword "abc-one") |
| 00:03 | clojurebot | :abc-one |
| 00:04 | Chouser | ,(let [a {:abc-one 1 :abc-two 2 }] (a (keyword "abc-one"))) |
| 00:04 | clojurebot | 1 |
| 00:04 | Chouser | blbrown: is that what you mean? |
| 00:04 | blbrown | yea |
| 00:05 | blbrown | and I guess clojure doesn't use the term 'atom' in that sense |
| 00:05 | Chouser | no, there's no vocab for that concept. non-collection object. :-) |
| 00:12 | blbrown | Chouser, another small question. what is the 'else' clause for 'cond' (cond (= 1 2) 3 ... true (println "abc")? |
| 00:13 | Chouser | 'true' works fine of course, but it's conventional to use ':else' |
| 00:14 | blbrown | because :else always evaluates to true anyway |
| 00:14 | Chouser | exactly |
| 02:22 | hiredman | clojurebot: emacs? |
| 02:22 | clojurebot | emacs is hard, lets go shopping! |
| 02:23 | metaperl | how do you write unicode characters in clojure? |
| 02:27 | hiredman | metaperl: all characters in clojure are unicode |
| 02:28 | metaperl | how would you get at one via hex? |
| 02:28 | metaperl | the unicode char 1F18 for instance |
| 02:29 | hiredman | ,(.codePointAt "?foo" 0) |
| 02:29 | clojurebot | 9021 |
| 02:29 | hiredman | ,(char 9021) |
| 02:29 | clojurebot | \? |
| 02:30 | metaperl | that's odd... my irc client has garbled text: (.codePointAt "GIBBERISH" 0) |
| 02:30 | hiredman | ,(Integer/toHexString 9021) |
| 02:30 | clojurebot | "233d" |
| 02:30 | hiredman | metaperl: your irc client is not doing unicode then |
| 02:30 | hiredman | you should get a better one |
| 02:30 | hiredman | ,(char 0233d) |
| 02:30 | clojurebot | Eval-in-box threw an exception:Invalid number: 0233d |
| 02:30 | hiredman | ,(char 0x233d) |
| 02:30 | clojurebot | \? |
| 02:30 | hiredman | :P |
| 02:31 | hiredman | ,(char 0x1f18) |
| 02:31 | clojurebot | \? |
| 02:32 | metaperl | thanks for your help - http://github.com/metaperl/begin-clojure/blob/619eb489fb68839d2376d2cdf7375f2370d38494/1/unicode-chars.txt |
| 02:33 | hiredman | yeah |
| 02:33 | hiredman | that is not the character I was playing with |
| 02:33 | hiredman | the character I was playing with is one of the APL symbols |
| 02:33 | hiredman | a circle with a vertical like through it |
| 02:36 | lisppaste8 | metaperl pasted "How to create a string from a series of characters?" at http://paste.lisp.org/display/74908 |
| 02:37 | hiredman | str |
| 02:37 | hiredman | ,(str \a \b \c) |
| 02:37 | clojurebot | "abc" |
| 02:38 | hiredman | but clojure is all unicode, so you can just use unicode strings |
| 02:39 | hiredman | ,(apply str (map char (range 100 150))) |
| 02:39 | clojurebot | "defghijklmnopqrstuvwxyz{|}~����������������������" |
| 02:39 | hiredman | ,(apply str (map char (range 200 300))) |
| 02:39 | clojurebot | "��������������������������������������������������������????????????????????????????????????????????" |
| 02:40 | hiredman | ,(char 0x2620) |
| 02:40 | clojurebot | \? |
| 02:44 | metaperl | moving on to numbers... how would I print the decimal value of 01101 interpreted as oct and binary? |
| 02:44 | hiredman | ,(Integer/parseInt "01101" 2) |
| 02:44 | clojurebot | 13 |
| 02:45 | hiredman | http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Integer.html <-- go nuts |
| 02:46 | metaperl | well I need to create a lambda that takes a base and map over 2 and 8 |
| 02:46 | metaperl | ,'(2 8) |
| 02:46 | clojurebot | (2 8) |
| 02:46 | metaperl | ,(map (fn [x] (+ 1 x)) '(2 8)) |
| 02:46 | clojurebot | (3 9) |
| 02:47 | metaperl | ,(map (fn [x] (Integer/parseInt "01101" x) '(2 8)) |
| 02:47 | clojurebot | Eval-in-box threw an exception:EOF while reading |
| 02:47 | hiredman | uh |
| 02:47 | metaperl | ,(map (fn [x] (Integer/parseInt "01101" x)) '(2 8)) |
| 02:47 | clojurebot | (13 577) |
| 02:48 | hiredman | read the javadoc for the parseInt method of Integer |
| 02:48 | hiredman | I don't think it does what you think it does |
| 02:49 | metaperl | http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Integer.html#parseInt(java.lang.String) |
| 02:49 | metaperl | I thought the 2 was a base |
| 02:49 | hiredman | it is |
| 02:49 | hiredman | 01101 is not in base 8 |
| 02:49 | jdz | well, why not? |
| 02:49 | metaperl | oh its the method above |
| 02:49 | hiredman | well it could be |
| 02:50 | hiredman | but, I mean, come on |
| 02:50 | jdz | :) |
| 02:50 | hiredman | so running parseInt with base 8 is islly |
| 02:50 | metaperl | hiredman: why? |
| 02:51 | hiredman | because it isn't base 8 |
| 02:51 | metaperl | oh you mean there are more efficient ways to express that in octal |
| 02:51 | hiredman | no |
| 02:53 | jdz | the point is that the number 01101 looks like a binary, not octal |
| 02:53 | metaperl | How do I put a newline in a string? (. javax.swing.JOptionPane (showMessageDialog nil "Hello World\newlineHi Mom")) |
| 02:53 | hiredman | no |
| 02:53 | hiredman | \newline is the chracter literal for newline |
| 02:53 | metaperl | right that's a string |
| 02:54 | metaperl | i mean my code |
| 02:54 | metaperl | has a string |
| 02:54 | jdz | metaperl: how about you read some tutorial on Java? |
| 02:54 | hiredman | metaperl: try it and see |
| 02:55 | metaperl | ,(. System getProperty "line.separator") |
| 02:55 | clojurebot | java.security.AccessControlException: access denied (java.util.PropertyPermission line.separator read) |
| 02:58 | hiredman | the current prefered style for static methods would be (System/getProperty "line.separator") |
| 03:17 | Lau_of_DK | Good morning gents |
| 03:28 | boxbeat | good morning danskj�vel |
| 03:39 | BigTom | ,(prn 07) |
| 03:39 | clojurebot | 7 |
| 03:40 | BigTom | ,(prn 08) |
| 03:40 | clojurebot | Eval-in-box threw an exception:Invalid number: 08 |
| 03:40 | BigTom | That messed me up for a few minutes |
| 03:42 | Cark | hum these are octal ? |
| 03:42 | Chousuke | yeah. |
| 05:27 | zakwilson | I'm contemplating writing an IRC client in Clojure, mostly for my own entertainment. I'm looking for a library that abstracts away the details of communicating with the server - unfortunately, Google has 200000 hits for "java IRC library". Does anybody here have experience with any of them? |
| 05:30 | karmazilla | zakwilson: nope, but the clojurebot source code on github might be a source of inspiration |
| 05:31 | Holcxjo | The last.fm people had a post recently how they used IRC in their everyday life -- http://www.metabrew.com/article/how-we-use-irc-at-lastfm/ -- they use Java... |
| 05:32 | Holcxjo | Points to http://github.com/RJ/irccat/tree/master |
| 05:35 | Holcxjo | which in turn has a libs dir which has a conspicuous pircbot.jar file -- googling finds http://www.jibble.org/pircbot.php |
| 05:36 | zakwilson | Thanks guys. |
| 05:51 | Lau_of_DK | zakwilson: If you havent found something yet I can look up one I used a while ago |
| 05:59 | zakwilson | Lau_of_DK: pircbot is looking pretty attractive, but if you have something you were happy with, I'd like to see it. |
| 06:16 | ayrnieu | zakwilson, there's very little detail in communicating with the server. |
| 06:18 | zakwilson | ayrnieu: I know - I looked over the API. Still, I'm not sure there's any good reason to do that part myself. |
| 06:18 | zakwilson | Err... not API. RFC. |
| 06:26 | Lau_of_DK | metaperl: Did u figure it out re your last lisp paste? |
| 07:53 | AWizzArd | Where again can I find the Clojure roadmap (,,to do list")? |
| 07:56 | danlarkin | clojurebot: todo? |
| 07:56 | clojurebot | todo is not what you think it is |
| 07:57 | danlarkin | clojurebot: todo list? |
| 07:57 | clojurebot | todo is not what you think it is |
| 07:57 | danlarkin | grrrr |
| 07:58 | karmazilla | clojurebot: what is todo? |
| 07:58 | clojurebot | todo is not what you think it is |
| 07:58 | karmazilla | clojurebot: what? |
| 07:58 | clojurebot | what is latest |
| 08:00 | metaperl | Lau_of_DK: he had the installer on a different git branch... he may have changed it now |
| 08:00 | metaperl | you have to do a git checkout after the git clone to get it |
| 08:03 | AWizzArd | rhickey: there is no ref?, agent? yet? |
| 08:04 | AWizzArd | I saw there is an atom? which corresponds closely to CLs ATOM. |
| 08:04 | AWizzArd | clojure.inspector/atom? |
| 08:06 | ayrnieu | ,(map class [(ref nil) (agent nil) (atom nil)]) |
| 08:06 | clojurebot | (clojure.lang.Ref clojure.lang.Agent clojure.lang.Atom) |
| 08:06 | rhickey | AWizzArd: all these predicates are tiresome, just use instance? |
| 08:06 | AWizzArd | k |
| 08:18 | cemerick | rhickey: clojure.lang.Compile really needs a way to set *warn-on-reflection* -- would you accept a patch to it that set that var based on a system property? |
| 08:20 | rhickey | cemerick: sure |
| 08:21 | rhickey | thanks |
| 08:30 | ayrnieu | huh. (defmacro yet? [sym] `(= `~sym '~sym)), (macroexpand '(yet? +)) => (clojure.core/= user/sym (quote +)) -- but it's the same way in CL. |
| 08:31 | jdz | what are you suprised by? |
| 08:32 | jdz | surprised even |
| 08:32 | ayrnieu | I expected (clojure.core/= 'clojure.core/+ '+) |
| 08:32 | ayrnieu | ,[`+ '+] |
| 08:32 | clojurebot | [clojure.core/+ +] |
| 08:33 | jdz | ayrnieu: well, you have nested backquotes |
| 08:33 | ayrnieu | right. I expected them to nest. |
| 08:33 | jdz | and the do, in fact, nest |
| 08:33 | jdz | *they |
| 08:34 | ayrnieu | sym does not interpolate into `(= `~sym '~sym)) |
| 08:36 | jdz | you sure you don't want `(= ~`~sym '~sym))? |
| 08:37 | ayrnieu | ,(let [sym '+] `(= ~`~sym '~sym)) |
| 08:37 | clojurebot | (clojure.core/= + (quote +)) |
| 08:38 | ayrnieu | no, I don't want that. I want `(= xxx ~sym '~sym) to become (= xxx + '+) But ` doesn't nest, which surprised me. |
| 08:43 | jdz | so, isn't (let [sym '+] `(= ~sym '~sym)) what you want? |
| 08:43 | jdz | ,(let [sym '+] `(= ~sym '~sym)) |
| 08:43 | clojurebot | (clojure.core/= + (quote +)) |
| 08:44 | jdz | (note that (quote +) *is* the same as '+) |
| 08:44 | ayrnieu | no. |
| 08:44 | ayrnieu | look.p |
| 08:45 | ayrnieu | ,(let [x 1] `(xxx (yyy (bbb (zzz ~x) ~x) ~x ~x ~x))) |
| 08:45 | clojurebot | (sandbox/xxx (sandbox/yyy (sandbox/bbb (sandbox/zzz 1) 1) 1 1 1)) |
| 08:45 | ayrnieu | ,(let [x 1] `(xxx (yyy (bbb (zzz ~x) ''~x) ~x '~x '~x))) |
| 08:45 | clojurebot | (sandbox/xxx (sandbox/yyy (sandbox/bbb (sandbox/zzz 1) (quote (quote 1))) 1 (quote 1) (quote 1))) |
| 08:46 | ayrnieu | ONLY ` CHANGES MEANING INSIDE ` |
| 08:46 | jdz | i still don't understand what you want |
| 08:46 | ayrnieu | you can change bbb to quote , or just type '(zzz ~x) instead, and x gets interpolated directly into the form. |
| 08:46 | rhickey | (resolve 'sym) |
| 08:46 | ayrnieu | I've told you: < ayrnieu> I expected (clojure.core/= 'clojure.core/+ '+) |
| 08:47 | ayrnieu | The effect of (= `+ '+) |
| 08:47 | ayrnieu | thanks. |
| 08:48 | rhickey | ayrnieu: when would you expect (= `+ '+) to be true? |
| 08:48 | rhickey | only (= `+ 'clojure.core/+) is true |
| 08:49 | rhickey | this is not CL |
| 08:49 | rhickey | where the reader would have put all read symbols in packages |
| 08:50 | ayrnieu | I hadn't thought as far as seeing that `some-undefined-thing resolved anyway to 'user/some-undefined-thing |
| 08:50 | rhickey | ayrnieu: right, you force the issue with syntaxy-quote, but resolve should let you write yet? |
| 08:51 | ayrnieu | yes. yet? is just `(resolve ~arg) :-) |
| 08:51 | rhickey | there you go! |
| 08:51 | ayrnieu | well, '~arg |
| 08:52 | rhickey | yet? need not be a macro |
| 08:52 | rhickey | (def yet? resolve) |
| 08:53 | rhickey | or is this for use outside of macros? |
| 08:55 | ayrnieu | I think just resolve is fine. /me & |
| 09:00 | AWizzArd | ,`(list `(+ ~(* 10 5) 2)) |
| 09:00 | clojurebot | (clojure.core/list (clojure.core/concat (clojure.core/list (quote clojure.core/+)) (clojure.core/list (clojure.core/* 10 5)) (clojure.core/list 2))) |
| 09:00 | AWizzArd | ayrnieu: seems that ` nests. |
| 09:04 | cemerick | clojure.lang.Compile really should (at least optionally) take a list of clojure source roots, and just walk the dirs looking for libs to compile. The necessary ant gymnastics for getting a proper set of arguments into c.l.Compile right now are pretty painful (and probably fragile, in my current impl). |
| 09:04 | cemerick | I suppose there are edge cases where a simple directory walk would trip over files that don't define a separate lib... |
| 09:04 | cemerick | (or, edge cases for me :-) ) |
| 09:05 | rhickey | cemerick: you can't presume file == lib |
| 09:06 | cemerick | rhickey: yeah, I know -- but in my world, I can blithely call such circumstances "edge cases" |
| 09:06 | AWizzArd | cemerick: can't Enclojure do that? |
| 09:06 | cemerick | Having to manually enumerate each lib that should be compiled is not sustainable, though. Perhaps some header comment can be used to identify libs, or not-libs |
| 09:07 | cemerick | AWizzArd: Perhaps, but IMO, builds must be able to run in a headless environment |
| 09:07 | cemerick | headless and automated, I should say |
| 09:11 | bstephenson | AWizzard: by default, enclojure enumerates all clj files under a projects source directory, converts the file names into the proper dot syntax that clojure compile expects, and sends each file separately as an arg to the java command that calls clojure's compile function. |
| 09:13 | rhickey | bstephenson: so it presumes file == lib, or does it look for ns declarations? |
| 09:14 | bstephenson | rhickey: right now, the default project build file for clojure projects does presume file == lib |
| 09:18 | rhickey | bstephenson: hmm..., so clojure core couldn't be a clojure project |
| 09:23 | bstephenson | rhickey: well, couldn't be buildwith the build file from a DEFAULT clojure project, which just compiles clojure files and java files and jars them up. There are changes to the build file that are sometimes needed for more complex projects, such as those that mix java and clojure code that call each other. I know all of our enclojure projects do NOT use the default build file that is created when you use NetBeans to create a new |
| 09:24 | thickey | rhickey: is the ns declaration all that makes a file a lib, or is there some other defining characteristics? (sorry, not used to using the term "lib" here) |
| 09:25 | bstephenson | ...to create a new clojure project. |
| 09:26 | jayfields | is there a way to get a list if all the functions defined in a namespace? |
| 09:26 | AWizzArd | ,*ns* |
| 09:26 | clojurebot | #<Namespace sandbox> |
| 09:26 | AWizzArd | ,(ns-map 'sandbox) |
| 09:26 | clojurebot | {sorted-map #'clojure.core/sorted-map, read-line #'clojure.core/read-line, re-pattern #'clojure.core/re-pattern, keyword? #'clojure.core/keyword?, val #'clojure.core/val, ProcessBuilder java.lang.ProcessBuilder, Enum java.lang.Enum, SuppressWarnings java.lang.SuppressWarnings, *compile-path* #'clojure.core/*compile-path*, max-key #'clojure.core/max-key, list* #'clojure.core/list*, ns-aliases #'clojure.core/ns-aliases, the |
| 09:27 | jayfields | thanks |
| 09:28 | AWizzArd | this reminds me: I forgot how to check if an object x is a function object... |
| 09:30 | bstephenson | ,(ns-publics 'sandbox) |
| 09:30 | clojurebot | {} |
| 09:31 | rhickey | thickey: I think that idiomatic use of ns would make it such that files containing ns declarations would be considered lib roots, subordinate files would use in-ns |
| 09:35 | karmazilla | what kind of array is [B ? |
| 09:36 | cemerick | rhickey: if that's the operational definition, then we can definitely make c.l.Compile accept just the top-level src dirs. That'd make life a lot more pleasant for just about every use case, I think. |
| 09:36 | rhickey | karmazilla: bute - see: http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html#getName() |
| 09:36 | rhickey | byte |
| 09:37 | karmazilla | ty |
| 09:38 | rhickey | cemerick: you're advocating putting the ns-detecting code in Compile? |
| 09:38 | cemerick | rhickey: no, I presume it'd be useful elsewhere, but I think that's the most critical "user-facing" piece that needs that functionality at the moment |
| 09:39 | rhickey | cemerick: sorry, I didn't mean locating it there, just using that logic in Compile |
| 09:40 | cemerick | rhickey: yeah -- otherwise, every lib in every project has to be enumerated, or everyone needs to muck around with ant absurdity in order to produce a sane build process |
| 09:40 | cemerick | sane == repeatable |
| 09:41 | rhickey | the enclojure team might already have ns-detecting logic somewhere |
| 09:42 | cemerick | I'm sure they do. I'll bring it up later. |
| 09:42 | rhickey | I'm even fine with saying the first non-comment form (i.e. the first object returned by read) must be an ns form |
| 09:42 | rhickey | would be interested in use cases where it's not |
| 09:46 | karmazilla | rhickey: where would that be checked? |
| 09:47 | rhickey | karmazilla: we've been talking about build tools using it to identify a source file that is a lib compilation root |
| 09:49 | karmazilla | so it's only when figuring out whether some file is a lib or not |
| 09:49 | rhickey | karmazilla: right |
| 09:53 | walters | cemerick: i have hopes that the Jigsaw project is going to have a sane module system integrated with the VM and language |
| 10:17 | te | i still dont understand what the hell is going on in clojure |
| 10:20 | AWizzArd | How can I do (function? x) ? |
| 10:20 | gnuvince | AWizzArd: (fn? x) |
| 10:21 | AWizzArd | thx |
| 10:21 | Chousuke | ,(fn? :a) |
| 10:21 | clojurebot | false |
| 10:21 | gnuvince | ,(fn? take) |
| 10:21 | clojurebot | true |
| 10:21 | gnuvince | ifn? if you want something that works like a function to return true too. |
| 10:21 | Chousuke | so it doesn't check for IFn. |
| 10:22 | rhickey | ,(ifn? :a) |
| 10:22 | clojurebot | true |
| 10:22 | beatbox | anynone know if it is possible to write applications in mathematica or it is just prototyping and calculating? |
| 10:23 | Chouser | "ifn?" sounds funny in my head. Makes me smile. |
| 10:23 | bitbckt | "if'n y'all want, get 'er done!" |
| 10:24 | gnuvince | I read it as "I Fun" |
| 10:24 | gnuvince | And it makes me happy? |
| 10:24 | gnuvince | But then it returns false |
| 10:24 | gnuvince | and I'm brought back to reality |
| 10:24 | Chouser | bitbckt: right, to which one might reply "if'n?" |
| 10:24 | bitbckt | => false |
| 10:25 | bitbckt | (ifn? :english) |
| 10:25 | bitbckt | ;-) |
| 10:26 | gnuvince | (def yall? every?) |
| 10:26 | cooldude127 | oh god |
| 10:26 | bitbckt | haha |
| 10:26 | mattrepl | heh |
| 10:26 | gnuvince | (yall? ifn? acoll) |
| 10:26 | gnuvince | clj-redneck |
| 10:27 | cooldude127 | ha |
| 10:27 | mattrepl | beatbox: it's possible to write apps in mathematica, but they look ugly. wouldn't do much more than interactive data visualization with it |
| 10:28 | mattrepl | beatbox: doh, sorry. I was thinking matlab, disregard... |
| 10:28 | bitbckt | and mattrepl tears us all back down to reality... |
| 10:28 | cooldude127 | matlab sucks |
| 10:29 | mattrepl | clojure + jfreechart + jME + JAMA is a nice replacement for matlab |
| 10:29 | cooldude127 | but gatech is all about matlab, so :( |
| 10:30 | Chouser | Dejcartes is a jfreechart wrapper for clojure that I've been meaning to look at. |
| 10:34 | gnuvince | The name hurts my jaw |
| 10:35 | Chouser | It's not its fault that all the cool names like "textjure" are already taken. |
| 10:36 | beatbox | so basically suff like matlab, R, mathematica etc is for prototyping, noone writes real datamining or machine leaning applications in it? |
| 10:36 | beatbox | could you do soemthing like the netflix prize in mathematica? i mean is it efficient, can it handle 17770*450000 sparse matrices? |
| 10:46 | beatbox | ill put a 1000000$ bounty on the next person nameing something -jure |
| 10:58 | danlarkin | beatbox: haha I'll double it |
| 11:00 | brianh_ | beatbox: it's been a while, but in a past life i worked with engineers who used SAS for mining/analysis |
| 11:09 | bstephenson | Guess I will have to get rid of my clojure-based entertainment product: "It's Your Pleajure" |
| 11:10 | noidi | :D |
| 11:10 | Chouser | oh dear |
| 11:23 | beatbox | SAS? |
| 11:33 | brianh_ | beatbox: http://www.sas.com/ |
| 11:34 | brianh_ | disclaimer! never used it myself though |
| 11:35 | Chouser | rhickey: would you accept a patch that changes Var to implement Named? They do have names, after all. |
| 11:41 | cgrand1 | chouser: local vars don't have names, no? |
| 11:44 | Chouser | right, they have .ns and .sym fields still, but both are nil |
| 11:45 | Chouser | but I suppose the with-local-vars macro could give them a .sym and leave the .ns nil |
| 11:45 | Chouser | a nil namespace isn't unusual for a Named thing |
| 11:45 | Chouser | ,(namespace 'foo) |
| 11:45 | clojurebot | nil |
| 11:55 | Cark | hum i can't find a way to access some java enum ... |
| 11:55 | Cark | it's define like this : JXFrame.StartPosition |
| 11:55 | Cark | and i want to access the CenterScreen value |
| 11:56 | Cark | so i tried this : JXFrame$StartPosition/CenterInScreen |
| 11:56 | Cark | and all variations |
| 11:56 | Cark | but none is working |
| 11:58 | Chouser | Cark: you have a javadoc or .jar link for that class? |
| 11:59 | Cark | http://swinglabs.org/hudson/job/SwingX%20Continuous%20Build/javadoc/org/jdesktop/swingx/JXFrame.StartPosition.html |
| 12:00 | Cark | that's the first time i try accessing a java enum |
| 12:01 | Chouser | ,(prn java.lang.Thread$State/BLOCKED |
| 12:01 | clojurebot | Eval-in-box threw an exception:EOF while reading |
| 12:01 | Chouser | ,(prn java.lang.Thread$State/BLOCKED) |
| 12:01 | clojurebot | #<State BLOCKED> |
| 12:01 | Chouser | That seems to work. Did you import the JXFrame$StartPosition class? |
| 12:02 | Cark | right your example seems to work =/ |
| 12:02 | Cark | ahh let me try that |
| 12:03 | Cark | that was it ! |
| 12:03 | Cark | thanks again chouser |
| 12:04 | Cark | i guess without the import, i needed to fully qualify the name |
| 12:04 | Cark | though JXFrame was imported |
| 12:04 | Chouser | right. the nested classes are really completely different classes than their container class |
| 12:04 | Chouser | or whatever the right word is |
| 12:05 | Cark | good to know =) |
| 12:06 | StartsWithK | how could i turn {:a {:b 1} :c {:d 2 :e 3}}} into ((:a :b) 1 (:c :d) 2 (:c :e) 3), it there function for something like this already? |
| 12:09 | Chouser | seems unlikely that there'd be one built in |
| 12:10 | Chouser | looks fun though |
| 12:11 | kefka | I have a question about transactions/dosync: does dosync put a lock on state it alters? |
| 12:12 | kefka | err, let me phrase that more intelligently: |
| 12:13 | kefka | If I (dosync (alter *ref* fun)) and *ref* changes during the transaction, is there any risk of *ref* holding fun of the old value? |
| 12:13 | Chouser | StartsWithK: (apply concat (for [[k1 m] mm [k2 v] m] [(list k1 k2) v])) |
| 12:13 | Chouser | kefka: no |
| 12:14 | kefka | Chouser: Thanks. Btw, did you see you made Hacker News? |
| 12:14 | Chouser | kefka: if something else changed *ref* between when fun ran and when the transaction commits, the transaction will be retried. |
| 12:15 | durka42 | Chouser: that only works for two level deep, doesn't it? |
| 12:15 | Chouser | kefka: nope, hadn't seen that. |
| 12:15 | kefka | Chouser: Cool. That's how I assumed transactions worked. Just making sure because concurrency is a weak area for me. |
| 12:15 | kefka | Chouser: http://news.ycombinator.com/item?id=466341 |
| 12:15 | StartsWithK | Chouser: it gives me "Don't know how to create ISeq from: Integer", but thanks for a start, i'll poke at it later |
| 12:16 | StartsWithK | didn't know you can do that little trick you did with 'm' in for |
| 12:17 | Chouser | StartsWithK: yep, true nested loops. |
| 12:21 | StartsWithK | Chouser: I can see the problem, [k2 v] can't be destructed for leaf nodes, so thans for this |
| 12:21 | StartsWithK | everyhing can be implemented as one-liner in clojure :) |
| 12:21 | Chouser | that why I like it! |
| 12:21 | Chouser | ok, maybe not the only reason. |
| 12:22 | ozy` | ,[defn 'no 'u] |
| 12:22 | clojurebot | java.lang.Exception: Can't take value of a macro: #'clojure.core/defn |
| 12:27 | LordOfTheNoobs | clojurebot: ,(let [v {:a {:b 1} :c {:d 2 :e 3}}] (apply concat (for [k (keys v) v (v k)] (list (list k (first v)) (frest v))))) |
| 12:27 | clojurebot | for is not a loop |
| 12:28 | Chouser | hehe |
| 12:36 | Chouser | LordOfTheNoobs: looks good, though. Have you done much with destructuring? |
| 12:47 | stuhood | ,(new Long 1) |
| 12:47 | clojurebot | java.lang.IllegalArgumentException: No matching ctor found for class java.lang.Long |
| 12:47 | stuhood | that is really annoying =/ |
| 12:47 | stuhood | is the only way to get a long via coercion? |
| 12:48 | Chousuke | hmm :/ |
| 12:48 | Chousuke | ,(long 1) |
| 12:48 | clojurebot | 1 |
| 12:48 | Chousuke | ,(class (long 1)) |
| 12:48 | clojurebot | java.lang.Long |
| 12:48 | Chouser | ,(new Long (long 1)) |
| 12:48 | clojurebot | 1 |
| 12:48 | Chouser | :-P |
| 12:49 | Chousuke | ,(Long. (int 1)) |
| 12:49 | clojurebot | java.lang.IllegalArgumentException: No matching ctor found for class java.lang.Long |
| 12:49 | stuhood | isn't it going from Int -> Long -> Long in that one? |
| 12:49 | Chousuke | heh. |
| 12:49 | Chousuke | ,(class 1) |
| 12:49 | clojurebot | java.lang.Integer |
| 12:50 | stuhood | in Java, passing an integer to a function that expects a long is kosher... it probably should be here as well |
| 12:54 | Chousuke | except those aren't integers or longs, they're Integers and Longs :) |
| 12:54 | stuhood | true... i think we still need a solution though |
| 12:55 | walters | stuhood: actually you can't do that in Java either |
| 12:55 | walters | stuhood: int can get auto-promoted to long, OR auto-boxed to Integer, but not int->long->Long |
| 12:56 | walters | now if you're taking the reflection hit there's no reason not to do the conversion |
| 12:56 | stuhood | walters: that chain of conversions i showed was for this code: (new Long (long 1)) |
| 12:57 | walters | stuhood: oh i see, yeah Long takes a long arg; yeah Clojure should probably have similar upcasting conversions as java |
| 13:00 | Chouser | I wish 'keyword' could take a symbol and not just a string |
| 13:04 | Cark | hum how would i cast a [Ljava.lang.Object array to some other type of array ? |
| 13:04 | Cark | i thought it wasn't necessary |
| 13:07 | Chouser | I've never tried to do that. You need it to be an array of a different type for a java method call? |
| 13:08 | Cark | yes |
| 13:08 | Chouser | Did you build the array? |
| 13:08 | Cark | yes i have indeed a [Ljava.lang.Object array |
| 13:08 | Cark | looks like we might need a to-typed-array function somewhere |
| 13:09 | Chouser | ,(into-array [1 2 3]) |
| 13:09 | clojurebot | #<Integer[] [Ljava.lang.Integer;@1cbf6bb> |
| 13:09 | Chouser | ,(into-array Long [1 2 3]) |
| 13:09 | clojurebot | java.lang.IllegalArgumentException: array element type mismatch |
| 13:09 | Cark | right but what if you need a [Lorg.jdesktop.swingx.painter.Painter array =P |
| 13:09 | Chouser | ,(into-array (map long [1 2 3])) |
| 13:09 | clojurebot | #<Long[] [Ljava.lang.Long;@287ca7> |
| 13:10 | Cark | (doc to-array) |
| 13:10 | clojurebot | Returns an array of Objects containing the contents of coll, which can be any Collection. Maps to java.util.Collection.toArray().; arglists ([coll]) |
| 13:10 | Cark | (doc into-array) |
| 13:10 | clojurebot | Returns an array with components set to the values in aseq. The array's component type is type if provided, or the type of the first value in aseq if present, or Object. All values in aseq must be compatible with the component type. Class objects for the primitive types can be obtained using, e.g., Integer/TYPE.; arglists ([aseq] [type aseq]) |
| 13:10 | Cark | allright this should make it |
| 13:11 | Cark | yes it does, thanks ! |
| 13:19 | boxbeat | do you think clojure code looks aesthetic? |
| 13:20 | technomancy | heh; nice quit message there, walters. |
| 13:20 | technomancy | boxbeat: depends on who writes it. =) |
| 13:21 | technomancy | stuff that interacts with Java a lot is often not as pretty as pure lisp clojure |
| 13:21 | gnuvince | boxbeat: depends if it's written like Lisp code ought to be written or if it's written like somebody who using using it as a dynamic Java with parens |
| 13:22 | jayfields | In the closure.contrib.test-is documentation it says: You can plug in your own test-reporting framework by rebinding the "report" function: (report event msg expected actual). How do I rebind a function? |
| 13:23 | Chousuke | probably through (binding [report yourfn] ...) |
| 13:23 | Chousuke | with all the test-is calling inside that form. |
| 13:23 | jayfields | cool. thanks. |
| 13:24 | Chousuke | boxbeat: I think idiomatic clojure code looks better than common lisp :) |
| 13:25 | technomancy | heh; well CL was designed back before they realized you could put question marks in your function names |
| 13:25 | technomancy | or vowels, for that matter |
| 13:25 | Chousuke | even the java interop can look okay if it's done properly. |
| 13:25 | Chousuke | technomancy: mostly I like how clojure uses non-parentheses very elegantly in the syntax. |
| 13:25 | Chouser | yes, though I think that depends more on the Java library API in question than on Clojure. |
| 13:27 | Chousuke | clojure often avoids the situation where you have two opening parentheses, like in common lisp (let ((foo bar))) which I think just looks ugly. |
| 13:28 | Chouser | when you see that in Clojure it almost always means you're actually getting a function and then calling it. |
| 13:29 | Chousuke | though destructuring in vectors often leads to [[foo bar]], that's somehow less offensive... I guess it's because in a vector the head position is not special. |
| 13:32 | Chousuke | Chouser: I prefer avoiding that though. somehow I feel it's clearer to use let first and call a named function, even if it's temporary :) |
| 13:38 | technomancy | Chousuke: I often do that to figure out what I'm doing, then inline it once I've got it working. |
| 13:38 | Chousuke | why not just leave it in as documentation though? :/ |
| 13:39 | technomancy | I usually find it easier to read, just not easy to write. |
| 13:39 | technomancy | which is weird |
| 13:40 | technomancy | when I see let, it often acts as a signal for "this variable is going to be used in more than one place" |
| 13:41 | jbondeson | i'm a big fan of using a let for local functions, even if only used once. |
| 13:44 | Chouser | but then it takes two lines. :-( |
| 13:44 | jbondeson | yes, but it can make your code substantially more readable |
| 13:44 | Chouser | yes, but TWO LINES! |
| 13:44 | jbondeson | heh |
| 13:45 | Chouser | sorry |
| 13:46 | durka42 | http://news.ycombinator.com/item?id=467155 |
| 13:47 | durka42 | he threw clojure onto a mono jvm and it worked... cool |
| 13:55 | technomancy | mono kinda reminds me of http://en.wikipedia.org/wiki/Harmony_toolkit |
| 13:56 | technomancy | great idea, back before the JVM was freed. but today... what's the point again? |
| 13:57 | stuhood | competition is good! (see recent javascript developments) |
| 14:11 | gnuvince | Does this seem like a decent solution to the matching brackets problem? http://gist.github.com/58924 |
| 14:11 | gnuvince | (Clojure style speaking) |
| 14:14 | kotarak | Just out of curiosity: do people really write a lot of macros defining macros? I wrote a bit of Clojure code, but I'm yet to see the need for a macro defined by a macro.... |
| 14:15 | Chousuke | I don't think I've done that. |
| 14:15 | rhickey | gnuvince: opening/closing-brackets should be sets |
| 14:15 | Chousuke | in fact the only macro defining macro I can think of right now is defmacro :P |
| 14:16 | rhickey | gnuvince: then you could use like predicate (cond (opening-bracket x) ...) |
| 14:17 | kotarak | Chousuke: ok, that a use case. :) |
| 14:17 | danlarkin | clojurebot: max people |
| 14:17 | clojurebot | max people is 145 |
| 14:17 | gnuvince | rhickey: but I'd need to replicate the brackets for my hash-map, because I cannot assume the order of the sets will be preserved, right? |
| 14:19 | rhickey | gnuvince: you could build the sets and the map from the strings, but the some linear lookup code is not good |
| 14:19 | gnuvince | ok |
| 14:22 | rhickey | ,(zipmap "({[<" ")}]>") |
| 14:22 | clojurebot | {\< \>, \[ \], \{ \}, \( \)} |
| 14:22 | rhickey | ,(set (keys *)) |
| 14:22 | clojurebot | java.lang.IllegalArgumentException: Don't know how to create ISeq from: core$_STAR___3192 |
| 14:23 | Chousuke | it's not that smart :) |
| 14:23 | rhickey | ,(set (keys *2)) |
| 14:23 | clojurebot | java.lang.IllegalStateException: Var clojure.core/*2 is unbound. |
| 14:23 | rhickey | hrm |
| 14:23 | kotarak | sorted-set works also |
| 14:23 | rhickey | gnuvince: anyway, zipmap |
| 14:23 | gnuvince | (doc zipmap) |
| 14:23 | clojurebot | Returns a map with the keys mapped to the corresponding vals.; arglists ([keys vals]) |
| 14:23 | gnuvince | cool |
| 14:29 | gnuvince | http://gist.github.com/58942 |
| 14:45 | lisppaste8 | rhickey pasted "more idiomatic check-brackets" at http://paste.lisp.org/display/74934 |
| 14:46 | rhickey | gnuvince: oh, I didn't see you later paste |
| 14:47 | gnuvince | No problem |
| 14:47 | gnuvince | rhickey: nice code; I always forget the (and ...) idiom. |
| 14:54 | Chouser | I think my first contributions to a free software project were to Harmony. |
| 14:58 | sethtrain | http://www.faa.gov/data_statistics/accident_incident/1549/media/N90%20AWE1546%201-15-09%20L116.mp3 |
| 14:58 | sethtrain | sorry guys, wrong window |
| 14:58 | cp2 | that mp3 is illegally shared |
| 14:59 | cp2 | the riaa will be at your doorstep in a matter of hours |
| 15:09 | Chouser | hm, when-first but no if-first. |
| 15:10 | ayrnieu | (if-let [x (first xs)] ...) |
| 15:11 | Chouser | or even (if-let [[x] xs] ...) I suppose |
| 15:12 | Chouser | oh, those are slightly different, and both different from when-let |
| 15:13 | Chouser | ayrnieu: yours tests the value of x, not xs |
| 15:13 | Chouser | my if-let tests the value of xs |
| 15:13 | Chouser | when-first test (seq xs) |
| 15:47 | Raynes | Is paste.lisp.org down? :| I'm getting a 502. |
| 15:48 | durka42 | lisppaste8: url? |
| 15:48 | lisppaste8 | To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste. |
| 15:48 | durka42 | ya, proxy error |
| 15:48 | ayrnieu | Reason: Document contains no data |
| 15:48 | hiredman | ain't that the truth |
| 15:49 | durka42 | back up |
| 15:50 | durka42 | that was quick |
| 15:54 | hiredman | ,(int H) |
| 15:54 | clojurebot | java.lang.Exception: Unable to resolve symbol: H in this context |
| 15:54 | hiredman | ,(int \H) |
| 15:54 | clojurebot | 72 |
| 15:54 | hiredman | ,(int \Z) |
| 15:54 | clojurebot | 90 |
| 15:54 | hiredman | ,(char (/ (- 90 72) 2)) |
| 15:54 | clojurebot | \tab |
| 15:54 | hiredman | ,(int \A) |
| 15:54 | clojurebot | 65 |
| 15:55 | hiredman | ,(char (+ (/ (- 90 72) 2) 72)) |
| 15:55 | clojurebot | \Q |
| 16:15 | lisppaste8 | jkantz pasted "untitled" at http://paste.lisp.org/display/74938 |
| 16:16 | jkantz | nested maps: is there some cool short cut for merging cookies into the :cookie-jar |
| 16:17 | hiredman | (doc update-in) |
| 16:17 | clojurebot | 'Updates' a value in a nested associative structure, where ks is a sequence of keys and f is a function that will take the old value and any supplied args and return the new value, and returns a new nested structure. If any levels do not exist, hash-maps will be created.; arglists ([m [k & ks] f & args]) |
| 16:19 | jkantz | nice! |
| 16:20 | kotarak | jkantz: also assoc-in and get-in |
| 16:24 | lisppaste8 | jkantz annotated #74938 with "untitled" at http://paste.lisp.org/display/74938#1 |
| 16:24 | ayrnieu | (update-in places [:kitchen :cupboard :cookie-jar] conj 'cookies) |
| 17:14 | cemerick | I'm seeing a ClassName__init.class file and a bunch of related inner classes (one for each fn, I think), but I'm not seeing a ClassName.class file. Any thoughts? |
| 17:15 | cemerick | this, after compiling, of course. |
| 17:16 | Chouser | you only get that if you ask for it. Via :gen-class, I think. |
| 17:17 | cemerick | Chouser: yeah -- this is actually in conjunction with an explicit gen-class (separate from the ns form) |
| 17:20 | Chouser | hmph |
| 17:20 | hiredman | huh |
| 17:20 | hiredman | my explicit gen-class stuff does generate a .class file named after the class |
| 17:21 | cemerick | hiredman: yeah, that's what I'm expecting |
| 17:21 | kotarak | Isn't ClassName.class for the namespace file? So if you have it separate from the ns, there is none? |
| 17:21 | hiredman | hmmm |
| 17:21 | hiredman | actually |
| 17:22 | cemerick | kotarak: you're right, putting a gen-class in the ns produces the ClassName.class file |
| 17:22 | cemerick | well, that's no good :-/ |
| 17:23 | cemerick | hiredman: can you verify what you're seeing there? |
| 17:25 | hiredman | cemerick: working on it |
| 17:25 | cemerick | hiredman: great, thanks |
| 17:25 | cemerick | gotta run for a bit -- hopefully, I'll catch the brilliant solution in the log ;-) thanks, all |
| 17:28 | hiredman | http://gist.github.com/34229 <-- this is the gen-class deal I am testing with |
| 17:29 | hiredman | when I compile hiredman.beans I get a wsbean.class file in ./classes/hiredman/ |
| 17:47 | hiredman | ,(char (- 9432 10)) |
| 17:47 | clojurebot | \(Y) |
| 17:48 | kotarak | hiredman: you are right. I also get the ClassName.class file, but in a subdirectory according to the qualified name of the class. |
| 17:48 | kotarak | So it isn't necessarily in the same directory as the .class files for the implementing functions. |
| 17:49 | hiredman | yeah |
| 17:49 | hiredman | class files go in the classpath of the namespace the entity they represent is in |
| 17:54 | ozy` | ,[def] |
| 17:54 | clojurebot | java.lang.Exception: Unable to resolve symbol: def in this context |
| 17:54 | ozy` | huh |
| 17:54 | hiredman | def is a special form |
| 17:54 | ozy` | yes |
| 17:55 | ozy` | I'm playing around with an interpreter and trying to decide if it should differentiate between special forms and macros |
| 17:55 | ozy` | it currently doesn't |
| 18:24 | jayfields | what's the easiest way to 'use' all the namespaces in a parent namespace? For example if I have tests.test-one and tests.test-two can I load them both via (use [tests]) |
| 18:26 | hiredman | (ns foo.bar (:user (tests test-one test-two))) |
| 18:27 | hiredman | I do not believe use ever takes a vector |
| 18:27 | jayfields | is there a dynamic way to just use all of the children of tests? |
| 18:27 | hiredman | nope |
| 18:28 | technomancy | jayfields: if they've been required, there could be one, but if not then you'd have to inspect the filesystem or something. |
| 18:28 | technomancy | which is lame |
| 18:28 | kotarak | hiredman: use may take a vector, eg. for :only |
| 18:29 | technomancy | but seems pretty reasonable |
| 18:29 | hiredman | kotarak: ok |
| 18:41 | tmi | Hi.. trying to use compojure - Don't know how to create ISeq from: Symbol - http://pastebin.com/d262a54d ... should be latest svn/git version of all. |
| 18:43 | ayrnieu | ... and your hello.clj ? |
| 18:43 | tmi | http://pastebin.com/d64615397 |
| 18:49 | Raynes | tmi: paste.lisp.org/list/clojure and paste.pocoo.org are better choices for Clojure ;) |
| 18:50 | Chousuke | tmi: your namespace name doesn't match your filename, but that's probably not the main problem :/ |
| 18:50 | tmi | Raynes: details, details. :P I'll try to remember next time. Put it in subject? |
| 18:50 | ayrnieu | In any case, I also get ExceptionInInitializer as soon as I (use 'compojure) |
| 18:51 | hiredman | you need to look lower down the stack |
| 18:51 | hiredman | or higher |
| 18:51 | hiredman | or which ever |
| 18:52 | hiredman | tmi: is your clojure up to date? |
| 18:52 | ayrnieu | it fails even when you use the supplied clojure.jar |
| 18:52 | tmi | hiredman: yes. Revision: 1162 |
| 18:53 | hiredman | ayrnieu: oh |
| 18:53 | tmi | ayrnieu: it worked with the supplied one for me. |
| 18:53 | ayrnieu | tmi - the latest is 1251 |
| 18:53 | hiredman | sounds like time to hit up the compojure google group |
| 18:53 | hiredman | clojurebot: latest? |
| 18:53 | clojurebot | latest is 1250 |
| 18:53 | hiredman | hmmm |
| 18:53 | hiredman | yeah |
| 18:53 | tmi | ayrnieu: gah. that might explain. |
| 18:53 | ayrnieu | hm, maybe -cp doesn't defeat CLASSPATH |
| 18:53 | hiredman | clojurebot's task runner died |
| 18:54 | Raynes | ,(doc +) |
| 18:54 | clojurebot | "([] [x] [x y] [x y & more]); Returns the sums of nums. (+) should never be used." |
| 18:54 | Raynes | :D |
| 18:55 | Chousuke | interesting remark |
| 18:55 | Chousuke | ,(+) ;muhahha |
| 18:55 | clojurebot | 0 |
| 18:55 | ayrnieu | two days ago: <ayrnieu> ,(.setMeta #'+ (assoc (meta #'+) :doc "Returns the sums of nums. (+) should never be used.")) |
| 18:56 | Chousuke | I see. |
| 18:56 | ayrnieu | (want to improve the documentation? Distribute an improved-doc.clj !) |
| 18:56 | tmi | hmm, why does SF say 1162 then? and my "svn update -r HEAD" says 1162. https://clojure.svn.sourceforge.net/svnroot/clojure/trunk *confused* |
| 18:57 | Raynes | Google Code bro. |
| 18:57 | Chousuke | (doc reset-meta!) |
| 18:57 | clojurebot | Atomically resets the metadata for a namespace/var/ref/agent/atom; arglists ([iref metadata-map]) |
| 18:57 | Chousuke | or alter-meta! I guess. |
| 18:57 | Chousuke | tmi: clojure moved to google code a long time ago :) |
| 18:58 | Raynes | Long long ago. |
| 18:58 | Raynes | At least 100 years ago. |
| 18:58 | ayrnieu | ,(- 1251 1162) ;; ago |
| 18:58 | clojurebot | 89 |
| 18:58 | tmi | can't be _that_ long ago... but sure, then I'm unconfused again. thanks. |
| 18:59 | tmi | besides, if I google "clojure svn" SF is still the top hit :-( |
| 19:00 | ayrnieu | clojure.org has a prominent 'SVN' |
| 19:00 | Chousuke | the move happened 16th of december it seems |
| 19:01 | Raynes | If XChat freezes one more time... |
| 19:01 | ayrnieu | you'll write an IRC client? |
| 19:01 | Raynes | Yes. |
| 19:01 | hiredman | you'll get a real client? |
| 19:02 | Raynes | hiredman: I'm trying out XChat for a friend. Great client, besides the constant freezin g. |
| 19:02 | Raynes | freezing* |
| 19:02 | clojurebot | svn rev 1251; [lazy] removed loop from distinct |
| 19:02 | Raynes | kotarak: You probably aren't on Windows vista either. |
| 19:03 | Raynes | I wouldn't use irssi if it was the only client in existence. |
| 19:03 | kotarak | No. Used xchat on Linux, no colloquy on mac |
| 19:03 | Chousuke | it could just as well be, since it's perfect! |
| 19:03 | kotarak | s/no/now |
| 19:03 | Chousuke | It's not built on lisp though |
| 19:03 | Chousuke | but that doesn't matter as there are no missing features. |
| 19:04 | Raynes | kvIRC is a nice client for windows. Just too colorful. |
| 19:04 | ayrnieu | yeah, a day is plenty of time to write an IRC client. |
| 19:05 | Chousuke | colloquy is a passable client. |
| 19:05 | Chousuke | after a bit of tweaking, anyway |
| 19:06 | Chousuke | with the defaults I can't stand it. |
| 19:06 | ayrnieu | it defiantly spreads error. |
| 19:06 | Ariens | limechat is better |
| 19:06 | cp2 | i prefer irssi, but im on windows so i am using the dreadfully lame mirc |
| 19:06 | cp2 | nnscript makes it a lot better :) |
| 19:06 | Chousuke | but there's still nothing that rivals irssi. |
| 19:07 | ayrnieu | irssi has acceptable defaults. |
| 19:07 | tmi | yay, now it works. thanks all for your help. now I can go play some more. |
| 19:07 | cp2 | ,(doc dotimes) |
| 19:07 | clojurebot | "([bindings & body]); bindings => name n Repeatedly executes body (presumably for side-effects) with name bound to integers from 0 through n-1." |
| 19:07 | ayrnieu | tmi - what did you do? |
| 19:07 | tmi | ayrnieu: did a fresh checkout from the right svn servers ;-) |
| 19:09 | ayrnieu | hmph. That doesn't help me, but I wasn't doing anything with compojure anyway. |
| 19:10 | tmi | :/ |
| 19:16 | cp2 | is there a way to generate a keyword from a string? |
| 19:16 | cp2 | as in |
| 19:16 | cp2 | "foo" would result in :foo |
| 19:16 | hiredman | ,(doc keyword) |
| 19:16 | clojurebot | "([name] [ns name]); Returns a Keyword with the given namespace and name. Do not use : in the keyword strings, it will be added automatically." |
| 19:16 | ayrnieu | ,(keyword (symbol "foo")) |
| 19:16 | clojurebot | java.lang.ClassCastException: clojure.lang.Symbol cannot be cast to java.lang.String |
| 19:16 | ayrnieu | or just that. |
| 19:16 | cp2 | i see |
| 19:17 | cp2 | thanks |
| 19:17 | hiredman | ,((comp keyword name) (symbol "foo")) |
| 19:17 | clojurebot | :foo |
| 19:17 | cp2 | i suppose i should get more acquainted with the api page |
| 19:18 | ayrnieu | or use find-doc , or you write your own: the first thing I did was throw together a http://paste.lisp.org/display/74207 |
| 19:19 | cp2 | heh, i still prefer http://clojure.org/api |
| 19:19 | cp2 | for the moment, at least |
| 19:44 | hiredman | clojurebot: latest? |
| 19:44 | clojurebot | latest is 1251 |
| 19:45 | hiredman | svn rev 1251 |
| 19:45 | clojurebot | svn rev 1251; [lazy] removed loop from distinct |
| 19:45 | clojurebot | svn rev 1251; [lazy] removed loop from distinct |
| 19:45 | hiredman | hmm |
| 19:45 | clojurebot | svn rev 1251; [lazy] removed loop from distinct |
| 19:45 | clojurebot | svn rev 1251; [lazy] removed loop from distinct |
| 19:45 | hiredman | that is not good |
| 19:46 | hiredman | svn rev 1251 |
| 19:46 | clojurebot | svn rev 1251; [lazy] removed loop from distinct |
| 19:46 | clojurebot | svn rev 1251; [lazy] removed loop from distinct |
| 19:47 | hiredman | svn rev 1235 |
| 19:47 | clojurebot | svn rev 1235; added pcalls, pvalues |
| 19:50 | Raynes | clojurebot: earliest? |
| 19:50 | clojurebot | Gabh mo leithsc�al? |
| 19:50 | Raynes | ;o |
| 19:51 | ayrnieu | ,(-> 1235 range sort first) |
| 19:51 | clojurebot | 0 |
| 19:52 | hiredman | Nice |
| 19:55 | ayrnieu | c.f. http://xahlee.org/UnixResource_dir/writ/lisp_problems_by_ruby.html |
| 19:58 | hiredman | I started working on a fn that would take something like (a b (c d)) and turn it into a block of (comp (partial a b) c) |
| 19:59 | technomancy | heh; xah lee. |
| 19:59 | hiredman | I forget why I stopped |
| 20:00 | ayrnieu | technomancy - he's better than the assholes who take him for a troll, but this isn't a shining post from him. |
| 20:00 | hiredman | clojurebot: the doctor? |
| 20:00 | clojurebot | No entiendo |
| 20:00 | hiredman | clojurebot: the doctor is out |
| 20:00 | clojurebot | Alles klar |
| 20:01 | technomancy | ayrnieu: he was definitely a troll when he frequented the #emacs channel but luckily I haven't heard from him since '05 or so; he could have reformed his ways since then |
| 20:02 | ayrnieu | technomancy - no, he definitely was not a troll; #emacs just went bat fucking insane, all on their own, all in *anticipation* of trolling. |
| 20:03 | technomancy | you can't use the word "fuckfaces" without provocation twice in the same sentence without being a troll. |
| 20:03 | technomancy | it doesn't work like that. |
| 20:04 | ayrnieu | I feel dirty even for using this worthless terminology. Xah Lee's kind of a dork, but the people who react to him are contemptible. |
| 20:05 | ayrnieu | but the point is, clojure cuts through some of the initial counter-arguments that someone would make to "what? Just use ->" |
| 20:14 | cemerick | hiredman, Chouser: found the cause of my gen-class-not-generating-classfile issue -- I omitted a tilde ahead of the value for the :name in the gen-class spec, so the name was being given as com.snowtide.clojure.utils/fq-classname. Doh! :-| |
| 20:17 | cemerick | rhickey: that particular *oops* was all my fault, but maybe the gen-class machinery should complain loudly when an invalid classname is provided (or, a classname that clojure doesn't know how to normalize). The slash in the name above was actually having the effect of generating a fq_classname.class file in the com/snowtide/clojure/utils dir. |
| 20:24 | rhickey | cemerick: I guess it shouldn't be normalizing, otherwise that behavior would be correct |
| 20:25 | cemerick | well, I was just talking about the dash-to-underscore translation, and whatever other transformations that are done to the classname |
| 20:28 | rhickey | cemerick: do you want munging or not? Because foo_bar is a valid classname |
| 20:29 | rhickey | I guess I'm not understanding |
| 20:30 | rhickey | or you want foo/bar-baz flagged as bad classname due to / ? |
| 20:34 | cemerick | sorry, yes, the slash is the problematic thing here, just because I think it's indicative of a maybe-semi-common programming error |
| 21:34 | Chouser | I want thread-local storage, but I don't want nested scopes to stack. |
| 21:34 | Chouser | Is there something like binding-once |
| 21:34 | Chouser | ? |
| 21:35 | schoppenhauer | ! |
| 21:38 | Chouser | ThreadLocal will do, I think. |
| 21:40 | Raynes | ,(meta #'str) |
| 21:40 | clojurebot | {:ns #<Namespace clojure.core>, :name str, :file "core.clj", :line 313, :arglists ([] [x] [x & ys]), :tag java.lang.String, :doc "With no args, returns the empty string. With one arg x, returns\n x.toString(). (str nil) returns the empty string. With more than\n one arg, returns the concatenation of the str values of the args."} |
| 21:41 | ayrnieu | Chouser, what would binding-once do? |
| 21:42 | Chouser | ayrnieu: establish a thread-local binding if this thread didn't have one yet |
| 21:43 | Chouser | this would allow 'set!' to communicate up the call stack through multiple binding-once blocks, instead of stopping at the nearest enclosing 'binding' block. |
| 21:43 | Chouser | but I'm not sure it would be any better than using the ThreadLocal class directly. That's what I'm trying now. |
| 22:58 | dreish | Anyone know a good way to make a library redefine a function (or in this case macro) in clojure.core? |
| 23:00 | dreish | I'd like to be able to (use 'util) or (:use util) and get my redefined version of -> |
| 23:01 | arohner | dreish: you can use binding, but that's scope local |
| 23:01 | dreish | Right, not really what I'm looking for. |
| 23:02 | Chouser | you can say (ns mylib (:refer-clojure :exclude (->)) (:use util)) |
| 23:02 | dreish | I thought ns-unmap would do it, but it needs an ns arg, and what I really want is the ns of the namespace importing me. |
| 23:02 | dreish | Chouser: That's maybe not the worst thing, if it works. I was hoping for something I could put inside util, rather than forcing users to do something ugly. |
| 23:03 | dreish | Arguably it should be explicit if you're redeffing stuff from core, but my -> is essentially backward-compatible. |
| 23:04 | arohner | you can also do (in-ns 'clojure.core) (defn -> [] ...), but I didn't show you that |
| 23:04 | Chouser | heh |
| 23:04 | dreish | Ah, that's what I wanted. Thanks. |
| 23:05 | ayrnieu | (.doReset (var ->) (fn [& rst] (println rst))) (-> 1 2 3) => printed: (1 2 3) |
| 23:05 | Chouser | that changes it for everyone |
| 23:05 | dreish | Yeah, but everyone is just me. |
| 23:05 | dreish | And like I said, it's backward-compatible. It just adds usages that formerly would do nothing but die. |
| 23:06 | ayrnieu | what does it add? |
| 23:06 | dreish | #() fns without an extra set of parens, and maybe a little more dangerously, _ as a special symbol meaning "insert previous form here". |
| 23:07 | ayrnieu | use (.setMacro (var ->)) after you .doReset |
| 23:07 | dreish | I.e., (-> 2 (+ 2) (/ 3 _)) |
| 23:07 | Chouser | mm, yeah, I've had that _ feature before. |
| 23:08 | dreish | user=> (map #(-> % name seq drop-last (apply str _) symbol) #{'AddObject. 'AskInv. 'Blob.}) |
| 23:08 | dreish | (Blob AddObject AskInv) |
| 23:08 | stimuli | It could make your library break some else's lib if everyone starts doing it |
| 23:08 | dreish | Meh, I'll deal with it when it happns. |
| 23:08 | arohner | is there already a macro for (when (not (nil? foo)) foo) ? |
| 23:08 | arohner | I find myself writing that often |
| 23:09 | stimuli | that's what the ruby guys said ... look at the mess they now have |
| 23:09 | dreish | stimuli: True, nobody has ever done anything useful with ruby. :-P |
| 23:09 | Chouser | arohner: (when foo foo) |
| 23:09 | stimuli | :) |
| 23:09 | stimuli | why not just call it --> or something ? |
| 23:09 | arohner | Chouser: yeah, but that depends on false == nil |
| 23:09 | dreish | That's probably how I'll deal with it. |
| 23:10 | stimuli | or fred |
| 23:10 | arohner | I'm not a huge fan of that |
| 23:10 | Chouser | oh |
| 23:10 | ayrnieu | (defmacro unless (test & body) `(when (not ~test) ~@body)) |
| 23:10 | Chouser | that's never gonna change. Clojure's going to keep nil meaning false forever. |
| 23:11 | dreish | Lispers have been arguing about (if (not (nil? x))) for decades. |
| 23:11 | ayrnieu | of course that should be [test & body] |
| 23:11 | stimuli | so a couple of my coworker who are "java only" sort of guys want to learn Clojure |
| 23:12 | stimuli | but I have no idea how they could learn it now give the available resources |
| 23:12 | arohner | I'm not expecting it to change, but I have situations in my code where they are not the same |
| 23:12 | arohner | stimuli: how did all of us learn it? |
| 23:12 | dreish | Programming Clojure. |
| 23:12 | stimuli | how much of that is done now ? |
| 23:12 | dreish | All but some typos. |
| 23:12 | stimuli | well ... I knew CL .. they don't |
| 23:12 | ayrnieu | stimuli - it's pretty helpful for Java. I used (filter #(.contains (val %) "32") (System/getProperties)) to answer a ##java question earlier. |
| 23:13 | arohner | yeah, I keep telling people clojure is a better java than java |
| 23:13 | stimuli | indeed |
| 23:13 | arohner | and Chouser's cool class introspection fns |
| 23:14 | stimuli | I think I'll buy learning clojure then |
| 23:15 | stimuli | I had thought only a couple chapters were done |
| 23:16 | dreish | I think it's close to printing. They cut one chapter, and now there are none that say "this chapter is not yet written". |
| 23:16 | stimuli | cool |
| 23:16 | stimuli | how would you rate it as a book ? |
| 23:17 | dreish | I thought it was perfect as a rapid introduction to the language. |
| 23:17 | stimuli | do you think it will work for the "I only know Java and C#" guys ? |
| 23:18 | dreish | Some of the stuff about getting set up with the environment I remember not liking, but I'm sure everything's changed a few times since I read it. |
| 23:18 | Chouser | stimuli: that's one of the key audiences |
| 23:18 | stimuli | that will change as teh eclipse and netbeans stuff matures |
| 23:18 | stimuli | not everyone will use emacs :) |
| 23:19 | stimuli | and I'm sure if I suggested to someone to install "slime" they'd look at me funny |
| 23:19 | arohner | for shame |
| 23:19 | hiredman | clojurebot: slime? |
| 23:19 | clojurebot | slime is icky |
| 23:19 | stimuli | slime is an emacs-lisp thingy |
| 23:19 | arohner | I really wish slime would become the defacto standard for clojure IDEs. static analysis of a dynamic language seems misguided at best |
| 23:19 | stimuli | with a debugger and stuff |
| 23:19 | hiredman | I am well aware |
| 23:20 | stimuli | well .. yeah |
| 23:20 | hiredman | given that #clojure turns into #emacs for a few hours a day |
| 23:20 | LordOfTheNoobs | stimuli: hiredman just likes playing with clojurebot |
| 23:20 | hiredman | it's actually kind of a drag |
| 23:20 | stimuli | dude ... if clojure on eclipse gets people to try it I'll sign on |
| 23:21 | hiredman | clojurebot: emacs? |
| 23:21 | clojurebot | "Learning Emacs and SLIME was just about the most painful computer experience I've ever been through." |
| 23:21 | c|p | lol |
| 23:21 | stimuli | poor poor clojurebot |
| 23:21 | arohner | I don't have a problem with them using eclipse, I just want them to use slime for the introspection/debugging stuff |
| 23:21 | hiredman | that one comes up way too often |
| 23:21 | hiredman | I really like "emacs is hard, lets go shopping!" |
| 23:21 | stimuli | I'm using one of the not-quite-slime emacs modes I d/l'ed |
| 23:22 | stimuli | (don't ask me which one) |
| 23:23 | hiredman | ugh |
| 23:23 | hiredman | my poor poor network |
| 23:23 | hiredman | so much lag |
| 23:25 | Raynes | I use the netbeans plugin myself. I think it's fine. It's buggy as hell, but it works. |
| 23:26 | Raynes | I use enclojure for Clojure and emacs for everything else. |
| 23:56 | hiredman | clojurebot: ping? |
| 23:56 | clojurebot | PONG! |
| 23:56 | hiredman | clojurebot: how much do you know? |
| 23:56 | clojurebot | I know 192 things |
| 23:56 | Cark | ~ping ? |
| 23:56 | clojurebot | PONG! |
| 23:57 | Cark | he's not that smart ! |
| 23:57 | Cark | how about the whole doc thing |
| 23:57 | ayrnieu | he doesn't even get confused by considering that "I know 192 things" is also something he knows. |
| 23:57 | Cark | that should boost his knowledge a little bit |
| 23:58 | hiredman | svn rev 1155 |
| 23:58 | hiredman | clojurebot: well? |
| 23:58 | clojurebot | No entiendo |
| 23:59 | hiredman | svn rev 1251 |
| 23:59 | hiredman | oh |