#clojure log - Nov 15 2009

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

0:16 cross: hey folks... does anyone know of a built neman cells jar? i'm having all sorts of trouble building it

1:00 aking: ztellman: thanks for penumbra - asteroids and tetris are both neat little example clojure games!

1:06 ztellman: aking: glad to hear it

3:25 scottj: I'm trying to use cljdb and I have ~/src/foo on my classpath and in that dir I have a file bar.clj with (ns bar) and after connecting with slime, loading the file with C-c C-k, and then attaching with jdb, if I try to set a breakpoint it says Deferring breakpoint bar:12. It will be set after the class is loaded. Any ideas?

5:07 Jetien: hi! i'd like to generate some def calls. i thought you could generate some strings for the names and then use something like (def (symbol "foo") bar), but this throws and error.

5:11 _ato: Jetien: the symbol needs to be available at compile time

5:12 this would be one way: (eval `(def ~(symbol "foo") bar))

5:13 Jetien: thanks! i don't understand how clojure works under the hood yet - when is the code compiled and when is it evaluated?

5:13 _ato: looks like using a macro also works: (defmacro defstr [name value] def ~(symbol name) ~value))

5:13 (defstr "foo" bar)

5:14 oops, mispaste, that should be: (defmacro defstr [name value] `(def ~(symbol name) ~value))

5:19 Jetien: what can i read to understand the compilation process of clojure?

5:20 or evaluation process

5:22 _ato: sorry... I think I'm full of it :-P actually the problem is just that the def special form doesn't evaluate it's argument

5:22 otherwise you'd have to write (def 'foo) everywhere

5:22 and the macro/eval gets around that

5:23 Jetien: ah okay :)

5:24 _ato: so when it sees the (symbol "foo") it sees a list containing a symbol 'symbol and a string and tries to cast that list to a symbol, hence the exception

5:25 Jetien: i see. i was puzzled because (class (symbol "foo")) = clojure.lang.Symbol - so the exception made no sense to me

5:25 _ato: yep

5:25 ,(class '(symbol "foo"))

5:25 clojurebot: clojure.lang.PersistentList

5:34 Jetien: (defstr "foo" 3) works but not (defstr (ex) 3) where (ex) is an expression that yields a string

5:42 Chousuke: Jetien: that's because the macro doesn't evaluate the expression.

5:44 Jetien: you can try printing things inside the macro to see what the parameters are. maybe that'll clarify it :)

5:44 Jetien: okay :)

5:52 _ato: ah, of course. Silly me. You'd have to use eval at some point anyway, I guess

8:21 grammati: When I do this: git clone git://github.com/richhickey/clojure.git clojure

8:21 I only get the master branch

8:22 shouldn't I get the newnew branch too?

8:22 or am I misunderstanding how git works?

8:24 _ato: you're missing understanding how it works :)

8:24 when you clone git creates a local "master" based on the remote master

8:24 you can see the remote branche with: git remote show origin

8:25 if you want to create a "new" local branch try: git checkout origin/new new

8:25 err

8:25 git checkout origin/new -b new

8:25 sorry

8:25 and it'll track upstream changes

8:26 the idea is that you can commit stuff to it and it'll automatically be merged with upstream with you pull

8:26 if you don't want to create a branch, just checkout it

8:26 ou can just do: git checkout origin/new

8:27 but you won't be able to commit to it (which maybe what you want anyway)

8:27 grammati: OK, thanks

8:28 That seems like it should work, except that I don't think git really works on Windows, as far as I can tell

8:28 As soon as I clone, it tells me that all my java files are locally modified

8:28 but that's another problem

8:28 Bjering: that is linefeed issue

8:29 http://stackoverflow.com/questions/1474686/git-replaced-all-of-my-lf-with-crlf-how-do-i-fix-this

8:29 gerry`: ,(deftype Person [name age] [java.lang.Comparator] (.compareTo [o] (compare age (:age o))))

8:29 clojurebot: java.lang.RuntimeException: java.lang.ClassNotFoundException: java.lang.Comparator

8:31 gerry`: ,(deftype Person [name age] [java.lang.Comparable] (.compareTo [o] (compare age (:age o))))

8:31 clojurebot: DENIED

8:31 _ato: clojurebot doesn't allow any def forms

8:33 gerry`: ,*clojure-version*

8:33 clojurebot: {:interim true, :major 1, :minor 1, :incremental 0, :qualifier "alpha"}

8:34 gerry`: ,(doc clojurebot)

8:34 clojurebot: I don't understand.

8:35 gerry`: clojurebot: help

8:35 clojurebot: http://www.khanacademy.org/

8:35 gerry`: clojurebot: what?

8:35 clojurebot: what is wrong with you

8:36 gerry`: hmm

8:36 Jetien: ha :)

8:37 gerry`: clojurebot: then?

8:37 clojurebot: It's greek to me.

8:39 Jetien: can you kill clojurebot?

8:39 mauritslamers: question: I want something like map, but without having it include nils in the result

