#clojure log - Dec 23 2010

The Joy of Clojure
Main Clojure site
Google Group
IRC
List of all logged dates

0:05 joshua__: I'm using congomongo and I have a database with one record in it. Calling destroy! on that one record isn't doing anything.

0:05 Thoroughly confused.

0:07 amalloy: joshua__: you call destroy!, not on a record, but on a where clause, is my recollection

0:07 a consequence of this is that (destroy! {}) will delete the whole database

0:08 i mean, i guess a record evaluates to a where clause that identifies itself perfectly, so maybe that ought to work

0:09 scottj: on old congomongo I think you could do (destroy! :collection {})

0:09 joshua__: I figured that out just a second ago =).

0:09 amalloy, you right.

0:10 amalloy, the problem for me was that the examples didn't show a where clause they showed an object and as it turned out that object was simple enough that you could use it as the where clause safely.

0:11 amalloy, but my object was a bit more complicated

0:11 amalloy, so if I used the object as the where clause it didn't delete anything.

0:11 amalloy, deleting based on the key of the item I wanted to delete worked though

0:12 $(doc destroy!)

0:12 &(doc destroy!)

0:12 sexpbot: java.lang.Exception: Unable to resolve var: destroy! in this context

0:13 joshua__: oh wells

0:28 ossareh: lo all

0:32 bhenry: am i doing something wrong or can i really not use cake without having ruby?

0:39 tomoj: any gloss users around? trying to figure out how to encode [[1 2 3] [4 5 6] [7 8 9] [10 11 12]] as "4,1,4,7,10,2,5,8,11,3,6,9,12", where the "4" at the beginning is a length prefix

0:40 and actually, each tuple position has a different type, so you get one length prefix and then three lists of that length of different types

0:41 amalloy: tomoj: have you tried writing a function to do that in clojure, before worrying about how to do it with gloss?

0:41 tomoj: no, it's too late

0:41 amalloy: ?

0:41 tomoj: but that's fairly easy

0:42 &((fn [v] (cons (count v) (apply mapcat vector v))) [[1 2 3] [4 5 6] [7 8 9] [10 11 12]])

0:42 sexpbot: ⟹ (4 1 4 7 10 2 5 8 11 3 6 9 12)

0:43 amalloy: tomoj: and with such a function, you could give gloss a less complicated structure, right? just ask it to send all those numbers?

0:44 tomoj: hmm

0:44 joshua__: What is gloss?

0:44 tomoj: https://github.com/ztellman/gloss/wiki

0:44 I could use a function like that to compile a new frame dynamically upon receiving the length prefix

0:44 but that would be slow

0:45 amalloy: tomoj: well, i've barely even looked at gloss, so i'm mostly just trying out ideas to see if any of them stick

0:56 tomoj: you said the tuples have different types - those types are known at compile time, right?

0:56 tomoj: yes

1:11 amalloy: tomoj: it doesn't look possible to me without compiling a new frame on receipt. the gloss repetition primitives assume that they'll either have a built-in prefix, or will be allowed to consume everything it sees

1:11 tomoj: right

1:11 I have cooked up something with header that seems to do the trick

1:11 amalloy: if the variance in sizes is small, you could precompile all the frames that you might need

1:11 tomoj: right

1:12 amalloy: tomoj: really? i'd like to see it, if you don't mind

1:12 tomoj: https://gist.github.com/0d834768928c7e484b38

1:13 amalloy: ah. yeah, that's all i could come up with too

1:13 tomoj: then I call it like (tuple-list :int16 coordinate :byte :byte) to generate a codec which encodes a list of tuples like <coord, byte, byte> into a short-prefixed list of all coords, then bytes, then bytes

1:15 amalloy: right

1:17 tomoj: unfortunately I can't see how to make a coordinate codec that splits up bytes

1:17 I think someday gloss/aleph/lamina will be pure awesome

1:20 amalloy: tomoj: like have 4-bit numbers, you mean?

1:20 tomoj: exactly

1:21 I guess it's fairly easy with a custom Reader/Writer implementation

1:41 s/I think someday // s/will be/are/

