#clojure logs

2009-11-15

00:16cross hey folks... does anyone know of a built neman cells jar? i'm having all sorts of trouble building it
01:00akingztellman: thanks for penumbra - asteroids and tetris are both neat little example clojure games!
01:06ztellmanaking: glad to hear it
03:25scottjI'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?
05:07Jetienhi! 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.
05:11_atoJetien: the symbol needs to be available at compile time
05:12_atothis would be one way: (eval `(def ~(symbol "foo") bar))
05:13Jetienthanks! i don't understand how clojure works under the hood yet - when is the code compiled and when is it evaluated?
05:13_atolooks like using a macro also works: (defmacro defstr [name value] def ~(symbol name) ~value))
05:13_ato(defstr "foo" bar)
05:14_atooops, mispaste, that should be: (defmacro defstr [name value] `(def ~(symbol name) ~value))
05:19Jetienwhat can i read to understand the compilation process of clojure?
05:20Jetienor evaluation process
05:22_atosorry... I think I'm full of it :-P actually the problem is just that the def special form doesn't evaluate it's argument
05:22_atootherwise you'd have to write (def 'foo) everywhere
05:22_atoand the macro/eval gets around that
05:23Jetienah okay :)
05:24_atoso 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
05:25Jetieni see. i was puzzled because (class (symbol "foo")) = clojure.lang.Symbol - so the exception made no sense to me
05:25_atoyep
05:25_ato,(class '(symbol "foo"))
05:25clojurebotclojure.lang.PersistentList
05:34Jetien(defstr "foo" 3) works but not (defstr (ex) 3) where (ex) is an expression that yields a string
05:42ChousukeJetien: that's because the macro doesn't evaluate the expression.
05:44ChousukeJetien: you can try printing things inside the macro to see what the parameters are. maybe that'll clarify it :)
05:44Jetienokay :)
05:52_atoah, of course. Silly me. You'd have to use eval at some point anyway, I guess
08:21grammatiWhen I do this: git clone git://github.com/richhickey/clojure.git clojure
08:21grammatiI only get the master branch
08:22grammatishouldn't I get the newnew branch too?
08:22grammatior am I misunderstanding how git works?
08:24_atoyou're missing understanding how it works :)
08:24_atowhen you clone git creates a local "master" based on the remote master
08:24_atoyou can see the remote branche with: git remote show origin
08:25_atoif you want to create a "new" local branch try: git checkout origin/new new
08:25_atoerr
08:25_atogit checkout origin/new -b new
08:25_atosorry
08:25_atoand it'll track upstream changes
08:26_atothe idea is that you can commit stuff to it and it'll automatically be merged with upstream with you pull
08:26_atoif you don't want to create a branch, just checkout it
08:26_atoou can just do: git checkout origin/new
08:27_atobut you won't be able to commit to it (which maybe what you want anyway)
08:27grammatiOK, thanks
08:28grammatiThat seems like it should work, except that I don't think git really works on Windows, as far as I can tell
08:28grammatiAs soon as I clone, it tells me that all my java files are locally modified
08:28grammatibut that's another problem
08:28Bjeringthat is linefeed issue
08:29Bjeringhttp://stackoverflow.com/questions/1474686/git-replaced-all-of-my-lf-with-crlf-how-do-i-fix-this
08:29gerry`,(deftype Person [name age] [java.lang.Comparator] (.compareTo [o] (compare age (:age o))))
08:29clojurebotjava.lang.RuntimeException: java.lang.ClassNotFoundException: java.lang.Comparator
08:31gerry`,(deftype Person [name age] [java.lang.Comparable] (.compareTo [o] (compare age (:age o))))
08:31clojurebotDENIED
08:31_atoclojurebot doesn't allow any def forms
08:33gerry`,*clojure-version*
08:33clojurebot{:interim true, :major 1, :minor 1, :incremental 0, :qualifier "alpha"}
08:34gerry`,(doc clojurebot)
08:34clojurebotI don't understand.
08:35gerry`clojurebot: help
08:35clojurebothttp://www.khanacademy.org/
08:35gerry`clojurebot: what?
08:35clojurebotwhat is wrong with you
08:36gerry`hmm
08:36Jetienha :)
08:37gerry`clojurebot: then?
08:37clojurebotIt's greek to me.
08:39Jetiencan you kill clojurebot?
08:39mauritslamersquestion: I want something like map, but without having it include nils in the result
08:39Jetien,(repeat 6)
08:39somniumwhat's with the hostility towards clojurebot =)
08:39Jetien:)
08:39clojurebotExecution Timed Out
08:40somniummauritslamers: filter identity
08:40mauritslamersI tried for with a :when clause, but for will always walk through every binding
08:41mauritslamerssomnium: I stopped using filter, because I don't want to filter afterwards
08:41mauritslamersbecause that will force going through the list again and again :)
08:42mauritslamerswhich is not a good idea performance-wise
08:42somnium,(for [x (range 50) :when (= 0 (mod x 3))] x)
08:42clojurebot(0 3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48)
08:43mauritslamersissue 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
08:43mauritslamerspositions from clojure.contrib.seq-utils works, but that indexes the collection every time
08:44mauritslamersI tried something like this: (for [unique uniques-list found-pos (positions #(= unique %) all-data :when (some pred) ] )
08:45mauritslamersbut that also iterates through every position in found-pos
08:45mauritslamersit would be nice if I could prevent the iteration of that found-pos list..
08:46mauritslamerslet's say that the :when clause should be something like this: :when (> (count found-pos) 1)
08:48mauritslamerssomnium: any idea how to do this?
08:48somniummauritslamers: I'm not sure I follow
08:49mauritslamersok, I'll try to be a bit more clear :)
08:49mauritslamersI have a list with unique values, derived from a list with patterns
08:50mauritslamersWhat I want is a list with positions of every unique value inside the list with patterns
08:50mauritslamersI have tried a few things, but they all cause problems in some ways
08:50somniumpositions = indexes?
08:50mauritslamersyep
08:51grammatimauritslamers: 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?
08:51mauritslamersthe list with indexes should only contain the unique patterns that occur more than once
08:51mauritslamersYes I know what laziness is :)
08:51mauritslamersI don't know the exact workings
08:52somniumhmm, if you have to keep count of occurrences you probably want to reduce, or maybe loop if necessary
08:52grammatiOK, it just seemed like maybe you though map would instantiate the whole list, including the values that you will later filer out
08:53mauritslamersWhen I use map for this procedure, I get loads of nils of course
08:53mauritslamerson different levels
08:54mauritslamersfiltering them out, takes at least two extra passes through the entire result
08:54somniumalso you can use for like [x xs y ys :let [z (* x y)]] :when ...
08:54mauritslamersah...!
08:54somniumfor can do quite a lot, and when it can't there's reduce and loop
08:54mauritslamerswas searching for something like that...
08:54mauritslamersexactly :)
08:54mauritslamersI knew there had to be some kind of way :)
08:55mauritslamersThanks!
08:58mauritslamerswhy do I get an "unsupported binding form :let" ? error
08:59mauritslamersold clojure version?
09:00mauritslamersor is it not allowed to have both :let and :when?
09:01somnium,(for [x (range 10) y (range 10) :let [z (* x y)] :when (= 0 (mod z 3))] z)
09:01clojurebot(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)
09:05mauritslamerssomnium: 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
09:09the-kennymauritslamers: Your code evaluates here fine (If I define a indexed-function)
09:09mauritslamers...
09:09mauritslamersweird
09:09somniummauritslamers: what clojure version?
09:09mauritslamers1.0 afaik
09:09mauritslamersit is the clojure.jar that is part of the textmate bundle
09:13somniumhmm, just tried with 1.0.1 and it worked
09:13somniumnot sure, maybe get latest clojure 1.0 from github? (or 1.1 if you're going to the trouble)
09:13mauritslamersthere are more strange things: user=> *clojure-version*
09:13mauritslamersjava.lang.Exception: Unable to resolve symbol: *clojure-version* in this context (NO_SOURCE_FILE:0)
09:14mauritslamersor the bundle writer in this case :)
09:14mauritslamersthe bundleit is not part of textmate itself
09:15mauritslamers*bundle
09:18mauritslamersI'll try the jar from google code
09:18somniumnetbeans and waterfront are fairly easy to setup alternatives FWIW
09:18somniumbetter from github
09:19somniumgoogle code hasn't been used in a while
09:19mauritslamersok, thanks!
09:19mauritslamersshould I compile my own jars or are there precompiled jars ?
09:19somniumgithub should have some downloads
09:20somniumbut you just need ant to build them :)
09:21mauritslamersafaik ant is normally installed in Mac OSX, so that shouldn't be a real problem :)
09:27mauritslamerscompiling clojure worked, now trying to compile clojure-contrib, but that returns errors: cannot find Clojure.lang.compile?
09:30the-kennymauritslamers: Have you specified -Dclojure.jar=path-to-clojure to ant?
09:30mauritslamersyep
09:30mauritslamersthe-kenny: otherwise it errors out "not able to find clojure.jar"
09:30the-kennyoh hm
09:30mauritslamerscheck_hasclojure:
09:31mauritslamers [echo] WARNING: You have not defined a path to clojure.jar so I can't compile files.
09:31mauritslamersno -D option specified here..
09:32somniumcheck_hasclojure: passes when you do specify?
09:32mauritslamerswith -D option: compile_classes:
09:32mauritslamers [java] Could not find clojure.lang.Compile. Make sure you have it in your classpath
09:32mauritslamersI'll post the entire dump, moment
09:33mauritslamerssomnium: http://gist.github.com/235256
09:36mauritslamerssomnium: got it working
09:36somniumgreat, I was clueless :)
09:36mauritslamersa path to the file alone is not enough
09:36mauritslamersI needed to specify the file
09:36mauritslamersso ant -D../clojure/clojure.jar
09:37mauritslamersehh.. ant -Dclojure.jar=../clojure.clojure.jar
09:38mauritslamerswhen only -Dclojure.jar=../clojure is specified, things go wrong... bug in build script?
09:38somniumno, clojure.jar is just a variable in the build.xml
09:38mauritslamers(typing is not one of my strongest points I believe) ... ant -Dclojure.jar=../clojure/clojure.jar
09:41somniumhopefully some alternative build tools are coming around soon, I wouldn't recommend getting into ant if you haven't had to already
09:41mauritslamersor just an automatic building tool?
09:42mauritslamersanyway, make stuff work again... next issue: the textmate bundle does not behave as expected ... :)
09:42mauritslamersOf course I don't expect you to be able to help here much :)
09:43somniumcan't help with that one, only use emacs and netbeans(for java)
09:43mauritslamersnp :)
09:43mauritslamersyou helped me more than enough already, thanks!
09:44somniumcheers
09:48mauritslamersmaybe 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
09:48mauritslamers(defn on-thread [f]
09:48mauritslamers (doto (new Thread f) (start)))
09:49mauritslamersit says: start: unable to resolve symbol
09:49somniumhmm, my guess would be it should be .start
09:54mauritslamersthat solves one issue, and makes room for the next one: [ss (new ServerSocket port 0 (.getByName InetAddress "localhost"))] => .getByName no matching method found??
09:55mauritslamers(import '(java.net ServerSocket Socket SocketException InetAddress) is in the file above
09:55The-Kennzmauritslamers: Is .getByName a static method?
09:56mauritslamersThe-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
09:56The-Kennzmauritslamers: Try (InetAddress/getByName "localhost)
09:57The-Kennzs/)/")/
09:57mauritslamerssolves that issue indeed!
09:58mauritslamersit comes back with another one, but I think that can be fixed in the same way
09:58The-Kennzmauritslamers: You call "normal" java methods with the .methodName, static methods with Classname/methodName
09:58somniumwas (.foo Bar) valid for static methods in the early days of clojure?
09:58The-KennzOh, and you don't need new, you can also write (classname.)
09:59The-Kennzsomnium: I don't know.
09:59mauritslamersThe-Kennz: as I said, I am trying to get it working, it is not my code :)
09:59The-KennzOkay
10:00mauritslamersI installed it from git://github.com/nullstyle/clojure-tmbundle.git
10:01The-Kennzmauritslamers: It looks like nullstyle has stopped development, but other people has continued his work: http://github.com/nullstyle/clojure-tmbundle/network
10:02mauritslamersah, better :)
10:02mauritslamersI fixed it by the way, and stuff is working again!
10:04mauritslamersThe-Kennz: thanks for the idea! Someone else improved it greatly, even adding a updating facility with automated building or something like that... :D
11:02Drakeson[using the `new' branch ...] How does one search for interfaces that have a particular method?
11:06spuzHas anyone used clojure.contrib.profile?
11:07spuzIt 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:08spuzIt 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:11Drakesonhow can I serialize an object to a bytes array?
12:12Drakesonfor instance, how can I get (1 0 2 0 0 0 3) from [(byte 1) (short 2) (int 3)] ?
12:38ambient,(into-array [1 2 3])
12:38clojurebot#<Integer[] [Ljava.lang.Integer;@f2a0ef>
13:05penthiefHi, is there a better way than: (cons (first my-list) (cons (second my-list) '())) ?
13:10maravillas(take 2 my-list)
14:07G0SUBHas anyone written a Clojure version of Knuth's man or boy test? http://rosettacode.org/wiki/Man_or_boy_test
14:38G0SUBhttp://rosettacode.org/wiki/Man_or_boy_test#Clojure
14:44spuzG0SUB: I can see a Clojure implementation there :)
14:53patrkrisIf 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:57The-Kennzpatrkris: I'm not sure, but add-watcher could work for refs.
14:57The-Kennza watcher is a function which gets called every time an agent (or ref) gets updated
14:58The-Kennzpatrkris: http://clojure.org/api#toc66
14:58The-KennzJust add a function that checks if there is only one element in the list.
15:00patrkrisThe-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:13polypusi would like to write a macro which takes a param vector and a list
15:13polypus(f [a b] (a b c d))
15:14polypusand returns a function of this form
15:15polypus(fn [b d] `(a ~b c ~d))
15:16polypushaving trouble getting it to work
15:18hoeck1(defmacro f [a b] `(fn [b# d#] (~a b# ~c d#)))
15:18polypusso that i should be able to write ((f [a] (b a t)) 'z) returning '(b z t)
15:19polypusthanks many, i'll give it a go
15:23hoeck1polypus: I don't know exactly what you want to achieve, but maybe a function like (#(list 'b % 't) 'z) will do the same?
15:23polypusdoesn't do it. i should be able to write ((f [a] (b a t)) 'z) and get the list (b z t) back
15:25polypusno 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:27polypusi was hoping to be able to have the macro generated function use syntax quote for performance reasons
15:32polypusi just realized that my first definition was wrong, it should have read (f [b d] (a b c d)), thanks for the help
15:33hoeck1guess I didn't help that much :)
15:38polypusdo you think it is even possible to write a macro which builds a syntax unquoted expression and bundles it up in a function?
15:38somniumyou can emit any kind of symbol with a macro
15:38somniumnot sure I understand what bundling it up in a function means
15:42G0SUBspuz: Yeah, I just wrote it.
15:42rhickeyprotocols - :on is gone
15:52polypusbundling 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:52polypusso for some macro f
15:52polypus(def g (f [b d] (a b c d)))
15:54polypuscalling function g: (g 4 5) returns the list (a 4 c 5)
15:57Drakesonhow can I slice an array (or get a sub-array)?
15:57polypusso g might look like this internally (fn [b d] `(a ~b c ~d)). but maybe i'm totally barking up the wrong tree
15:59somniumpolypus: have you looked at definline?
16:00polypusno, i will. thx
16:02rhickeypolypus: 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:04polypusok thx. just a noob trying to wrap my head around this stuff
16:06rhickeywrite 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:09duncanmi was just thinking, is there a way to 'simulate' the channels in CSP/go-routines using lazy collections/streams?
16:10duncanmtechnomancy: congrats on the elpa upload, i'm downloading now
16:11piccolinoWhat got uploaded to elpa?
16:12duncanmpiccolino: swank-clojure
16:12piccolinoLike a new version?
16:42duncanmla la la
16:52ordnungswidrighmm
17:13DraggorHow would I go about delivering my clojure app as a single jar?
17:16mauritslamersquestion: 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:18mauritslamersthe error being that it cannot resolve the symbol
17:18ordnungswidrigDraggor: do you have dependencies?
17:18mauritslamerswhich is the binding defined first in the let
17:18ordnungswidrigmauritslamers: can you paste something to pastebin?
17:18mauritslamersordnungswidrig: of course, thanks!
17:20mauritslamersordnungswidrig: http://gist.github.com/235535
17:20mauritslamersthe error:<Exception java.lang.Exception: Unable to resolve symbol: indexed-coll in this context>
17:21Draggorordnungswidrig: I do. Actually using compojure and a couple other things
17:21ordnungswidrigmauritslamers: is it the let? check the line no. of the excpetion
17:21ordnungswidrig,(let [a 1 b (* 2 a)] b)
17:21clojurebot2
17:21mauritslamersmoment, I'll give you the entire function
17:22ordnungswidrigDraggor: if you use maven you can use the uberjar plugin. I think it should work with clojure, too
17:22mauritslamersordnungswidrig: please reload the gist
17:24ordnungswidrigmauritslamers: When I define a dummy function "indexed" I get no error about indexed-coll. Just about "pattern" not defined.
17:25Draggorordnungswidrig: 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:25rosejn1http://sites.google.com/site/rpdillon/creatingexecutablejarswithclojure
17:25Draggorrosejn1: Even better, thanks!
17:27ordnungswidrigDraggor: 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:27mauritslamersordnungswidrig: strange...
17:27mauritslamersordnungswidrig: the definition of pattern is: (defstruct pattern :pattern :found-at)
17:27ordnungswidrigDraggor: http://code.google.com/p/jarjar/ will do the job
17:28ordnungswidrigmauritslamers: working from the repl? restart it, perhaps something has been garbled?!
17:28ordnungswidrigwith the definition of pattern it compiles in my repl
17:28mauritslamersI restarted the stuff quite a few times already, no change...
17:29chouserrhickey: 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:29ordnungswidrigme, bed, now.
17:29ordnungswidrigsee you!
17:30ordnungswidrigmauritslamers: sorry, I'm lost. It's bedtime for me anyways. Good luck!
18:09AWizzArdIn 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_atoAWizzArd: 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:25AWizzArdic
18:27_atooh, and you can define a protocol on anything
18:28_atolike for example you can define it on Object or Nil or somebody else's type
18:28AWizzArdDo you have an example where this would be useful?
18:28_atothat could get weird if it changed hierachy of the type
18:28_atotoString() is a simple example
18:29_atowhat if you wanted to make a to-json function that convrts anything to JSON
18:29_atoyou'll want to do implmentations for java types like string and what-not
18:29_atoand probably default implentation for everything that at least serializes the name of the class
18:31lisppaste8Chouser pasted "silly example of extending Integer and String with a protocol" at http://paste.lisp.org/display/90452
18:33Chousukehmm
18:34ChousukeI guess you'd need multiprotocols for defining add operations between Strings and Integers :/
18:35Chousuke(or rather, integers and Complex numbers :P)
18:35chouserright, or regular multimethods
18:36chouserI said it was a silly example
18:37_atoas 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:38Chousukeyeah, but that would negate the performance benefits
18:48dnolenone 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:51Chousukeno, the method implementations in deftype are for Java interfaces as far as I know.
18:51Chousukeif you want to have your type implement a protocol, you'll need to call extend after the type is created.
18:52Chousukethough 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:52Chousukeimplents... implements.
18:54dnolenChousuke: k so if you're programming in pure Clojure, the general pattern is 1. deftype 2. deprotocol 3. extend ?
18:54ChousukeI suppose.
18:55dnolentrying to understand what the Clojure bits are, and what the interop bits are, easy to get confused :)
18:56chouserprotocols can't be on top of interfaces anymore
18:57chouserno need apparently as the call-site caching is faster than the :on feature was
18:58dnolenchouser: yeah I saw that. So protocols are now always just a list of functions right?
18:58_atoahh, cool, that reduces the confusion
18:58chouserdnolen: sounds right
18:59dnolenchouser: 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:02Chousukehmm.
19:02_atodnolen: does doing that gain you anything over just using (.foo obj)?
19:03_atoI guess it could be a way to bridge compatiblity between say different hosts
19:03_atoor different library implementations
19:03dnolen_ato: yes I was about to reply saying that :)
19:04_atoalthough I'd hazard that most of the time you couldn't just do that automatically, at least for one of the implementations
19:06dnolen_ato: true
19:07the-kennyVery strange things happen in my code...
19:10Chousukednolen: 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:10Chousukeand then every host needs to provide code to implement the protocols
19:12the-kennyWhat can cause (take 24 @my-agent) to fail with a NullPointerException when (take 23 @my-agent) works? (last works too, as does nth)
19:12Chousukebut 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:12the-kennyThis behaviour started after the agent ran a log time (some hours or so)
19:12the-kennys/log/long/
19:12Chousukethe-kenny: the seq generating function throws an NPE? :/
19:13the-kennyChousuke: Looks so. I think some very strange things are happening here
19:13Chousukebe mindful of laziness and dynamic scope .)
19:14the-kennyIt worked for over 3 hours now. After that, something breaks.
19:14Chousuke:/
19:15the-kennyNew things gets added to the list in the agent, but I can't dereference it anymore.
19:15Chousukeoh, well, I need to get some sleep. Good luck with the bug-hunt :P
19:16the-kennyChousuke: I have to go to bed too ;) Can we continue this tomorrow?
19:22the-kennyNevermind, I'll investigate this tomorrow.. night
19:31hamzahey guys, i am trying to locate gen-interface function but it is not in contrib or core?
19:31rhickeychouser: 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:33chouseroh! wow.
19:34_ato~def gen-interface
19:34_atohamza: ^
19:34woobyhas anyone written an interpreter for another language in clojure?
19:37hamza_ato: thank you.
19:38hamzai am actually looking for gen-and-load-interface function which is not present in source?
19:40_atogen-and-load-interface no longer exist
19:40hamzaok, is there a substitute for it?
19:47_atohamza: I don't think so, you're generally supposed to compile things upfront if you want to use gen-class or gen-interface
19:50hamzahmm ok thanks.
19:50hamzais there a particular reason for removing it? cause to me it just makes things harder.
19:54dakronecould someone explain why 'i' isn't being incremented in this? http://paste.lisp.org/display/90457
19:55_atohamza: 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:55rhickeyhamza: 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:55rhickeyalso, such classes can only be loaded once per classloader
19:56hiredmandakrone: why would it be incremented?
19:56maravillasdakrone: inc doesn't modify the original i
19:56dakroneoh duh, this is what I get for programming with a fever
19:57dakroneimmutable, duh
19:57dakronethanks hiredman & maravillas
19:57hamza_ato,rhickey thank you both for clarification.
19:57maravillasfeel better :)
19:57dakronethanks
20:24hamzacan i type Some.class for a function that expects Some.class as a argument interface is created but i get ClassNotFoundException
20:27maravillastry just Some without the ".class"
20:40lisppaste8hamza pasted "untitled" at http://paste.lisp.org/display/90458
20:40hamzaam i missing something? i keep getting class not found although class is present in classes/ folder which is in class path.
20:41hamzacompile causes java.lang.NoClassDefFoundError: java/lang/Library (jna.clj:13)
20:41_atohamza: have you seen http://github.com/Chouser/clojure-jna ?
20:43hamzanope, thanks for pointing..
20:47lisppaste8_ato annotated #90458 "works for me" at http://paste.lisp.org/display/90458#1
20:51hamzathanks, _ato
20:51_atohamza: oh... wait, just realised what the problem is
20:51hamza?
20:52_atoyou have to specify the full classname in :extends
20:52_atonotice the error: java/lang/Library
20:52_atonot com/sun/jna/Library
20:52hamzaohh ok, got it.
20:52_atoI don't know why gen-class/gen-interface don't pickup the imports
20:53hamzanow it works.. thanks, nice catch.
20:53_atomust be something funny about compilation works
21:14hamzawhat does tilde stand for in this context? ~(namespace s)
21:16cgordonI'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:17chouserhamza: ~ inside a ` form will unescape
21:18chouser,(let [a 5] `(a b c))
21:18clojurebot(sandbox/a sandbox/b sandbox/c)
21:18chouser,(let [a 5] `(~a b c))
21:18clojurebot(5 sandbox/b sandbox/c)
21:18chousercgordon: symbol
21:18chouser,(symbol "string")
21:18clojurebotstring
21:18chouser,(type (symbol "string"))
21:18clojurebotclojure.lang.Symbol
21:18cgordonthanks!
21:20hamzachouser is ` like '?
21:20chouserhamza: a bit, yes. ` is called syntax-quote
21:21chouserthe differences are that syntax-quote supports ~ where quote does not
21:21hamzaok..
21:21chouseralso, syntax-quote namespace-qualifies symbols where quote does not
21:21chouser['a `a]
21:21chouser,['a `a]
21:21clojurebot[a sandbox/a]
21:41Scriptorhey everyone, after building clojure-contrib, should I be able to see any of the classes for pprint under classes/clojure/contrib ?
21:42chouserScriptor: I have a large number of files in that dir starting with "pprint"
21:42qedhow 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:42chouserqed: are you talking about agents or something else?
21:43qedchouser: yes
21:43qederr, yes, agents
21:43Scriptorchouser: I don't seem to have any
21:43qedsomeone asked me this question earlier and i didnt have an answer
21:43Scriptorbuilding gives a few errors but otherwise it says "build successful"
21:45_atoScriptor: did you specify -Dclojure.jar=/path/to/clojure.jar when you compiled?
21:45qedclojure.org is down huh?
21:46Scriptor yup
21:46qedbummer
21:46qedi was hopin it'd have the answer to my question :)
21:46qedScriptor: paste the exact line you tiped in when you built clojure-contrib
21:46chouserqed: 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:46qedScriptor: also make sure you have the most recent versions of both
21:47qedchouser: nono, not to combine them or anything
21:47Scriptorant -Dclojure.jar=../clojure_1/clojure.jar
21:47qedjust how does clojure know when it has all of the answers from the separate threads?
21:47ScriptorI should have the recent versions since I only got them yesterday or so, but I'll check
21:48qedchouser: maybe that's a silly question -- im not sure
21:48_atoqed: it doesn't? what do you mean by "kno when it has all of the answers" ?
21:49Scriptorthe .clj files are present, but they don't seem to be compiled
21:49qed_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:49qedhow does clojure know that it shouldnt return when it only has some of those answers
21:49Scriptorduring compiling I'm also getting a FileNotFoundException for wal__init.class and walk.clj
21:50Scriptor*walk__init.class
21:50rlbclojure.org seems to be having difficulties...
21:51rlb"An unrecoverable error has occurred. The problem has been logged and the Wikispaces staff has been notified."
21:51qedrlb: nod
21:51qedit's known
21:51_atoqed: 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:51qed_ato: yes sorry, i said that earlier
21:52rlbNice, the partial load was good enough for what I needed.
21:52qedif we spread this out across mutliple threads and cores, how do we know when we have all the answers for all the calculations
21:52qedhow do we know not to return an impartial set of results
21:52chouserhow do you spread it?
21:52qedagents
21:52chousereach agent only does one operation at a time.
21:53_atoqed: do you mean multiple agents? one per core?
21:53_atoqed: in that case you have to wait for them to finish using (await agent1 agent2 agent3...)
21:57qed_ato: thanks that's the answer i was waiting for
21:57qedno pun intended
22:01qedclojure.org is back
22:01qedFYI
22:02qedwhoa, someone else in wisc.edu interested in clj :)
22:03qeda young one, taboot, must be in the dorms
22:12hamzaI 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_atohamza: 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:19arohner_ato: I believe it does
22:20hamzayeah that's what i thought, i tried [String (to-array Object)] that failed?
22:22_atohmmm
22:22_ato,(to-array [])
22:22clojurebot#<Object[] [Ljava.lang.Object;@6f403e>
22:22_atomaybe "[Ljava.lang.Object"
22:23hamzait 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:24clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Class
22:24_ato,(Class/forName "Object[]")
22:24clojurebotjava.lang.ClassNotFoundException: Object[]
22:24_ato,(Class/forName "[Ljava.lang.Object")
22:24clojurebotjava.lang.ClassNotFoundException: [Ljava/lang/Object
22:24_atohmm
22:25_ato,(class (to-array []))
22:25clojurebot[Ljava.lang.Object;
22:26_ato,(Class/forName "[Ljava.lang.Object;")
22:26clojurebot[Ljava.lang.Object;
22:26_atoah there
22:26_atotry that
22:26_ato[String (Class/forName "[Ljava.lang.Object;")]
22:26_atoor even [String "[Ljava.lang.Object;"] might work
22:28hamza:( getting ClassFormatError
22:30hamza(make-array)
22:30_atohmm
22:30_ato,(make-array)
22:30clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$make-array
22:31_atothe thing is you don't want an aeeay object you wnt the array type
22:32DrakesonHow 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:33hamzahmm
22:33arohnerDrakeson: M-x slime-connect to the running process
22:33arohnersay no when it asks you if you want to close the old connection
22:35_atohamza: I know there is a way to do it, if you don't specify the types and instead use magic name-mangling
22:35_ato_mst told me about it
22:35_atolemme find the link
22:36hamza_ato: you mean empty []?
22:36Drakesoncan I also get REPLs out of emacs?
22:36_atohamza: http://dishevelled.net/Tricky-uses-of-Clojure-gen-class-and-AOT-compilation.html
22:36_atooh wait.. that won't work with gen-interface will it
22:36_atohmmm
22:37_ato,(doc asm-type)
22:37clojurebotTitim gan éirí ort.
22:39_ato,(clojure.asm.Type/getObjectType "java.lang.Integer")
22:39clojurebot_ato: Pardon?
22:41arohnerDrakeson: what do you mean by out of emacs?
22:46_ato,(@#'clojure.core/asm-type "Integer")
22:46clojurebot#<Type Ljava/lang/Integer;>
22:47_ato,(@#'clojure.core/asm-type "[Ljava.lang.Integer;")
22:47clojurebot#<Type L[Ljava/lang/Integer;;>
22:47_ato:(
22:48Drakesonarohner: 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:49Drakesonessentially, I want to get a few "clojure shell"s
22:49_atohamza: looks like you can't do it, might be worth raising it on the mailing list as a bug
22:49hamzaok, thanks for the help...
22:51Drakesonwhat idiom should I use to get a run-forever loop?
22:52_atoDrakeson: (loop [] ... (recur)) or maybe (while true ...)
22:53somnium,((fn [] (recur)))
22:53clojurebotExecution Timed Out
22:57Drakesonby 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:03technomancyDrakeson: 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:04Drakesontechnomancy: I see, thanks.
23:06DrakesonI am looking for a quick way to get at a running REPL. Nailgun doesn't work well for me.
23:09DrakesonSo 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:10DrakesonDo you have a better setup that you recommend?
23:14technomancyI don't think you'll be able to beat that by much
23:19Drakesonbtw 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:30Drakesond'oh!
23:30hamzacan't i use let inside a defmacro?
23:31_atohamza: you can
23:32hamza(defmacro afunc[input] `(let [escape ~input] )) i define it like this but i can't call it
23:33_atoerr.. what's that supposed to do? the body of the for is empty
23:33somniumit would error on escape in any case
23:33_atooh and the error is because ` automatically namespace qualifies
23:34_atotry [~'escape ~input]
23:34Drakesonwhat do you want to do? that does not do anything other than making `escape' an alias for `input', if input is eval-able.
23:34hamzait has no purpose just trying to learn macros. its useless
23:34defnhow do I use (to-array-2d)?
23:34defn(to-array-2d '(1 2 3 4))
23:35Drakeson,(to-array-2d [[1 2][3 4]])
23:35clojurebot#<Object[][] [[Ljava.lang.Object;@1237512>
23:35_atohamza: try doing: (macroexpand-1 '(afunc ...))
23:35defnI see Drakeson
23:35_atoit'll show you what's happening
23:36hamzaok, thanks.