8:39 Jetien: ,(repeat 6)

8:39 somnium: what's with the hostility towards clojurebot =)

8:39 Jetien: :)

8:39 clojurebot: Execution Timed Out

8:40 somnium: mauritslamers: filter identity

8:40 mauritslamers: I tried for with a :when clause, but for will always walk through every binding

8:41 somnium: I stopped using filter, because I don't want to filter afterwards

8:41 because that will force going through the list again and again :)

8:42 which is not a good idea performance-wise

8:42 somnium: ,(for [x (range 50) :when (= 0 (mod x 3))] x)

8:42 clojurebot: (0 3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48)

8:43 mauritslamers: issue being that I have two lists: one with unique values, the other a list with all data... I want all positions of the unique data in the all data list

8:43 positions from clojure.contrib.seq-utils works, but that indexes the collection every time

8:44 I tried something like this: (for [unique uniques-list found-pos (positions #(= unique %) all-data :when (some pred) ] )

8:45 but that also iterates through every position in found-pos

8:45 it would be nice if I could prevent the iteration of that found-pos list..

8:46 let's say that the :when clause should be something like this: :when (> (count found-pos) 1)

8:48 somnium: any idea how to do this?

8:48 somnium: mauritslamers: I'm not sure I follow

8:49 mauritslamers: ok, I'll try to be a bit more clear :)

8:49 I have a list with unique values, derived from a list with patterns

8:50 What I want is a list with positions of every unique value inside the list with patterns

8:50 I have tried a few things, but they all cause problems in some ways

8:50 somnium: positions = indexes?

8:50 mauritslamers: yep

8:51 grammati: mauritslamers: re. your earlier statement: "I stopped using filter, because I don't want to filter afterwards" - are you clear on how the laziness of map and filter work?

8:51 mauritslamers: the list with indexes should only contain the unique patterns that occur more than once

8:51 Yes I know what laziness is :)

8:51 I don't know the exact workings

8:52 somnium: hmm, if you have to keep count of occurrences you probably want to reduce, or maybe loop if necessary

8:52 grammati: OK, it just seemed like maybe you though map would instantiate the whole list, including the values that you will later filer out

8:53 mauritslamers: When I use map for this procedure, I get loads of nils of course

8:53 on different levels

8:54 filtering them out, takes at least two extra passes through the entire result

8:54 somnium: also you can use for like [x xs y ys :let [z (* x y)]] :when ...

8:54 mauritslamers: ah...!

8:54 somnium: for can do quite a lot, and when it can't there's reduce and loop

8:54 mauritslamers: was searching for something like that...

8:54 exactly :)

8:54 I knew there had to be some kind of way :)

8:55 Thanks!

8:58 why do I get an "unsupported binding form :let" ? error

8:59 old clojure version?

9:00 or is it not allowed to have both :let and :when?

9:01 somnium: ,(for [x (range 10) y (range 10) :let [z (* x y)] :when (= 0 (mod z 3))] z)

9:01 clojurebot: (0 0 0 0 0 0 0 0 0 0 0 3 6 9 0 6 12 18 0 3 6 9 12 15 18 21 24 27 0 12 24 36 0 15 30 45 0 6 12 18 24 30 36 42 48 54 0 21 42 63 0 24 48 72 0 9 18 27 36 45 54 63 72 81)

9:05 mauritslamers: somnium: when I try to have this function evaluated, I get the error #<Exception java.lang.Exception: Unsupported binding form: :let>: http://gist.github.com/235236

9:09 the-kenny: mauritslamers: Your code evaluates here fine (If I define a indexed-function)

9:09 mauritslamers: ...

9:09 weird

9:09 somnium: mauritslamers: what clojure version?

9:09 mauritslamers: 1.0 afaik

9:09 it is the clojure.jar that is part of the textmate bundle

9:13 somnium: hmm, just tried with 1.0.1 and it worked

9:13 not sure, maybe get latest clojure 1.0 from github? (or 1.1 if you're going to the trouble)

9:13 mauritslamers: there are more strange things: user=> *clojure-version*

9:13 java.lang.Exception: Unable to resolve symbol: *clojure-version* in this context (NO_SOURCE_FILE:0)

9:14 * somnium blames textmate

9:14 mauritslamers: or the bundle writer in this case :)

9:14 the bundleit is not part of textmate itself

9:15 *bundle

9:18 I'll try the jar from google code

9:18 somnium: netbeans and waterfront are fairly easy to setup alternatives FWIW

9:18 better from github

9:19 google code hasn't been used in a while

9:19 mauritslamers: ok, thanks!

9:19 should I compile my own jars or are there precompiled jars ?

9:19 somnium: github should have some downloads

9:20 but you just need ant to build them :)

9:21 mauritslamers: afaik ant is normally installed in Mac OSX, so that shouldn't be a real problem :)

9:27 compiling clojure worked, now trying to compile clojure-contrib, but that returns errors: cannot find Clojure.lang.compile?