1:49 amalloy: can someone help me understand the timing and execution-ordering, during syntax-quote/macro/eval stuff? https://gist.github.com/752664 is a brief example of something that seems like it "should" work but doesn't

1:55 zvrba: ok, i like the ideas behind the JVM and clojure, but i can't stand Javas crappy OO-API. is there a Clojure library that makes, at least, I/O and conversions as simple as in C?

1:55 i'm talking about fopen/fgets/atoi/sprintf/sscanf/..

1:56 i don't want to spend an afternoon plowing through java docs just to open a file.

2:03 amalloy: zvrba: clojure.java.io isn't bad

2:05 but you won't find fgets

2:05 zvrba: is there a better-formatted documentation than http://richhickey.github.com/clojure/clojure.java.io-api.html

2:06 amalloy: http://clojuredocs.org/clojure_core/clojure.java.io/reader is probably worse-formatted for quick reference, but has example usages and stuff

2:06 zvrba: oh

2:06 nice

2:07 ngw: nice

2:07 didn't know that

2:07 amalloy: http://clojure.org/cheatsheet can be useful to find out what name to use for a function you're thinking of

2:07 but it doesn't have clojure.java.io, just the core stuff

2:08 zvrba: ok, that cheat sheet is one of the best i've seen :-)

2:09 now. i've started to write some small programs in common lisp. and i'd like to learn some lisp-like language.

2:09 what would be the advantage of "switching" to clojure, if any?

2:10 or.

2:10 amalloy: zvrba: well, it's better. duh :)

2:10 zvrba: amalloy: :) in what way?

2:10 btw, does emacs slime work equally well with clojure as with CL?

2:10 (note: i'm using windows)

2:10 amalloy: zvrba: quite well, but not equally well

2:11 zvrba: a year ago I tried to use netbeans/eclipse/jetbrains plugin for clojure, and none worked well.

2:13 amalloy: zvrba: clojure has more convenient names and syntaxes for almost everything; this really adds up over time. it's also very nice to (a) run anywhere java runs, and (b) be able to use any java library. the community is friendlier...

2:15 it leans very heavily on functional programming and lazy sequences, which leads to some amazing conclusions, but it has good support for non-functional, mutable stuff for when a functional style would be unnecessarily tangled

2:15 zvrba: amalloy: can you give a concrete example of more convenient names?

2:15 right, i wanted to get my hands more dirty with functional progrmaming.

2:16 i guess clojure is better for that; it's way too easy to fall back to imperative style in CL

2:16 amalloy: well, it's been a while since i've used CL. but i seem to recall that CL's syntax for a hash-map is something like (hash-map 1 a 2 b) or something?

2:16 zvrba: you mean, hash literals?

2:16 amalloy: yeah

2:16 zvrba: i don't know, didn't need that yet :)

2:16 amalloy: heh

2:17 zvrba: i've written just small pieces of code in CL, no serious big projects

2:17 amalloy: well okay, even just lists/vectors

2:17 zvrba: i see that clojure is not uniform -- sometimes I have to use [], and sometimes ()

2:17 it seems kinda ugly and that I have to learn special cases of when to use what

2:17 amalloy: zvrba: i was about to get into that, actually. you will realize that it's "get to"

2:18 zvrba: "get to"? I didn't get that :)

2:18 amalloy: you "get to use" [] intead of()

2:18 zvrba: ah, so I can choose which i will use?

2:19 amalloy: if you want a list of a, 1, and the symbol 'c in CL, you have to write (list a 1 'c); that's available in clojure, but far more usual is [a 1 'c]

2:19 zvrba: ah

2:19 one thing that annoyed me in CL: '(1 2 3) is a literal list that can be modified at run-time