9:30 the-kenny: mauritslamers: Have you specified -Dclojure.jar=path-to-clojure to ant?

9:30 mauritslamers: yep

9:30 the-kenny: otherwise it errors out "not able to find clojure.jar"

9:30 the-kenny: oh hm

9:30 mauritslamers: check_hasclojure:

9:31 [echo] WARNING: You have not defined a path to clojure.jar so I can't compile files.

9:31 no -D option specified here..

9:32 somnium: check_hasclojure: passes when you do specify?

9:32 mauritslamers: with -D option: compile_classes:

9:32 [java] Could not find clojure.lang.Compile. Make sure you have it in your classpath

9:32 I'll post the entire dump, moment

9:33 somnium: http://gist.github.com/235256

9:36 somnium: got it working

9:36 somnium: great, I was clueless :)

9:36 mauritslamers: a path to the file alone is not enough

9:36 I needed to specify the file

9:36 so ant -D../clojure/clojure.jar

9:37 ehh.. ant -Dclojure.jar=../clojure.clojure.jar

9:38 when only -Dclojure.jar=../clojure is specified, things go wrong... bug in build script?

9:38 somnium: no, clojure.jar is just a variable in the build.xml

9:38 mauritslamers: (typing is not one of my strongest points I believe) ... ant -Dclojure.jar=../clojure/clojure.jar

9:41 somnium: hopefully some alternative build tools are coming around soon, I wouldn't recommend getting into ant if you haven't had to already

9:41 mauritslamers: or just an automatic building tool?

9:42 anyway, make stuff work again... next issue: the textmate bundle does not behave as expected ... :)

9:42 Of course I don't expect you to be able to help here much :)

9:43 somnium: can't help with that one, only use emacs and netbeans(for java)

9:43 mauritslamers: np :)

9:43 you helped me more than enough already, thanks!

9:44 somnium: cheers

9:48 mauritslamers: maybe you could be of some help after all... I tracked part of the problem down to a clojure file supplied inside the bundle... It starts the repl on a server... This file contains a function to create a new thread, but its definition results in an error

9:48 (defn on-thread [f]

9:48 (doto (new Thread f) (start)))

9:49 it says: start: unable to resolve symbol

9:49 somnium: hmm, my guess would be it should be .start

9:54 mauritslamers: that solves one issue, and makes room for the next one: [ss (new ServerSocket port 0 (.getByName InetAddress "localhost"))] => .getByName no matching method found??

9:55 (import '(java.net ServerSocket Socket SocketException InetAddress) is in the file above

9:55 The-Kennz: mauritslamers: Is .getByName a static method?

9:56 mauritslamers: The-Kennz: no idea to be honest, I am just trying to get my text mate bundle to work again after replacing the clojure.jar and clojure-contrib.jar files

9:56 The-Kennz: mauritslamers: Try (InetAddress/getByName "localhost)

9:57 s/)/")/

9:57 mauritslamers: solves that issue indeed!

9:58 it comes back with another one, but I think that can be fixed in the same way

9:58 The-Kennz: mauritslamers: You call "normal" java methods with the .methodName, static methods with Classname/methodName

9:58 somnium: was (.foo Bar) valid for static methods in the early days of clojure?

9:58 The-Kennz: Oh, and you don't need new, you can also write (classname.)

9:59 somnium: I don't know.

9:59 mauritslamers: The-Kennz: as I said, I am trying to get it working, it is not my code :)

9:59 The-Kennz: Okay

10:00 mauritslamers: I installed it from git://github.com/nullstyle/clojure-tmbundle.git

10:01 The-Kennz: mauritslamers: It looks like nullstyle has stopped development, but other people has continued his work: http://github.com/nullstyle/clojure-tmbundle/network

10:02 mauritslamers: ah, better :)

10:02 I fixed it by the way, and stuff is working again!

10:04 The-Kennz: thanks for the idea! Someone else improved it greatly, even adding a updating facility with automated building or something like that... :D

11:02 Drakeson: [using the `new' branch ...] How does one search for interfaces that have a particular method?

11:06 spuz: Has anyone used clojure.contrib.profile?

11:07 It seems to store the running time of every execution of each of the code blocks as a list which means it can quickly blow the heap

11:08 It appears there's no reason to store each of the stats that it does so I wonder if there is a reason for it?

12:11 Drakeson: how can I serialize an object to a bytes array?

12:12 for instance, how can I get (1 0 2 0 0 0 3) from [(byte 1) (short 2) (int 3)] ?

12:38 ambient: ,(into-array [1 2 3])

12:38 clojurebot: #<Integer[] [Ljava.lang.Integer;@f2a0ef>

13:05 penthief: Hi, is there a better way than: (cons (first my-list) (cons (second my-list) '())) ?

13:10 maravillas: (take 2 my-list)

14:07 G0SUB: Has anyone written a Clojure version of Knuth's man or boy test? http://rosettacode.org/wiki/Man_or_boy_test

14:38 http://rosettacode.org/wiki/Man_or_boy_test#Clojure

14:44 spuz: G0SUB: I can see a Clojure implementation there :)

14:53 patrkris: If I have a ref with a vector in it, and I want to send off an action to an agent every time the *first* element is added, but not when subsequent elemenets are added, what do I do? Once in a while the list is emptied. It is important that the action sent to the agent sees that the first element has been added (and perhaps elements added in the meantime).

14:57 The-Kennz: patrkris: I'm not sure, but add-watcher could work for refs.

14:57 a watcher is a function which gets called every time an agent (or ref) gets updated

14:58 patrkris: http://clojure.org/api#toc66

14:58 Just add a function that checks if there is only one element in the list.

15:00 patrkris: The-Kennz: thanks for your suggestion - i actually tried using add-watch (not -watchER) but it didn't seem to work. I'll give it a tryk.

15:13 polypus: i would like to write a macro which takes a param vector and a list

15:13 (f [a b] (a b c d))

15:14 and returns a function of this form

15:15 (fn [b d] `(a ~b c ~d))

15:16 having trouble getting it to work

15:18 hoeck1: (defmacro f [a b] `(fn [b# d#] (~a b# ~c d#)))

15:18 polypus: so that i should be able to write ((f [a] (b a t)) 'z) returning '(b z t)

15:19 thanks many, i'll give it a go

15:23 hoeck1: polypus: I don't know exactly what you want to achieve, but maybe a function like (#(list 'b % 't) 'z) will do the same?

15:23 polypus: doesn't do it. i should be able to write ((f [a] (b a t)) 'z) and get the list (b z t) back

15:25 no this is a distillation of a harder problem. i need it to be more general. i really need the behaviour of ((f [a] (b a t)) 'z) -> (b z t)

15:27 i was hoping to be able to have the macro generated function use syntax quote for performance reasons

15:32 i just realized that my first definition was wrong, it should have read (f [b d] (a b c d)), thanks for the help

15:33 hoeck1: guess I didn't help that much :)

15:38 polypus: do you think it is even possible to write a macro which builds a syntax unquoted expression and bundles it up in a function?

15:38 somnium: you can emit any kind of symbol with a macro

15:38 not sure I understand what bundling it up in a function means

15:42 G0SUB: spuz: Yeah, I just wrote it.

15:42 rhickey: protocols - :on is gone

15:52 polypus: bundling up in a function meaning just that from the macro args of a vector [b d] and list (a b c d) the macro will return a function with parameter list [b d] which internally uses syntax quote to return a list where b and d in the original list passed to the macro are replaced by the values passed to the function.

15:52 so for some macro f

15:52 (def g (f [b d] (a b c d)))

15:54 calling function g: (g 4 5) returns the list (a 4 c 5)

15:57 Drakeson: how can I slice an array (or get a sub-array)?

15:57 polypus: so g might look like this internally (fn [b d] `(a ~b c ~d)). but maybe i'm totally barking up the wrong tree

15:59 somnium: polypus: have you looked at definline?

16:00 polypus: no, i will. thx

16:02 rhickey: polypus: there is no point to trying to use syntax-quote here, since you don't know what the args will be. It just expands to calls to quote and list anyway, which is what you'll have to do in your macro

16:04 polypus: ok thx. just a noob trying to wrap my head around this stuff

16:06 rhickey: write a function that when handed '[b d] and '(a b c d) returns '(list (quote a) b (quote c) d), then call it from your macro

16:09 duncanm: i was just thinking, is there a way to 'simulate' the channels in CSP/go-routines using lazy collections/streams?

16:10 technomancy: congrats on the elpa upload, i'm downloading now

16:11 piccolino: What got uploaded to elpa?

16:12 duncanm: piccolino: swank-clojure

16:12 piccolino: Like a new version?

16:42 duncanm: la la la

16:52 ordnungswidrig: hmm

17:13 Draggor: How would I go about delivering my clojure app as a single jar?

17:16 mauritslamers: question: I have a let in which I define a binding. The next binding is actually a function which uses that variable inside. When evaluating that function, I get an error. Could anyone tell me why?

17:18 the error being that it cannot resolve the symbol

17:18 ordnungswidrig: Draggor: do you have dependencies?

17:18 mauritslamers: which is the binding defined first in the let

17:18 ordnungswidrig: mauritslamers: can you paste something to pastebin?

17:18 mauritslamers: ordnungswidrig: of course, thanks!

17:20 ordnungswidrig: http://gist.github.com/235535

17:20 the error:<Exception java.lang.Exception: Unable to resolve symbol: indexed-coll in this context>

17:21 Draggor: ordnungswidrig: I do. Actually using compojure and a couple other things

17:21 ordnungswidrig: mauritslamers: is it the let? check the line no. of the excpetion

17:21 ,(let [a 1 b (* 2 a)] b)

17:21 clojurebot: 2

17:21 mauritslamers: moment, I'll give you the entire function

17:22 ordnungswidrig: Draggor: if you use maven you can use the uberjar plugin. I think it should work with clojure, too