2:19 [a 1 'c] is literal list, but can it be modified at run-time?

2:19 amalloy: zvrba: hardly anything can be modified at runtime

2:20 zvrba: and is there a difference between (list a 1 'c) and [a 1 'c] ?

2:20 (in CL, (list a 1 'c) *always* generates a new list)

2:20 (whereas '(a 1 c) is a "singleton", in the lack of a better name)

2:20 amalloy: zvrba: there is! (list a 1 'c) is a linked list of cons cells; [a 1 'c] is a magic clojure data structure with fast random access as well as fast appends to the end

2:21 well, i say "appends". like most clojure things, you don't actually change the vector, you just get out a new structure that's different

2:21 zvrba: mhm

2:21 does Clojure also accept '(a 1 c) syntax?

2:21 amalloy: yeah

2:21 zvrba: goodie

2:22 amalloy: but that doesn't get you the value of a; it gets you the symbol a, just like CA

2:22 CL

2:22 zvrba: i know

2:22 or

2:22 amalloy: &(reduce + (map inc [1 2 3]))

2:22 sexpbot: ⟹ 9

2:22 zvrba: uh

2:22 amalloy: is an example of something you can express much more succinctly and naturally in clojure than in CL

2:23 zvrba: i'd like to start with clojure, but I hesitate because I don't really want to mess with standard java API, but i must if i want to do anything useful :/

2:23 i seriously personally think that Java API is an abomination and an example of how NOT to design software

2:23 amalloy: ah, function names are self-evaluating?

2:23 no need for quoting?

2:24 amalloy: zvrba: mmmm, something in between

2:24 clojure has one namespace that contains both functions and variables/locals/whatever

2:24 so you don't have to use #' to specify which you mean

2:25 zvrba: ok

2:25 which IDE is most stable?

2:25 amalloy: zvrba: meh. i like emacs

2:25 zvrba: :)

2:25 amalloy: it's most popular, but eclipse is getting traction

2:26 zvrba: does "apropos" and "describe" work?

2:26 i don't want to use eclipse.

2:26 period :)

2:26 amalloy: zvrba: i don't know

2:26 zvrba: ok, when you write (reduce ..) do you get sensible names as hints in the status-row?

2:26 amalloy: zvrba: yeah, eldoc works

2:26 zvrba: when I used CLISP, all I got was (reduce arg0 arg1..) which was totally useless

2:27 with ClozureCL I get sensible names, e.g. (reduce function seq ...)

2:27 ok, that was useful to know

2:27 amalloy: when i write (reduce ..), the minibuffer reads ([f coll] [f val coll])

2:27 zvrba: good, that's what I was interested in :)

2:28 do you use it under linux or windows?

2:28 any hints about emacs setup?

2:28 amalloy: ubuntu 10.04

2:29 Raynes: http://www.assembla.com/wiki/show/clojure/Getting_Started_with_Emacs

2:29 amalloy: ah, thanks Raynes

2:31 Raynes: It's a tiny bit outdated though. The elisp binaries for Clojure stuff are in phil's own repo.

2:32 Newer versions anyway.

2:32 zvrba: ok, thanks

2:33 amalloy: zvrba: you can do a lot of stuff without having to call java libraries, if that bothers you, especially as a lot of them have clojure wrappers already

2:36 i usually use the java builtins for things like strlen, but clojure.string contains equivalent stuff if you prefer

2:37 zvrba: i'd prefer wrappers around Java APIs for common stuff, yes

2:40 amalloy: &(count "a string") ; treats the string as a sequence of characters

2:40 sexpbot: ⟹ 8

2:45 zvrba: what is leiningen ?

2:46 amalloy: zvrba: a build/dependency tool to save you from java

3:45 zvrba: find anything you like?

3:50 zvrba: amalloy: haven't started yet. real-life chores, heh. i think i'll go with emacs.

4:53 LauJensen: Morning all

4:54 raek: Ningmor Lau

5:28 dsop: hmm it seems that (string (http-agent "http://foo" :method "POST" :connect-timeout 100)) hangs forever

5:42 AWizzArd: dsop: I also was using http-agent until recently. But this lib was stopped, and I suggest you to better switch to the Apache HTTP Client.

5:42 dsop: AWizzArd: hmm k

5:43 why do they stop libs in contrib?

5:43 AWizzArd: dsop: because a http client is a complex tool. It takes months and months to develop a feature rich one that is also stable.

5:44 Raynes: Why switch to apache-http-client direction? Check out clj-http. It's a nice wrapper and is designed similarly to ring.

5:44 mids: Raynes: I don't think clj-http allows you to set timeout values though

5:45 Raynes: There is no shorted of Clojure HTTP clients though. Might be one that does.

5:46 dsop: Raynes: afaik clj-http doesnt work on appengine

5:48 AWizzArd: Raynes: a wrapper is fine, but it still needs something substantial under the hood. This would be the Apache client, or maybe the one from JBoss.

5:48 And the question is: does a wrapper significantly increase your productivity?

5:49 Raynes: Not having to read Java docs and learn a new Java API certainly does. At least for me. Nonetheless, if clj-http and clj-apache-http don't support timeouts, then there isn't much of a choice in the matter.

5:50 AWizzArd: Those wrappers can indeed help, for the most basic tasks. One will read a few minutes the docs and can start. Reading the Java docs might require the double time, such as 8 minutes vs 4.

5:50 And for 20 minute projects this is a big win.

5:52 But for real applications you have needs such as specifying that you can accept gziped replies, cookie management, NTLM Authentication, etc.

5:53 Raynes: My point is that Clojure is more accessible to Clojure programmers. If there is a Clojure library/wrapper library that does what you need, I wouldn't see the purpose of using a Java API directly unless there was some real need for it. Readers of your code will thank you.

5:54 dsop: I prefer clojure wrappers over java interopt

5:54 sandGorgon: while invoking lucene from clojure, I get back a TermEnum, which is a custom enumerator class with prev and next. Now I need to run a map on this TermEnum - which I can do because clojure " Don't know how to create ISeq from". How do I solve this ?

5:54 AWizzArd: Difficult to answer this in general.

5:55 sandGorgon: s/can/cant/

5:55 sexpbot: <sandGorgon> while invoking lucene from clojure, I get back a TermEnum, which is a custom enumerator class with prev and next. Now I need to run a map on this TermEnum - which I cant do because clojure " Don't know how to create ISeq from". How do I solve this ?

5:55 AWizzArd: Wrappers have their own set of advantages and disadvantages.

5:55 raek: sandGorgon: you could make your own lazy seq

5:55 AWizzArd: I prefer what makes me more productive. This can be a wrapper, but this can also be the original API.

5:56 sandGorgon: raek, i thought something like that was the answer - any examples on that ?

5:56 _mst: sandGorgon: I usually do something like this: (take-while identity (repeatedly #(when (.next terms) (.term terms))))

5:56 (where terms is your TermEnum)

5:56 raek: (defn term-seq [t] (when t (cons t (term-seq (.next t)))))

5:57 sandGorgon: assuming .next returns nil when there are no next thing

5:57 (defn term-seq [t] (lazy-seq (when t (cons t (term-seq (.next t))))))

5:57 I meant...

5:58 it isn't very lazy without the lazy-seq part... :-)

5:59 sandGorgon: raek, ok.. good starting point. I'll figure it out from that - thanks!

6:10 raek: sandGorgon: I just peeked into the javadocs for TermEnum. it turns out .next does not return a new thing, but changes the object in-place. so you cannot use my approach

6:10 also, that class is deprecated

6:12 sandGorgon: raek, oh ? thanks for doing that

6:14 raek, the java code was something like "while(terms.next()){ Term term = terms.term();} . Why does in-place affect your code ?

6:20 raek: my snippet incorrectly assumed that terms.next would return a new "terms" object, rather than a boolean

6:21 (defn term-seq [terms] (lazy-seq (when (.next terms) (cons (.term terms) (term-seq terms)))))

6:21 this would work

6:22 the resulting seq is also thread safe, if term-seq is the only thing that gets the terms instance

6:23 but the underlying terms object is not

6:23 so clojure fixes it :-)

6:34 sandGorgon: raek, awesome - thanks !

6:47 AWizzArd: dsop, Raynes: the clj-http wrapper looks good and clean. The timeouts can still be set up through the API. The wrapper wraps the Apache HTTP Client.

6:48 Raynes: AWizzArd: Right. I figured that timeouts could be set *somehow*.

6:48 dsop: AWizzArd: I try it, but as said I ran into troubles using a couchdb wrapper that uses clj-http because some stuff was forbidden on appengine

6:48 so I hvae to check if clj-http works on appengine

6:50 AWizzArd: Ah okay, I missed the appengine part.

6:50 But doesn't the appengine offer you a http client?

6:50 dsop: yes kindof

6:50 but I prefer getting a clojure version :)

6:51 AWizzArd: Well, the Apache Client seems to work. So in principle clj-http should too.

7:33 dsop: AWizzArd: just as a side note: http client v4 doesnt work on appengine out of the box

7:38 fliebel: morning

7:49 Dranik: I'm using swank-clojure. Trying to C-x, C-e on (println "Hello, World!") but nothing happens. How can I evaluate a clojure form?

7:50 mrBliss: Dranik: println returns nil, so you won't see the "Hello, World!"

7:51 AWizzArd: dsop: not nice

7:51 Dranik: mrBliss, so which command should I use?

7:52 mrBliss: Dranik: I don't think there is a version of print that also returns the string, but if you're just checking if C-x C-e works, you can just eval "Hello World"

7:52 Dranik: mrBliss, Bingo!! :-)

8:13 raek: Dranik: when evaluating (println "Hello, World!"), the text appears in the repl buffer (*slime-repl clojure*)

8:26 fliebel: What do the WP bloggers among you use to highlight Clojure? (or embed gists)

8:29 Raynes: fliebel: Syntaxhighligher works well.

8:29 fliebel: Look for the "Syntaxhighlighter Advanced" or whatever plugin.

8:30 fliebel: Raynes: I found evolved, if that's what you mean.

8:30 Raynes: Yeah, that's it.

8:30 I use it.

8:30 fliebel: *checks some code on Raynes site*

8:32 Raynes: The only code I see is a rather ugly darkblue and has needless scrollbars :( But it seems it does Clojure just fine.

8:33 *do

8:33 no wait

8:33 oh, whatever

8:33 cemerick: fliebel: WP.com has clojure highlighting baked in

8:34 Raynes: fliebel: All of that can be changed on the settings page.

8:34 fliebel: cemerick: I'm self hosting. But I think what Raynes mentioned is the same they use.

8:34 cemerick: yeah, probably

8:34 * cemerick has no patience for self-hosting :-)

8:35 fliebel: cemerick: long live automation :) I'm planning to set up a multisite to manage sites for my clients as well. I fear some of them might be running WP 2.3 or something like that ;)