17:22 mauritslamers: ordnungswidrig: please reload the gist

17:24 ordnungswidrig: mauritslamers: When I define a dummy function "indexed" I get no error about indexed-coll. Just about "pattern" not defined.

17:25 Draggor: ordnungswidrig: Don't have maven set up right now, though I did just find this on wikibooks: http://en.wikibooks.org/wiki/Clojure_Programming/Tutorials_and_Tips#Distributing_application_as_self_contained_.jar

17:25 rosejn1: http://sites.google.com/site/rpdillon/creatingexecutablejarswithclojure

17:25 Draggor: rosejn1: Even better, thanks!

17:27 ordnungswidrig: Draggor: you'll have to add you compojure dependencies, of coure. Adding it to the final jar (unzipped) like with clojure.jar should do the trick.

17:27 mauritslamers: ordnungswidrig: strange...

17:27 ordnungswidrig: the definition of pattern is: (defstruct pattern :pattern :found-at)

17:27 ordnungswidrig: Draggor: http://code.google.com/p/jarjar/ will do the job

17:28 mauritslamers: working from the repl? restart it, perhaps something has been garbled?!

17:28 with the definition of pattern it compiles in my repl

17:28 mauritslamers: I restarted the stuff quite a few times already, no change...

17:29 chouser: rhickey: protocol :on was only for performance? I guess you can use deftype on an interface and still redefine it with roughly the flexibility that extend provides?

17:29 ordnungswidrig: me, bed, now.

17:29 see you!

17:30 mauritslamers: sorry, I'm lost. It's bedtime for me anyways. Good luck!

18:09 AWizzArd: In http://www.assembla.com/wiki/show/clojure/Protocols one of the drawbacks of interfaces is mentioned: they create a isa/instanceof type and a hierarchy. Why are those drawbacks?

18:25 _ato: AWizzArd: I'm uncertain, but from what I've read Rich saying about it, part of the reasoning may just be that hierarchy is an unecessary complication

18:25 AWizzArd: ic

18:27 _ato: oh, and you can define a protocol on anything

18:28 like for example you can define it on Object or Nil or somebody else's type

18:28 AWizzArd: Do you have an example where this would be useful?

18:28 _ato: that could get weird if it changed hierachy of the type

18:28 toString() is a simple example

18:29 what if you wanted to make a to-json function that convrts anything to JSON

18:29 you'll want to do implmentations for java types like string and what-not

18:29 and probably default implentation for everything that at least serializes the name of the class

18:31 lisppaste8: Chouser pasted "silly example of extending Integer and String with a protocol" at http://paste.lisp.org/display/90452

18:32 * AWizzArd clicks

18:33 Chousuke: hmm

18:34 I guess you'd need multiprotocols for defining add operations between Strings and Integers :/

18:35 (or rather, integers and Complex numbers :P)

18:35 chouser: right, or regular multimethods

18:36 I said it was a silly example

18:37 _ato: as someone pointed out on the mailint list, the implementation for an interface could be a multimethod (as a multimethid is just a regular function)

18:38 Chousuke: yeah, but that would negate the performance benefits

18:48 dnolen: one thing I'm confused about deftype and defprotocol. so when defining methods in the type do the method have to exist in a protocol?

18:51 Chousuke: no, the method implementations in deftype are for Java interfaces as far as I know.

18:51 if you want to have your type implement a protocol, you'll need to call extend after the type is created.

18:52 though if the protocol is implemented on top of an interface AND a type implents that interface, there should be no need for the extend :P

18:52 implents... implements.

18:54 dnolen: Chousuke: k so if you're programming in pure Clojure, the general pattern is 1. deftype 2. deprotocol 3. extend ?

18:54 Chousuke: I suppose.

18:55 dnolen: trying to understand what the Clojure bits are, and what the interop bits are, easy to get confused :)

18:56 chouser: protocols can't be on top of interfaces anymore

18:57 no need apparently as the call-site caching is faster than the :on feature was

18:58 dnolen: chouser: yeah I saw that. So protocols are now always just a list of functions right?

18:58 _ato: ahh, cool, that reduces the confusion

18:58 chouser: dnolen: sounds right

18:59 dnolen: chouser: it also seems with protocols it would be way simpler to create Clojure version of Java libs no? Like go through all the list of methods and automatically generate protocols? or silly?

19:02 Chousuke: hmm.

19:02 _ato: dnolen: does doing that gain you anything over just using (.foo obj)?

19:03 I guess it could be a way to bridge compatiblity between say different hosts

19:03 or different library implementations

19:03 dnolen: _ato: yes I was about to reply saying that :)

19:04 _ato: although I'd hazard that most of the time you couldn't just do that automatically, at least for one of the implementations

19:06 dnolen: _ato: true

19:07 the-kenny: Very strange things happen in my code...

19:10 Chousuke: dnolen: I'm thinking that eg. for contrib libraries you could perhaps specify some low-level protocols and write the "meat" of the code on top of those.

19:10 and then every host needs to provide code to implement the protocols

19:12 the-kenny: What can cause (take 24 @my-agent) to fail with a NullPointerException when (take 23 @my-agent) works? (last works too, as does nth)

19:12 Chousuke: but I haven't though much about it at all, so it might be a silly idea, even though it sounds good in my current, rather tired state of mind :P

19:12 the-kenny: This behaviour started after the agent ran a log time (some hours or so)

19:12 s/log/long/

19:12 Chousuke: the-kenny: the seq generating function throws an NPE? :/

19:13 the-kenny: Chousuke: Looks so. I think some very strange things are happening here

19:13 Chousuke: be mindful of laziness and dynamic scope .)

19:14 the-kenny: It worked for over 3 hours now. After that, something breaks.

19:14 Chousuke: :/

19:15 the-kenny: New things gets added to the list in the agent, but I can't dereference it anymore.

19:15 Chousuke: oh, well, I need to get some sleep. Good luck with the bug-hunt :P

19:16 the-kenny: Chousuke: I have to go to bed too ;) Can we continue this tomorrow?

19:22 Nevermind, I'll investigate this tomorrow.. night

19:31 hamza: hey guys, i am trying to locate gen-interface function but it is not in contrib or core?

19:31 rhickey: chouser: right, just use extend on an interface instead of :on. With call-site cache and internal cache not ever faster. Plus i made it so higher-order use just as fast also

19:33 chouser: oh! wow.

19:34 _ato: ~def gen-interface

19:34 hamza: ^

19:34 wooby: has anyone written an interpreter for another language in clojure?

19:37 hamza: _ato: thank you.

19:38 i am actually looking for gen-and-load-interface function which is not present in source?

19:40 _ato: gen-and-load-interface no longer exist

19:40 hamza: ok, is there a substitute for it?

19:47 _ato: hamza: I don't think so, you're generally supposed to compile things upfront if you want to use gen-class or gen-interface

19:50 hamza: hmm ok thanks.

19:50 is there a particular reason for removing it? cause to me it just makes things harder.

19:54 dakrone: could someone explain why 'i' isn't being incremented in this? http://paste.lisp.org/display/90457

19:55 _ato: hamza: I don't know, possibly because java doesn't allow classes to be reloaded, so there'd be gotcha situations. the only discussion I could find was this: http://www.mail-archive.com/clojure@googlegroups.com/msg02682.html

19:55 rhickey: hamza: in order consume an interface you need to compile code that knows its name. But it is not generally supportable to expose the names of dynamically created classes, so there are limits to where the name of a generated interface could be seen

19:55 also, such classes can only be loaded once per classloader

19:56 hiredman: dakrone: why would it be incremented?

19:56 maravillas: dakrone: inc doesn't modify the original i

19:56 dakrone: oh duh, this is what I get for programming with a fever

19:57 immutable, duh

19:57 thanks hiredman & maravillas

19:57 hamza: _ato,rhickey thank you both for clarification.

19:57 maravillas: feel better :)

19:57 dakrone: thanks

20:24 hamza: can i type Some.class for a function that expects Some.class as a argument interface is created but i get ClassNotFoundException

20:27 maravillas: try just Some without the ".class"

20:40 lisppaste8: hamza pasted "untitled" at http://paste.lisp.org/display/90458

20:40 hamza: am i missing something? i keep getting class not found although class is present in classes/ folder which is in class path.

20:41 compile causes java.lang.NoClassDefFoundError: java/lang/Library (jna.clj:13)

20:41 _ato: hamza: have you seen http://github.com/Chouser/clojure-jna ?

20:43 hamza: nope, thanks for pointing..

20:47 lisppaste8: _ato annotated #90458 "works for me" at http://paste.lisp.org/display/90458#1

20:51 hamza: thanks, _ato

20:51 _ato: hamza: oh... wait, just realised what the problem is

20:51 hamza: ?

20:52 _ato: you have to specify the full classname in :extends

20:52 notice the error: java/lang/Library

20:52 not com/sun/jna/Library

20:52 hamza: ohh ok, got it.

20:52 _ato: I don't know why gen-class/gen-interface don't pickup the imports

20:53 hamza: now it works.. thanks, nice catch.

20:53 _ato: must be something funny about compilation works

21:14 hamza: what does tilde stand for in this context? ~(namespace s)

21:16 cgordon: I'd like to be able to do something like "(compile (first *command-line-args*))", but I get a class cast exception. How can I convert a String to a symbol?

21:17 chouser: hamza: ~ inside a ` form will unescape

21:18 ,(let [a 5] `(a b c))

21:18 clojurebot: (sandbox/a sandbox/b sandbox/c)

21:18 chouser: ,(let [a 5] `(~a b c))

21:18 clojurebot: (5 sandbox/b sandbox/c)

21:18 chouser: cgordon: symbol

21:18 ,(symbol "string")

21:18 clojurebot: string

21:18 chouser: ,(type (symbol "string"))

21:18 clojurebot: clojure.lang.Symbol

21:18 cgordon: thanks!

21:20 hamza: chouser is ` like '?

21:20 chouser: hamza: a bit, yes. ` is called syntax-quote

21:21 the differences are that syntax-quote supports ~ where quote does not

21:21 hamza: ok..

21:21 chouser: also, syntax-quote namespace-qualifies symbols where quote does not

21:21 ['a `a]