8:36 cemerick: I self-hosted WP for a couple of years. It seems like you really need to know php and the security bits around it to make it work well.

8:37 The pain associated with always having to carefully port (necessary) tweaks given a new version of WP was what really pushed me off of it.

8:38 fliebel: cemerick: I know those :) What kind of tweaks? 'official' tweaks(plugins) are fairly consistent across versions as far as I know.

8:39 * fliebel is engaged in WP discussion on #clojure once again...

8:39 cemerick: fliebel: I'm sure I don't remember. This was years ago.

8:40 fliebel: cemerick: Good for you, if you can live with WP.com ;)

8:42 cemerick: Does it have downsides I don't know about?

8:43 Raynes: The only time I ever had to touch PHP was to define a couple of documented constants in the config file when I moved the site to new servers.

8:48 Gigaroby: guys is there any function to map every value of a list with a increasing number --> (index ("a" "b")) => ((0 "a") (1 "b"))

8:49 I do know how to implement it but I was just wondering if there is any alredy made

8:50 mrBliss: Gigaroby: clojure.contrib.seq/indexed but I thought map-indexed also existed

8:50 fliebel: Gigaroby: I was also about to suggest map-indexed

8:50 Gigaroby: mrBliss, thanks but I do need the not-map indexed

8:50 Raynes: &(keep-indexed vector ["a" "b" "c" "d"])