21:21 ,['a `a]

21:21 clojurebot: [a sandbox/a]

21:41 Scriptor: hey everyone, after building clojure-contrib, should I be able to see any of the classes for pprint under classes/clojure/contrib ?

21:42 chouser: Scriptor: I have a large number of files in that dir starting with "pprint"

21:42 qed: how does clojure know when all of the threads have gotten a value? like if we're running some concurrent application that does some calculation on several threads, how does clojure know not to return a partial answer that doesn't include all of the threads?

21:42 chouser: qed: are you talking about agents or something else?

21:43 qed: chouser: yes

21:43 err, yes, agents

21:43 Scriptor: chouser: I don't seem to have any

21:43 qed: someone asked me this question earlier and i didnt have an answer

21:43 Scriptor: building gives a few errors but otherwise it says "build successful"

21:45 _ato: Scriptor: did you specify -Dclojure.jar=/path/to/clojure.jar when you compiled?

21:45 qed: clojure.org is down huh?

21:46 Scriptor: yup

21:46 qed: bummer

21:46 i was hopin it'd have the answer to my question :)

21:46 Scriptor: paste the exact line you tiped in when you built clojure-contrib

21:46 chouser: qed: if you want to combine results from multiple agents, it's your own responsibility to make sure all the calculations you want done have been done.

21:46 qed: Scriptor: also make sure you have the most recent versions of both

21:47 chouser: nono, not to combine them or anything

21:47 Scriptor: ant -Dclojure.jar=../clojure_1/clojure.jar

21:47 qed: just how does clojure know when it has all of the answers from the separate threads?

21:47 Scriptor: I should have the recent versions since I only got them yesterday or so, but I'll check

21:48 qed: chouser: maybe that's a silly question -- im not sure

21:48 _ato: qed: it doesn't? what do you mean by "kno when it has all of the answers" ?

21:49 Scriptor: the .clj files are present, but they don't seem to be compiled

21:49 qed: _ato: like if i have some calculation that finds the result of 100^(some random number between 100 and 1000), some of those will take longer than others

21:49 how does clojure know that it shouldnt return when it only has some of those answers

21:49 Scriptor: during compiling I'm also getting a FileNotFoundException for wal__init.class and walk.clj

21:50 *walk__init.class

21:50 rlb: clojure.org seems to be having difficulties...

21:51 "An unrecoverable error has occurred. The problem has been logged and the Wikispaces staff has been notified."

21:51 qed: rlb: nod

21:51 it's known

21:51 _ato: qed: sorry, I still got don't get what you mean, some of what will take longer? 100^foo is just one operation.. are you parellizing it with agents somehow?

21:51 qed: _ato: yes sorry, i said that earlier

21:52 rlb: Nice, the partial load was good enough for what I needed.

21:52 qed: if we spread this out across mutliple threads and cores, how do we know when we have all the answers for all the calculations

21:52 how do we know not to return an impartial set of results

21:52 chouser: how do you spread it?

21:52 qed: agents

21:52 chouser: each agent only does one operation at a time.

21:53 _ato: qed: do you mean multiple agents? one per core?

21:53 qed: in that case you have to wait for them to finish using (await agent1 agent2 agent3...)

21:57 qed: _ato: thanks that's the answer i was waiting for

21:57 no pun intended

22:01 clojure.org is back

22:01 FYI

22:02 whoa, someone else in wisc.edu interested in clj :)

22:03 a young one, taboot, must be in the dorms

22:12 hamza: I am trying to use gen-interface to create a function with the signiture (String format, Object... args) how does Object... map to clojure?

22:17 _ato: hamza: when calling Object... is just sugar for an Objec array argument. I'm not sure whether that works when defining an interface method though

22:19 arohner: _ato: I believe it does

22:20 hamza: yeah that's what i thought, i tried [String (to-array Object)] that failed?

22:22 _ato: hmmm

22:22 ,(to-array [])

22:22 clojurebot: #<Object[] [Ljava.lang.Object;@6f403e>

22:22 _ato: maybe "[Ljava.lang.Object"

22:23 hamza: it works in clojure but it does not work in method decleration :methods [[format [String (into-array Object)] void]]

22:24 _ato: ,(into-array Object)

22:24 clojurebot: java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Class

22:24 _ato: ,(Class/forName "Object[]")

22:24 clojurebot: java.lang.ClassNotFoundException: Object[]

22:24 _ato: ,(Class/forName "[Ljava.lang.Object")

22:24 clojurebot: java.lang.ClassNotFoundException: [Ljava/lang/Object

22:24 _ato: hmm

22:25 ,(class (to-array []))

22:25 clojurebot: [Ljava.lang.Object;

22:26 _ato: ,(Class/forName "[Ljava.lang.Object;")

22:26 clojurebot: [Ljava.lang.Object;

22:26 _ato: ah there

22:26 try that

22:26 [String (Class/forName "[Ljava.lang.Object;")]

22:26 or even [String "[Ljava.lang.Object;"] might work

22:28 hamza: :( getting ClassFormatError

22:30 (make-array)

22:30 _ato: hmm

22:30 ,(make-array)

22:30 clojurebot: java.lang.IllegalArgumentException: Wrong number of args passed to: core$make-array

22:31 _ato: the thing is you don't want an aeeay object you wnt the array type

22:32 Drakeson: How can I run clojure so that I connect to it several times each one getting its own REPL? I have swank if that helps.

22:33 hamza: hmm

22:33 arohner: Drakeson: M-x slime-connect to the running process

22:33 say no when it asks you if you want to close the old connection

22:35 _ato: hamza: I know there is a way to do it, if you don't specify the types and instead use magic name-mangling

22:35 _mst told me about it

22:35 lemme find the link

22:36 hamza: _ato: you mean empty []?

22:36 Drakeson: can I also get REPLs out of emacs?

22:36 _ato: hamza: http://dishevelled.net/Tricky-uses-of-Clojure-gen-class-and-AOT-compilation.html

22:36 oh wait.. that won't work with gen-interface will it

22:36 hmmm

22:37 ,(doc asm-type)

22:37 clojurebot: Titim gan éirí ort.

22:39 _ato: ,(clojure.asm.Type/getObjectType "java.lang.Integer")

22:39 clojurebot: _ato: Pardon?

22:41 arohner: Drakeson: what do you mean by out of emacs?

22:46 _ato: ,(@#'clojure.core/asm-type "Integer")

22:46 clojurebot: #<Type Ljava/lang/Integer;>

22:47 _ato: ,(@#'clojure.core/asm-type "[Ljava.lang.Integer;")

22:47 clojurebot: #<Type L[Ljava/lang/Integer;;>

22:47 _ato: :(

22:48 Drakeson: arohner: I want to connect to a running clojure instance. I know how to connect to do this using emacs+slime+swank+clojure. Now, 1. is it possible to connect to the same instance that is serving emacs+slime+swank from a command line (not from emacs). 2. [if 1 fails] Are there any good packages or modules that allow that?

22:49 essentially, I want to get a few "clojure shell"s

22:49 _ato: hamza: looks like you can't do it, might be worth raising it on the mailing list as a bug

22:49 hamza: ok, thanks for the help...

22:51 Drakeson: what idiom should I use to get a run-forever loop?

22:52 _ato: Drakeson: (loop [] ... (recur)) or maybe (while true ...)

22:53 somnium: ,((fn [] (recur)))

22:53 clojurebot: Execution Timed Out

22:57 Drakeson: by any chance, do you know how can I create a new emacs frame and run slime-connect in it? (I want to bind all this to a keybinding).

23:03 technomancy: Drakeson: Emacs is the only existing client implemented for the slime protocol, but if you want to access a clojure repl outside of Emacs it's easy to set up a socket repl that works with telnet

23:04 Drakeson: technomancy: I see, thanks.

23:06 I am looking for a quick way to get at a running REPL. Nailgun doesn't work well for me.

23:09 So far, I run a clojure instance which runs swank (outside emacs), then I have bound a window-manager shortcut that runs emacsclient -e "etc." which creates a new emacs frame with a new REPL. I was looking to improve the delay before getting a new REPL ...

23:10 Do you have a better setup that you recommend?

23:14 technomancy: I don't think you'll be able to beat that by much

23:19 Drakeson: btw is there any news on slime/swank over dbus (instead of an non-secure port to which everyone on the same machine can connect)?

23:29 * technomancy has no plans

23:30 Drakeson: d'oh!

23:30 hamza: can't i use let inside a defmacro?

23:31 _ato: hamza: you can

23:32 hamza: (defmacro afunc[input] `(let [escape ~input] )) i define it like this but i can't call it

23:33 _ato: err.. what's that supposed to do? the body of the for is empty

23:33 somnium: it would error on escape in any case

23:33 _ato: oh and the error is because ` automatically namespace qualifies

23:34 try [~'escape ~input]

23:34 Drakeson: what do you want to do? that does not do anything other than making `escape' an alias for `input', if input is eval-able.

23:34 hamza: it has no purpose just trying to learn macros. its useless

23:34 defn: how do I use (to-array-2d)?

23:34 (to-array-2d '(1 2 3 4))

23:35 Drakeson: ,(to-array-2d [[1 2][3 4]])

23:35 clojurebot: #<Object[][] [[Ljava.lang.Object;@1237512>

23:35 _ato: hamza: try doing: (macroexpand-1 '(afunc ...))

23:35 defn: I see Drakeson

23:35 _ato: it'll show you what's happening

23:36 hamza: ok, thanks.

Logging service provided by n01se.net