8:50 sexpbot: ⟹ ([0 "a"] [1 "b"] [2 "c"] [3 "d"])

8:51 mrBliss: http://clojuredocs.org/clojure_core/clojure.core/map-indexed

8:51 fliebel: Raynes: keep will trow out nil values.

8:51 Raynes: fliebel: Who needs 'em

8:51 fliebel: &(keep-indexed vector ["a" "b" "c" nil "d"])

8:51 sexpbot: ⟹ ([0 "a"] [1 "b"] [2 "c"] [3 nil] [4 "d"])

8:51 Raynes: ;)

8:51 fliebel: hm

8:52 Raynes: fliebel: It doesn't because the result of the function will never be nil.

8:52 Nonetheless, I guess map-indexed works just as well: ##(map-indexed vector ["a" "b" "c" "d"])

8:52 sexpbot: ⟹ ([0 "a"] [1 "b"] [2 "c"] [3 "d"])

8:53 Gigaroby: the first was fine thanks cause then I need to pass it to a (every? #(not= %1 %2) (whatever))

8:56 raek: &(map vector (range) ["a" "b" "c" "d"])

8:56 sexpbot: ⟹ ([0 "a"] [1 "b"] [2 "c"] [3 "d"])

8:56 Gigaroby: turned out I need map cause I need to start from a number different from 0

8:57 still thank you guys

8:58 raek: if you just destructure the vector and pass the parts to a function, it can make sense to replace 'vector' with the consuming function

8:59 sandGorgon: i'm calling a function within a function - but the functions are defined separately. can I access the variables of the parent function from within the nested function's body ?

9:00 raek: a function that is created inside another can do that

9:01 sandGorgon: raek, actually I have a filter that is being used, which needs to access the variables of the parent function. but I cant pass more than one variable to a filter function right ?

9:03 raek: you could do something like this: (defn filter-divisible [n coll] (filter (fn [x] (zero? (mod x n))) coll))

9:04 sandGorgon: of course ... i was hoping there was a better way.

9:04 raek: the anonymous function remebers (closes over) the environment where it was created

9:06 if you have a complex function defined elsewhere you would like to use, you can "adapt it" with an anonymous function:

9:06 (defn divisible [x n] (zero? (mod x n)))

9:06 (defn filer-divisible [n coll] (filter #(divisible? % n) coll))

9:06 Dranik: raek, well, my *slime-repl clojure* does not show anything...

9:07 raek: Dranik: for me, it appears _above_ the "user>" prompt

9:07 Dranik: it just prints the input line like USER>

9:08 sandGorgon: raek, what was your syntax - what is it doing exactly ?

9:08 Dranik: raek, yeah, that is supposed to be so. But my slime does not show it

9:08 how did you prepare your emacs?

9:08 raek: #(divisible? % n) is the same as (fn [%] (divisible? % n))

9:08 % is just a symbol

9:09 #(...) is just syntactic sugar for the fn form

9:09 Dranik: what happens if you eval the println in the repl?

9:09 Dranik: user> (println "Hello, World!")

9:09 Hello, World

9:10 raek: and ewhen evaluating that in another buffer, nothing happens? (besides the minibuffer displaying "nil" for a second)

9:11 sandGorgon: that reader macro is documented here: http://clojure.org/reader

9:11 sandGorgon: raek, oh .. now I see what you have done. just one question : are "divisible" and "divisible?" interchangeable ?

9:12 raek: oh. no... that's just a typo :-)

9:13 Dranik: also, is clojure-mode activated for that other buffer?

9:13 Dranik: raek, how to activate it?

9:13 bcs something is happening when i press c-x, c-e

9:13 raek: M-x clojure-mode

9:13 Dranik: but definietely not what I supposed

9:13 raek: should happen automatically for .clj files

9:14 Dranik: it could be that you are evaluating emacs-lisp...

9:14 Dranik: yep

9:14 clojure-mode was activated

9:14 raek: I tested this with my very basic emacs setup (clojure-mode, slime and slime-repl from ELPA)

9:14 Dranik: the same

9:15 raek: note that only the output of print* works this way

9:15 the return value is not displayed in the repl

9:16 I usually enter what I want to evaluate in repl

9:16 and use C-M-x or C-x C-e just for reevaluating definitions

9:30 Gigaroby: is there any way to get this (some = <stuff>)

9:30 return faolse

9:30 *false instead of nil

9:31 bhenry: Gigaroby: wrap it in boolean

9:32 ,(boolean (some #{1} [2 3 4]))

9:32 clojurebot: false

9:33 Gigaroby: thanks

10:11 (defn pair-equal? [[x y]] (= x y)) is that [[x y]] a valid destruct ?

10:13 chouser: yep

10:13 Gigaroby: ty

12:10 karthik6_: any body is from india

12:33 Lajla: Yes

12:33 any body is from india

13:16 dnolen: *unchecked-math* is nifty when you need it.

14:53 gju_: hey

14:54 how can i execute code sequentially?

14:54 technomancy: gju_: wrap it in a "do" form

14:54 gju_: oh.

14:55 sec, i try. :)

15:00 well... i guess it works. but i have another question.

15:00 when i use a method that doesn't return a value but instead changes one of its parameters. how do i express that in clojure?

15:01 technomancy: all functions return values. sometimes that value is nil.

15:01 gju_: in this case its RandomAccessFile's read method which expects a buffer

15:01 wel... yes ok. but do you know what i mean?

15:02 technomancy: not really. are you having trouble calling the .read method on a RandomAccessFile instance?

15:02 gju_: yes.

15:03 i try it like this

15:03 (. file read buffer 0 3)

15:03 but it says that "buffer" is unresolvable in this context

15:03 but i actually don't know any better.

15:05 technomancy: gju_: you'll need to construct a byte array for that; something like (make-array Byte/TYPE 1000)

15:15 gju_: works. nice. thanks.

15:15 looks weird tho...

15:21 maybe someone could give me some suggestions:

15:22 http://pastie.org/1401445

15:23 amalloy: gju_: (let) has an implicit do, and allows multiple bindings

15:24 so you could write (let [x 1 y 2] (stuff) (more stuff))

15:25 gju_: ok

15:25 amalloy: there's also the handy-dandy doto macro: ##(macroexpand '(doto file (.seek 10) (.read buffer)))

15:25 sexpbot: ⟹ (let* [G__9287 file] (dot G__9287 seek 10) (dot G__9287 read buffer) G__9287)

15:25 gju_: ah

15:25 i guess i know what it does...

15:25 sequences of method calles to a specific object?

15:26 amalloy: yeah, though technically it's more general than that

15:27 i assume you're coming from a lisp background; clojure's = returns true or false, not t or nil

15:28 gju_: i played with cl a litte in the past. so yeah kinda.

15:33 amalloy: gju_: so https://gist.github.com/1f671546d31182bc746c is probably how i would write it. the -> stuff at the end is a matter of taste; i don't think it's substantially better than the way you did it, but i'm putting it there to expose you to ->

15:35 &(macroexpand-all '(-> buffer String. (.equalsIgnoreCase "TAG")))

15:35 sexpbot: ⟹ (let* [obj-class__6346__auto__ (clojure.core/class (new String buffer))] (let* [temp__3586__auto__ (clojure.core/some (if (clojure.core/map? clojail.core/tester) (let* [map__9304 clojail.core/tester map__9304 (if (clojure.core/seq? map__9304) (clojure.core/apply cloj... http://gist.github.com/753516

15:36 amalloy: oh god. i forgot the . calls turn into a huge mess when macroexpanding in sexpbot

15:36 ignore that, gju_ :P

16:06 programble: anyone know how easy/hard it is to use Slick2d with clojure?

16:20 is there a project.clj spec anywhere?

16:30 lrenn: programble: https://github.com/technomancy/leiningen/blob/master/sample.project.clj

16:30 programble: that's about the closest thing there is.

16:31 programble: found that before you said it but thanks

16:31 and that kinda sucks :\

16:31 i think i found what i needed though

16:36 technomancy: programble: what's wrong with it?

16:37 programble: it isn't exactly documentation

16:37 and i think cake might have some extra ones that it has no docs for

16:37 technomancy: sure, can't help you there.

16:58 amalloy: programble: what info are you looking for? i use technomancy's sample for reference

16:59 programble: amalloy: nah i'm good, needed to know how to add another maven repo

17:00 amalloy: sounds like you found it anyway, but https://github.com/amalloy/clojopts/blob/master/project.clj#L7

17:01 programble: grrr my internets broke

17:02 :\

17:02 my router responds to pings and has port 80 open but i can't access its page

17:07 anthony_: I'm trying to integrate clojure with SWT. On a MenuItem, you set the accelerator using setAccelerator, which takes an int parameter, such as SWT.MOD1 + 'A' (SWT.MOD1 is an int). I'm having trouble casting a char to an int in clojure, though. Am I missing something simple?

17:07 amalloy: &(int \A)

17:07 sexpbot: ⟹ 65

17:08 amalloy: anthony_: that's what you want, right?

17:08 anthony_: That's exactly what I want. I'm ashamed of myself. Thanks.

17:08 amalloy: welcome

17:14 anthony_: I'm sure I have something fundamentally wrong. If I put this into the REPL: '(1 (+ 2 3) 4) why do I get (1 (+ 2 3) 4) instead of (1 5 4) ? I didn't quote the inner parenthesis. Is there any way to get it to return the list (1 5 4) ?

17:15 amalloy: anthony_: ' quotes an entire form. you probably want ##[1 (+ 2 3) 4]

17:15 sexpbot: ⟹ [1 5 4]

17:15 amalloy: er...i guess ## there might be confusing. that's just to tell sexpbot to eval, not part of the code

17:16 anthony_: Gotcha. So I just use [ ] ?

17:16 amalloy: yeah, [] is the vector syntax, which is used for most non-lazy data structures

17:16 anthony_: I didn't think about using a vector instead. I think that will work for me.

17:17 Okay, thanks. I have almost no Lisp exposure, but the little I do have has me always wanting to use lists when I shouldn't. :)

17:17 amalloy: heh

17:17 it's very handy to have a non-quoting literal syntax for lists, for exactly the reason you describe

17:19 anthony_: Definitely. I'm beginning to see the benefits of code and data being represented the same.

17:23 Derander: I really need to write my lispruby

17:23 I want to see if that works at all

17:44 raek: anthony__: if you really want a list, you can construct it with ##(list 1 (+ 2 3) 4)

17:44 sexpbot: ⟹ (1 5 4)

17:44 raek: vectors also has such a function: ##(vector 1 (+ 2 3) 4)

17:44 sexpbot: ⟹ [1 5 4]

17:45 raek: so a literal vector is very much like a call to 'vector', but a literal list does not behave this way

17:46 but as amalloy said, [] is the usual way to do it

17:48 arohner: does anyone have any good tools for measuring cache misses? I'm not familiar with the tools available on OSX & JVM

18:04 programble_: how do you do a float literal in clojure?

18:07 cemerick: programble_: you don't, AFAIK. ints and doubles are given priority. For interop purposes, you can use (float …)

18:07 tonyl: programble_: as far as i know there isn't

18:07 cemerick: ,(class (float 5.0))

18:07 clojurebot: java.lang.Float

18:08 programble_: that worked

19:41 anome: hi there

20:26 rata_: hi all

20:31 what was that?

20:31 Raynes: $google netsplit

20:35 amalloy: Raynes: sexpbot dropped too

20:35 rata_: I have a performance problem with clojure... I've written a app that iterates and has a similar cost per iteration until 30 mins running... after that it loses the linear relation between number of iterations or steps and time

20:35 Raynes: yes, but I've search for it by myself =)

20:35 Raynes: amalloy: I never would have guessed.

20:36 ;)

20:37 amalloy: rata_: probably not cleaning up all the memory you're using

20:37 and after ~30min it runs out of real memory and starts swapping everything

20:37 rata_: and looking for the reason why after a certain number of steps it becomes slower, I used visualvm and it says sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run is using up to a 68% of the time

20:37 ok... so how can I clean up all the memory I'm using?

20:38 amalloy_: rata_: make sure not to keep references (direct or indirect) to objects you don't need. that's all it takes to get the gc to do the cleanup. afk now though

20:39 rata_: amalloy_: but the gc is doing its task correctly... I doesn't throw an out of memory execptioin

20:39 *exception

20:40 should I use a more aggressive gc?

20:40 is the sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run method related to the GC?

20:41 (I'm not using RMI in my app)

20:42 the problem seems to be that the GC can do its work, but it does it slowly

20:52 amalloy_: ^

20:55 amalloy: rata_: i would guess that ConnectionHandler is delegating to your app and isn't really using up much cpu itself, but this isn't an area i know a lot about

20:59 rata_: mmm ok

21:05 what's a good GC for persistent data structures?

21:57 still wondering what are good GC options for a clojure app in which there is a huge record that contains several nested persistent data structures and changes constantly

23:11 count is strict, right?

Logging service provided by n01se.net