#clojure logs

2010-08-15

04:00LauJensenGood morning all
08:00rdsrCan I type hint the protocol methods so that the methods in generated interface does not have Object as the argument type?
08:42BahmanHi all!
08:50no_mindhi
08:54emhrdsr: I googled for that earlier this week, found http://www.listware.net/201006/clojure/44571-protocol-type-hints-java-interface.html
08:54rdsremh, oh cool thks
08:55rdsremh, I tried adding type hints but the generated interface contains only objects as types
08:57emhrdsr: yes, according to the thread seems like you have to use definterface to get non-Object types
08:58rdsrthks emh
09:39Licensercookies?
09:40Licenserwoooh it's working!
09:41Licensernow that I can talk again I wanted to say it's amazing how well clojure works with jpcap
09:51defnLicenser: Did you give me permission to port lein-search to cake?
09:52Licenserdefn: it is open source :) you don't need my permission
09:52defnIt's polite to ask :)
09:52defnAlso, does anyone know if java-utils was renamed for 1.2.0?
09:52defnis it just .java now?
09:52defnspecifically im looking for (as-file ...)
09:53Licenserdefn: heh
09:53defnI keep forgetting which were changed and to what
09:57Licenserwow my knowledge about TCP IP is rusty :(
09:57defnLicenser: im sure you'll pick it up-
09:57Licenserdefn: it can take a while, it's non trivial sadly
09:58Licenserand too well documented
09:59defnLicenser: know anything about protocol buffers?
09:59Licenserthe google protobuf ting?
09:59defnyeah
09:59defnim curious why it's so efficient
09:59defnit just looks like kv pairs
10:00Licenserdefn: because it's binary compiled
10:01defnLicenser: ah -- i found an interesting clojure library that allowed you to do them easily in clojure as your serialization format
10:01Licenser*nods*
10:01LicenserI know
10:01Licensercaptured with clojure: http://gist.github.com/525514
10:02defnha! interesting coincidence
10:04Licensernow I wonder how can I make out the TCP stream from that :(
10:21gfrlogcan an agent ever have more than one error?
10:30gfrlog,(* 3 3)
10:30clojurebot9
10:51Licenserawsome I can follow TCP Streams now :D
10:57technomancydefn: as-file is just clojure.java.io/file now
10:59LauJensenLicenser: What are you working on ?
10:59LicenserLauJensen: jpcap & clojure
10:59LauJensenYes - I mean from a highlevel POV - What kind of applicaton ?
10:59LauJensens/applicaton/application/
10:59sexpbotYes - I mean from a highlevel POV - What kind of application ?
11:01LicenserLauJensen: oh well I want some network debugging
11:01LauJensenOk
11:01Licenserthink of a wireshark specialized for my usual problems
11:01Licenseralso I'm still in the testing stage :)
11:02LauJensenWireshark has been good to me in the past, would be interesting if you came up with something like it
11:02LicenserLauJensen: it has been to me too, for now I want a somewhat compfy lib to handle basic cases :P
11:02LauJensenCan you give some examples of what you're targeting?
11:05Licenser(backgrond-capture-streams streams open-en1) => streams keeps an up to date list of TCP streams on en1
11:05Licenserwhere open-en1 is a capture interface I opened and strems is an (atom {})
11:06Licenserin general I hope for a tool to debug SIP, since it's part of my day job and it'd be way cooler then whireshark :P
11:07LauJensenOk
11:08Licenserbut that is a long run thing :P for the moment I am glad to play with package capturing ^^
11:08Licensersince I've my doubt that I'll ever manage to finish the entire project
11:14LauJensenYea I understand- Its amazing how fast you can get work done, once you get paid for it
11:32LicenserLauJensen: yea my problem is I ain't :P
11:32LauJensenYea I figured
11:33Licenserwhich is quite sad since I bet we could use a program like that
11:35defntechnomancy: thanks
11:35defntechnomancy: is this documented anywhere besides notes on a commit?
11:36technomancydefn: there was a mailing list thread about clojure.io
11:37defntechnomancy: oh :X I must admit the mailing list is not the best way for me personally to follow new developments
11:39technomancythere may be more somewhere else
11:42technomancymaybe the 1.2 changelog?
11:56bobbytekwhat's the best ide for clojure?
11:56bobbytekcounterclockwise?
11:56clojurebotCounterclockwise aka ccw at http://code.google.com/p/counterclockwise/
12:00LicenserLauJensen: out of curiosity, where does your interest come form?
12:10kenshowhat is the best way to mutate a java graphics context in a thread safe way in clojure? i.e. I want to call setColor and drawRect atomically from multiple threads.
12:13kenshoIs this possible without locks?
12:14Licenserkensho: I guess using agents won't be wrong
12:15kenshoLicenser: thanks, I'll look into it
13:41Licenserin the slime repl what was the specal variable for the last result?
13:41qbg*1
13:42Licenserthanks qbg
13:55LauJensenLicenser: my interest?
13:55LicenserLauJensen: in package capturing
13:56LauJensenI was just trying to imagine what kind of project you could be working on. Last time I used it was to reverse engineer a proprietary communications protocol
14:01LauJensen~seen etate
14:01clojurebotno, I have not seen etate
14:01LauJensen$seen etate
14:01sexpbotI have never seen etate.
14:01Licenser*nods*
14:02LicenserLauJensen: ah :) well clojure works great for this since it's nice for stuff
14:03Licenserwow that was a very non saying sentence :) I ment all the data mangling is really great
14:04LauJensenhaha
14:05LauJensenYea - Dude, I want a t-shirt with that printed
14:05LauJensen"since its nice for stuff"
14:05LauJensenClojure is indeed, nice for stuff :D
14:05Licenseryes it is
14:44LauJensenATTENTION PRODUCITIVTY FREAKS: Im about to wrap up my blogposts on productivity and Im looking to share some Emacs bindings that help speed things up. If any of you have some really good bindings would you mind hitting me with an msg or sending me an email with your 10 favorite bindings ?
14:48gfrlogCtrl-X Ctrl-C vim
14:48LauJensengfrlog: In my company that would get you fired, so dont joke like that :)
14:48gfrlog:-D
14:49qbgM-x butterfly
14:49LauJensenyea, butterfly is good
14:49qbgIt flips the bits for me!
14:49LauJensenqbg: yea, like a bigger M-x zone-mode
14:50qbgM-x tetris makes you very productive ;)
14:50LauJensenBoth of you guys scroll up, I said produtivity freaks - you sound like slackers :)
14:51qbgIt makes you very productive at slacking off. Slacking off is hard work, after all...
14:55Licenseris there something like re-split?
14:56LicenserI totally fail to find that :(
14:56gfrlogclojure.contrib.str-utils2/split looks promising
14:56gfrlog,(doc clojure.contrib.str-utils2/split)
14:56clojurebotPardon?
14:56Licensergfrlog: thank you!
14:57qbgclojure.string/split
14:57gfrlogguess I'm not up to date on the latest organization
14:57gfrlogneither is the main site apparently
16:04gfrlog,(nil)
16:04clojurebotjava.lang.IllegalArgumentException: Can't call nil
16:06alpheusThere's a *follow-redirects* in clojure-http-client ("1.1.0-SNAPSHOT"). How do I access it in my code?
16:07LicenserI think (set! *follow-redirects* true) or even better (binding [ *follow-redirects* true] ...your code...)
16:07alpheusI've tried binding, but I get an exception with the message "No such var: clojure-http.client/*follow-redirects*"
16:07Licenserthen your intel might be outdated?
16:08alpheusIntel? I am looking at source with the save version number. But maybe the jar that lein downloaded doesn't match the source?
16:08Licenserhmm hmmm
16:08alpheuss/save/same
16:09LauJensenalpheus: (def *http-agent-defaults* (assoc *http-agents-default* :follow-redirects false)) I think.
16:09LauJensenhttp://github.com/clojure/clojure-contrib/blob/master/src/main/clojure/clojure/contrib/http/agent.clj#L166
16:11alpheusActually, after (ns clojure-http.client), evaluating *follow-redirects* still causes an exception. So the source I'm reading must really not match the jar, I think.
16:23LauJensenDo we have something in Clojure-land for producing guids ?
16:24alpheusdunno about clojure, but if you happen to be using Linux, there's /proc/sys/kernel/random/uuid -- just read a line from int
16:26alpheusAFAICT, clojure-http.client doesn't use http/agent, but just uses HttpURLConnection directly.
16:28LauJensen,(slurp "/proc/sys/kernel/random/uuid")
16:28clojurebotjava.security.AccessControlException: access denied (java.io.FilePermission /proc/sys/kernel/random/uuid read)
16:29LauJensentsk
16:29LauJensenHard to get an easier UUID than that
16:30alpheusYes. I replaced a few hundred lines of Ruby code with that one-liner.
16:30LauJensenhehe
16:30LauJensenouch
16:47alpheusOK, the clojure-http.client jar and source were definitely out of sync. Proved it by loading client.clj by hand.
16:48alpheusSo I built a jar called clojure-http-client-1.1.0-SNAPSHOT.jar. How do I replace the jar called clojure-http-client-1.1.0-20100502.112537-2.jar (that's apparently out-of-date) in my project?
16:53gfrlogalpheus: are you using leiningen?
16:53alpheusyes
16:53gfrlogwhen I went to clojars I saw two versions of that library
16:54gfrlogI have [org.clojars.raynes/clojure-http-client "1.1.0-SNAPSHOT"] in my project.clj
16:54gfrlogwhich was the newer of the two
16:54gfrlogand included the namespace switch mentioned on the project page
16:54gfrlogmaybe that's good enough for you?
16:55alpheusNow it's starting to make more sense.
16:56alpheusAs an experiment, I copied the jar I just built into the lib/ directory, and removed the other one. Everything's now working exactly as I'd hoped.
16:57gfrlogwould that survive a "lein clean"?
16:57alpheusI obviously need to invest some time in learning how leiningen and clojars work
16:57gfrlogor cloning the project into a new directory?
16:57alpheusno, not at all. it's just a quick sanity check.
16:59gfrlogokeedoke
16:59gfrlogleiningen is pretty simple I think
17:00alpheusI'm a total newb. This is my firt attempt at a clojure program.
17:00alpheusfirst*
17:00gfrlogare you familiar with build tools in other languages?
17:01alpheussure, from Common Lisp, and make. I've looked at ant
17:21ender403test
17:22kencauseyender403: pong
17:23kotrinender403: test
17:23ender403hello all. i'm trying to use a java library that require me to define a class with some primitive fields and a java annotation per field
17:23ender403i tried doing this using deftype but I also need a default constructor that takes no arguments
17:26ender403should I use gen-class to create a class for thsi type?
17:26ender403hi ken, kotrin
17:43hoeckender403: right, with gen-class you can define custom ctors
17:45ender403hoeck, thanks. what is the syntax to add fields using gen-class?
17:45hoeckender403: you can have only one single field :/
17:46hoeckits usually called state and contains a ref
17:47hoeckso using gen-class won't work in your case
17:48gfrlogis there a native closure function for getting the current time?
17:48ender403i'm trying to defining a class such that it will work to serialize in binary data using the preon library (http://preon.sourceforge.net/)
17:50ender403preon requires that I declare a simple java class with some annotations. like this class Rectangle {
17:50ender403@Bound private int x1;
17:50ender403@Bound private int y1;
17:50ender403@Bound private int x2;
17:50ender403@Bound private int y2;
17:50ender403}
17:50ender403i'd like to create a class exactly like this using clojure if possible
17:55hoecksounds (currently) impossible to me doing this in clojure
17:56hoeckgenclass is missing the ability to have mutable fields, and deftype defrecord do not have no-ar ctors
18:00ender403i read that rich doesn't want to make deftype into an all purpose java interop feature so deftype probably won't allow custom constructors in future
18:01ender403isn't gen-class supposed to be a java interop feature?
18:02hoeckimo a right decision, but gen-class should then support mutable or mutable-volatile fields
18:02kencauseyIt sounds to me like this is just a case where it makes more sense to implement that class in Java and move on
18:02kencauseyIf it's simple and requires a lot of Java-isms, why do otherwise?
18:03hoeckof course, and you have to compile it anyways, so little gain from writing it in clojure
18:06ender403it would be nice to have a macro that can generate the class in clojure. we can then have nice binary serialization like Erlang. But if there is no way current then I can write it in java
18:07ender403preon library looks very nice. has anyone here had experience with it?
18:08ender403brb. making pasta
18:15ender403hoeck, i'm still new to clojure. do you mean there is little to gain because the class is created at compile time instead of runtime?
18:19hoeckender403: I just assume that because most java-serialization libs use named classes wich must be created by compiling a gen-class namespace in clojure
18:48technomancyLeiningen repl now listens on a socket as a bonus: http://github.com/technomancy/leiningen/commit/4f64c64afb455c3494873d469729b4a89f7f9f29
18:57technomancyI hate how long that function is, but building up a form for eval-in-project makes it harder to split out functionality. =\
18:59technomancynot on my watch =)
19:05vIkSiTlo all
19:06vIkSiTanyone using mongodb here?
19:06vIkSiTI was wondering if there was a way to use congomongo to do range queries on a collection.
19:07vIkSiT(For instance, if a collection has a 100 rows, is there a way to retrieve the first 10, the next 10, and so on)
19:09phaerWhat does "(~ var)" in clojure do? Or do you know whats the name of "~" in english, so i can look for it?
19:09vIkSiTthe tilde operator?
19:09vIkSiTOne use is when creating macros
19:10gfrlogis there another use?
19:10technomancyI think it's called unquote
19:10vIkSiT(def mymacro [n] `(apply str "this is" ~n))
19:10vIkSiTgfrlog, I'm not sure I know enough about Clojure to comment if there was ONLY one use :)
19:10phaerah, makes sense. thank you
19:11pdkfkin hate how you cant even change your nick without leaving some channels on freenode
19:11pdkanyway ~ is called tilde
19:11pdkand in clojure it's used in macros to tell it to eval a part of a quoted form iirc
19:11pdkwe're rebellious so we dont do cl style ,
19:13phaerpdk: Yes, but thats a plus point for clojure. The use of different kind of brackets for example makes it much more readable than common lisp in my opinion. :)
19:13pdkit's not so much a bracket difference here as just using a different symbol for the same function from cl
19:14pdksince people already use , as a reading aid in map literals
19:14vIkSiThmm, so what would be the best way to iterate over a large collection of elements, taking n elements at a time?
19:15pdk(partition n n list)?
19:15vIkSiTpdk, would that be lazy?
19:15pdk(doc partition)
19:15clojurebot"([n coll] [n step coll] [n step pad coll]); Returns a lazy sequence of lists of n items each, at offsets step apart. If step is not supplied, defaults to n, i.e. the partitions do not overlap. If a pad collection is supplied, use its elements as necessary to complete last partition upto n items. In case there are not enough padding elements, return a partition with less than n items."
19:15vIkSiTaah
19:15vIkSiTthanks for the info
19:15pdk(partition 3 (take 15 (iterate inc 1)))
19:15pdk,(partition 3 (take 15 (iterate inc 1)))
19:15clojurebot((1 2 3) (4 5 6) (7 8 9) (10 11 12) (13 14 15))
19:17vIkSiTawesome
19:18vIkSiTpdk, so assuming I've got a list of elements whose total I do not know of.
19:18pdktotal as in number of items in the list or sum of all numerical items in the list
19:18vIkSiThmm. the former
19:18pdkpartition doesnt require the list it takes in to be a clean multiple of n in terms of length
19:19pdk,(partition 4 (take 15 (iterate inc 1)))
19:19clojurebot((1 2 3 4) (5 6 7 8) (9 10 11 12))
19:19pdk,(partition 3 (take 15 (iterate inc 1)))
19:19clojurebot((1 2 3) (4 5 6) (7 8 9) (10 11 12) (13 14 15))
19:19vIkSiTaah indeed
19:19pdkMAYBE
19:19pdk,(partition 4 4 (take 15 (iterate inc 1)))
19:19clojurebot((1 2 3 4) (5 6 7 8) (9 10 11 12))
19:19pdkclojurebot dont make this difficult
19:20pdk,(partition 4 1 (take 15 (iterate inc 1)))
19:20clojurebot((1 2 3 4) (2 3 4 5) (3 4 5 6) (4 5 6 7) (5 6 7 8) (6 7 8 9) (7 8 9 10) (8 9 10 11) (9 10 11 12) (10 11 12 13) (11 12 13 14) (12 13 14 15))
19:20pdkobvious way would probably be to do a step of 1 then grab every nth item and the last item i guess
19:20vIkSiTah so the 1 there is an overlap step
19:20pdkthis could use some more looking into
19:21pdkyeah the 3 argument version uses the second argument to control how far to advance between steps
19:21pdk,(partition 4 1 (range 1 9))
19:21clojurebot((1 2 3 4) (2 3 4 5) (3 4 5 6) (4 5 6 7) (5 6 7 8))
19:21pdksee how it steps with a step of 1
19:21pdk,(partition 4 2 (range 1 9))
19:21clojurebot((1 2 3 4) (3 4 5 6) (5 6 7 8))
19:21vIkSiTright
19:22pdkso partition 4 2 sort of makes half of each list overlap
19:22vIkSiTright
19:24pdkwould need to know a few more details about what we want for this problem before deciding if partition's cutting-off behavior would be an issue
19:25vIkSiTwell, in my case, I'm trying to compensate for the fact that my database won't let me do ranged queries on my data. So, I'm using a lazy "fetch" to get the entire dataset
19:25pdkcause apparently the 2 argument version if the length of the list isn't a multiple of n it'll just drop the excess
19:25vIkSiTand then partitioning it into manageable chunks, map a function on it, and finally dump it. so the exact partition doesn't make a difference ot me
19:26vIkSiTpdk, yes, the overlap won't be a problem
19:26pdkhmm not quite sure if partition would do the job on its own without the 3 arg version or some extra trickery to make it not drop stuff in the 2 arg
19:26pdkin that case 3 arg version with a step 1 seems to preserve all the data when the list length isn't a multiple of n
19:26vIkSiTpdk, not sure I understood your last statement
19:26pdklike when i tried to partition a 15 element list with n = 4 earlier
19:26vIkSiTright
19:26pdkin the 2 arg version of partition
19:27pdknote how it retrieved 12 items then just dropped the last 3 cause it couldn't make a 4 element list out of them
19:27vIkSiTaah.
19:27vIkSiT,(partition 4 4 (take 15 (iterate inc 1)))
19:27clojurebot((1 2 3 4) (5 6 7 8) (9 10 11 12))
19:27raekI think you can pass nil as one of the args to solve that
19:27vIkSiTright
19:27vIkSiT,(partition 4 nil (take 15 (iterate inc 1)))
19:27clojurebotjava.lang.RuntimeException: java.lang.NullPointerException
19:27pdkoh yeah there's a 4 arg version
19:27pdkwith the 3rd arg as padding
19:28pdk(doc partition)
19:28clojurebot"([n coll] [n step coll] [n step pad coll]); Returns a lazy sequence of lists of n items each, at offsets step apart. If step is not supplied, defaults to n, i.e. the partitions do not overlap. If a pad collection is supplied, use its elements as necessary to complete last partition upto n items. In case there are not enough padding elements, return a partition with less than n items."
19:28pdkthe 3rd arg has to be a sequence
19:28pdkyou could do either (repeat nil) or (repeatedly nil), i forget which
19:28pdk(doc repeat)
19:28clojurebot"([x] [n x]); Returns a lazy (infinite!, or length n if supplied) sequence of xs."
19:28pdk(doc repeatedly)
19:28clojurebot"([f] [n f]); Takes a function of no args, presumably with side effects, and returns an infinite (or length n if supplied) lazy sequence of calls to it"
19:28pdkyeah repeat
19:28raekyeah, pad = nil will make the last sequence be the rest of the elements
19:29pdk(partition 4 4 nil (range 1 16))
19:29pdk,(partition 4 4 nil (range 1 16))
19:29clojurebot((1 2 3 4) (5 6 7 8) (9 10 11 12) (13 14 15))
19:29vIkSiThmm
19:29pdk,(partition 4 4 nil (range 1 15))
19:29clojurebot((1 2 3 4) (5 6 7 8) (9 10 11 12) (13 14))
19:29vIkSiTaah the third argument
19:29pdk!!!
19:29pdkthat makes it preserve everything without overlap
19:29vIkSiT,(partition 4 4 nil (take 15 (iterate inc 1)))
19:29clojurebot((1 2 3 4) (5 6 7 8) (9 10 11 12) (13 14 15))
19:29vIkSiTah that works
19:29pdkoughta take note of that little trick
19:30vIkSiTindeed
19:30vIkSiTthats pretty neat
19:30pdkthough still dumb that it doesnt document what happens when you use nil as 3rd arg in 4 arg version
19:30pdkat least not explicity
19:30pdkcause first time you read it say "pad collection" you assume it has to be an actual collection
19:31raekwell, I guess you could use () as padding too
19:31raekbut yeah... it's a common usage that is not very obvious
19:32pdk(partition 4 4 () (range 1 15))
19:32pdk,(partition 4 4 () (range 1 15))
19:32clojurebot((1 2 3 4) (5 6 7 8) (9 10 11 12) (13 14))
19:42chouserthere was a pretty extensive discussion about changing how partition with padding works
19:42chouserbut I guess it didn't end up going anywhere
19:43pdkwhat was the gist of the proposed change
19:43chouserI think the final statements were feeling out whether the current partition-with-pad was perhaps mixing two things into a single function that ought to be separated.
19:44chouserI'm sure it's on the google group or IRC log. Not sure which.
19:47chouserhm, or maybe assembla
19:49chouserpdk: https://www.assembla.com/spaces/clojure/tickets/120
20:05ender403hi chouser
20:07ender403is it possible to declare the following java class using gen-class or deftype? class Rectangle {
20:07ender403@Bound private int x1;
20:07ender403@Bound private int y1;
20:07ender403@Bound private int x2;
20:07ender403@Bound private int y2;
20:07ender403}
20:09chouserIs @Bound some sort of annotation?
20:11chouserhm, I don't think either will do private fields.
20:12ender403yes Bound is an annotation provided by the preon library
20:12ender403it doesn't have to be private field. When I tried defining this type using deftype I couldn't get a default constructor which takes no arguments. preon needs this
20:13ender403preon overview is here http://www.scribd.com/doc/8128172/Preon-Introduction
20:13chouserugh. I don't think so.
20:14chouserdeftype only provides a ctor with one arg per field, and no way to provide more ctors
20:14chousergen-class only allows zero or one fields, no more.
20:15ender403hmm, is it possible to embed java code inside clojure code?
20:15raekmaybe it's just simpler to write that class int java, and interact with it using clojure's usual java interop
20:16chouserno, but you can define your little class in a .java file, then use that as needed from clojure
20:16raekender403: there is, for example, a lein-javac plugin for leiningen that allows you to have both clojure and java sources in the same project
20:17ender403ok. i was hoping to do it in clojure so I can get nice binary serialization like Erlang has
20:17raekiirc, the build tool Cake has support for java sources out of the box
20:19ender403thanks raek. lein-javac looks interesting
20:27gfrloghow do you handle circular definitions in clojure? like if functions a and b want to refer to each other
20:28gfrlogdo we vacuously pre-def one of them C++ style?
20:28gfrlogthen re-def it later?
20:29raekyes.
20:29gfrlogokeedoke
20:29raekyou can simply do a (def a)
20:30gfrlogthanks
20:30spewnIsn't the preferred way to do it with declare?
20:30raekor it you want to create multiple variables: (declare a b)
20:30phaerraek: thanks from me too. lein-javac seems to be exactly what i was looking for at the moment :)
20:30gfrlogI learned a new word
20:31raekspewn, I think declare signals the intentions more clearly, so I guess so
20:35gfrlogI can swap an atom inside an agent function, right?
20:35raeksure
20:37dreishI had slime working just yesterday, and now, restarting after my Mac crashed, slime-connect reports success but does not create a buffer for the REPL.
20:37raekbut I have no idea of what makes most sense in your situation
20:37raekdreish: is there a repl in the *inferior-lisp* buffer?
20:38dreishraek: The only buffers currently open are *scratch*, *Messages*, and *slime-events*
20:38tomojdreish: do you have slime-repl installed?
20:39dreishtomoj: That might be it. I think I moved some things around in my .emacs file and now my slime/contrib dir is no longer in the load path.
20:39dreishI had to symlink a couple of slime things just to get emacs to start at all, and I missed slime-repl.el.
20:41raekI finally surrendered to ELPA
20:42raekand installing slime though it wasn't that bad
20:44tomojyou get a crippled slime I guess
20:45raekold version?
20:46tomojit doesn't contain the whole thing
20:46tomojright?
20:46tomojI mean, you get more stuff if you install slime yourself?
20:47raekI dunno... I haven't missed anything so far :)
20:47dreishThis doesn't look good. My *slime-repl clojure* buffer has a CL-USER> prompt.
20:48dreishAnd I still had to load slime-repl.el manually.
20:48raekyou used slime-connect to start it?
20:48dreishYes.
20:48tomojhaha
20:48dreishIt still didn't create a repl buffer.
20:48raekdo you have clojure-mode?
20:48dreishYes.
20:49tomojwait, I'm confused... "it stil didn't create a repl buffer" "my *slime-repl clojure* buffer..."
20:49dreishWhich I created after manually loading slime-repl.el and running M-x slime-repl
20:49dreishI think I need to just give up and go with ELPA.
20:49dreishIt can't be much worse than this.
20:50raekI think slime-repl starts the repl itself, rather than connect to an existing
20:50raekwhat happens if you don't run slime-repl and only slime-connect?
20:50tomojI don't think you should be running M-x slime-repl
20:50dreishIt says "Hack and be merry" or whatever, but I just have the buffers I listed at 8:38.
20:50raekdreish: http://www.assembla.com/wiki/show/clojure/Getting_Started_with_Emacs
20:51raekthere is some relevant info there
20:51raekperticularily about how slime finds out which program to start
20:52raekI only have to run slime-connect to get started
20:52gfrlogdoes "java.lang.Exception: Can't await in agent action" ring a bell to anybody?
20:52dreishThat worked for me, too, last time.
20:53raekgfrlog: what are you trying to do? (on a more larger scale)
20:54dreishOh, I already have ELPA. :-?
20:54raekit sounds like you are using agents in the wrong way
20:55raekgfrlog: can you paste the code?
20:55gfrlogum
20:55gfrlogI'm trying to have most of my code running within an agent
20:55gfrlogand it includes a lot of http
20:55gfrlogthrought clojure.contrib.http.agent
20:55gfrlogso if there's an issue with one agent function calling another agent and waiting for the result...
20:55raekwhy in an agent? to have it in its own thread?
20:56gfrloghmm
20:56raekyou can use (future ...code...) to run something in another thread
20:56gfrlogwell I want other threads to be able to add code to the main thread
20:57gfrlogI suppose imagine a main thread and some worker threads
20:57gfrlogwhere each worker thread ultimately results in an http call
20:57gfrlogbut I'd rather the http calls be one-at-a-time
20:57gfrlogso I do them in the main thread
20:57gfrlogvia the agent
20:57raekwhere does the waiting come in?
20:58gfrlogwaiting for the result of the http
20:58raekthat sounds more like futures
20:58gfrlogbut I don't want the next http call to start before the last one finishes
20:58raekif you do a @ on a future, it will block until the values is completed
20:58gfrloghmm.
20:59raekwhy not simply do the calls one after another?
20:59raekin one thread
20:59gfrlogso
20:59gfrlogthe main thread I want to make http calls whenever one of the worker threads finishes, or 30 seconds elapses, whichever is first
21:00raekanway, to answe the original question: yes, agents are not allowed to wait for other agents in their action functoin
21:00gfrlogso I could tell him to sleep for 30 seconds, but then how does he get interrupted by the workers?
21:01gfrlogI'll rework it I guess
21:02gfrlogthanks
21:02raekI'm sorry... I can't come up with a simple solution right now...
21:02gfrlogI know, this setup is rather complex
21:03gfrlogI have a hard enough time coming up with good ideas even with full knowledge
21:03raekfutures have a future-cancel function too, might be good to know
21:03gfrlogyep
21:03gfrlogI'm using futures for the worker threads actually
21:04raekI guess the worker agents could send a "I'm ready for work" message to the main agent or something
21:05gfrlogbut then the main thread is still an agent
21:06gfrlogI wonder if I can sidestep it by just wrapping the await in a future
21:06raekmaybe one could send an "add job" message to the main agent, which adds the job to a queue (the main agent's sate)
21:06gfrlogah hah! the sidestep worked
21:07gfrlogso an agent can wait on a future, but not another agent
21:07gfrlogthat seems arbitrary from my naive point of view
21:07raekan agent kind of is a thread
21:08raekand a future is a thread too
21:08raekso the agent is not waiting
21:08gfrlogI bet the clojure.contrib.http.agent library would be better rewritten with futures anyhow
21:08raekbecause another thread does the waiting
21:08gfrlogthe agent waits for the future though
21:09raek...and then when a worker agent is ready, it sends a function to the main agent that will pop the next job and send it to itself
21:10raekanyway, agents are asynchronous in their nature
21:10gfrlogright
21:11raekbut they might be the closest fit anyway, if one needs the queing facility
21:11gfrlogyeah, I think it works fine without that one issue
21:11gfrlogI'm actually only using one agent
21:11gfrlogthe "worker threads" are all futures
21:15spewnHow does one typically deal with having a defstruct foo and passing instances of that struct to a function as an arg named foo?
21:15spewnI can only think of renaming one or the other to struct-foo or a-foo, but that seems awkward.
21:16gfrlog,(keys {})
21:16clojurebotnil
21:16gfrlogick
21:16gfrlog,(or (keys {}) [])
21:16clojurebot[]
21:19gfrlogspewn: if you were using deftype, you could have Foo and foo
21:19spewngfrlog: I'll have to wait until 1.2 comes out for that, I think
21:20gfrlogyeah :(
21:43pdkhow is 1.2 release looking now anyway
21:43pdki see on the dl page it's at rc3
21:48gfrlog,(.substring (str :keyword) 1)
21:48clojurebot"keyword"
21:54brweber2gfrlog you could use (name :keyword), of course I have no idea what you are trying to do...
21:54gfrlog(name :youreright)
21:54gfrlog,(name :onemoretime)
21:54clojurebot"onemoretime"
21:54gfrlogah ha
21:55gfrlog,(doc name)
21:55clojurebot"([x]); Returns the name String of a string, symbol or keyword."
21:55gfrloggood man!
21:55gfrlogthat'll clean my code up
22:27eckrothhow do I convert a map to a string? (str [1 2 3]) works but not (str {:a 1 :b 2})
22:28defneckroth: how do you want it to look
22:28defnlike "a 1 b 2"?
22:28eckrothdefn: anything that can parse into a map with (read-string)
22:28eckrothoddly try-clojure.org halts on (read-string "{:a 1 :b 2}")
22:29defnRaynes: 21:28 < eckroth> oddly try-clojure.org halts on (read-string "{:a 1 :b 2}")
22:29eckrothdefn: thanks for forwarding to Raynes :)
22:29defn:D
22:29defneckroth: so you want to...serialize this to a file or?
22:29eckrothdefn: exactly
22:30defniirc you need to use *print-dup*
22:30defnone sec
22:30a_strange_guy,(print-str {:a 1, :b 2})
22:30clojurebot"{:a 1, :b 2}"
22:30defnyeah but that wont work with read-string i dont think, will it?
22:30defn,(read-string "{:a 1, :b 2}")
22:30clojurebot{:a 1, :b 2}
22:30a_strange_guy,(read-string (print-str {:a 1, :b 2}))
22:30clojurebot{:a 1, :b 2}
22:31defni must be wearing orthopaedic shoes...
22:31eckrotha_strange_guy: a great
22:31eckrotha_strange_guy: ah great I mean
22:31defneckroth: http://clojuredocs.org/v/2020
22:32defneckroth: you want to use *print-dup* -- im failing to remember why that is the case right now
22:34defneckroth: ah -- it's if you're serializing something in your map which is a java object:
22:34a_strange_guy*print-dup* conserves the type of maps and numbers etc
22:34eckrothdefn: ok right
22:34eckroth,(binding [*print-dup* true] (str {:a 1 :b 2}))
22:34clojurebot"#=(clojure.lang.PersistentArrayMap/create {:a 1, :b 2})"
22:34defn,(read-string (print-str {:a (java.util.Date.), :b 1}))
22:34clojurebotjava.lang.RuntimeException: java.lang.Exception: Unreadable form
22:35a_strange_guy(binding [*print-dup* true] +)
22:36a_strange_guy,(binding [*print-dup* true] (print +))
22:36clojurebot#=(clojure.core$_PLUS_. )
22:36defn,(read-string (binding [*print-dup* true] (str {:a (java.util.Date.), :b 1})))
22:36clojurebotjava.lang.RuntimeException: java.lang.IllegalArgumentException: No method in multimethod 'print-dup' for dispatch value: class java.util.Date
22:36defna_strange_guy: you're a strange guy.
22:37a_strange_guyxD
22:37a_strange_guyif you want to serialize POJOs then you have to extend the print-dup multimethod to Serializable
22:38eckroththere should be no expectation that "any" POJO can be serialized
22:39a_strange_guyneither is every datastucture printable
22:40eckrotha_strange_guy: such as records at the moment, right? they cannot be printed
22:40eckrotha_strange_guy: and multimethods I assume
22:41a_strange_guy ,(binding [*print-dup* true] (print #'clojure.core/print-method))
22:41a_strange_guy,(binding [*print-dup* true] (print #'clojure.core/print-method))
22:42clojurebot#=(var clojure.core/print-method)
22:42a_strange_guy,(binding [*print-dup* true] (print @#'clojure.core/print-method))
22:42clojurebotjava.lang.IllegalArgumentException: No method in multimethod 'print-dup' for dispatch value: class clojure.lang.MultiFn
22:42eckroth,(binding [*print-dup* true] (print (fn [x] (+ 1 x)))
22:42clojurebotEOF while reading
22:42eckrothoh bother
22:42eckroth,(binding [*print-dup* true] (print (fn [x] (+ 1 x)))
22:42clojurebotEOF while reading
22:42eckrothwhoops again
22:43a_strange_guy,(binding [*print-dup* true] (print (fn [a] (+ a a)))
22:43clojurebotEOF while reading
22:43a_strange_guy,(binding [*print-dup* true] (print (fn [a] (+ a a))))
22:43clojurebot#=(sandbox$eval502761$fn__502762. )
22:43eckrothso, usless
22:44a_strange_guyactually it works
22:44a_strange_guyyou can read functions
22:45defnit's also dangerous
22:45a_strange_guyunless they are closures
22:45defnand the sandbox would be smart to not let you just read in any old string
22:45eckrotha_strange_guy: not if you lose state, right? that printed function makes no sense once you restart java
22:46a_strange_guytoplevel fns do work actually
22:46a_strange_guyif you AOT
22:46eckrotha_strange_guy: I mean anon functions
22:47eckrotha_strange_guy: I don't know why print can't just represent as the same datastructure that defines the anon func (that is, '(fn [x] ...))
22:48a_strange_guybecause clojure compiles everything
22:48a_strange_guythe source is gone then
22:48defnthere's a way to pretty print an anon function fwiw
22:48eckrotha_strange_guy: but the datastructure remains
22:48defnfrom a string i mean
22:48a_strange_guynope, no datastructure
22:49eckrotha_strange_guy: what is no datastructure? an anon func has no associated datastructure?
22:50a_strange_guyan anon func is just a singleton instance of a java class
22:50a_strange_guy(more or less)
22:50eckrotha_strange_guy: why say singleton instance? why not just instance?
22:51defnsingleton implies anon i believe
22:51defna_strange_guy: is that right?
22:51defnor at least in the ruby object model it does
22:52a_strange_guysingleton means that there is only one instance
22:53a_strange_guyyou don't need more than one if the fn is not a closure
22:53a_strange_guybut I am not sure if clojure compiles that way
22:54a_strange_guy(letfn [(make-fn [] (fn [] nil))] (indentical? (make-fn) (make-fn)))
22:55a_strange_guy,(letfn [(make-fn [] (fn [] nil))] (indentical? (make-fn) (make-fn)))
22:55clojurebotjava.lang.Exception: Unable to resolve symbol: indentical? in this context
22:55a_strange_guy,(letfn [(make-fn [] (fn [] nil))] (identical? (make-fn) (make-fn)))
22:55clojurebotfalse
22:55a_strange_guyforget singleton
22:55defna_strange_guy: you're a strange guy.
22:56defnim sorry but i cannot resist
22:56defngreat nick
22:56defnreminds me of a strange loop
22:56a_strange_guyfrom G.E.B?
22:58defnthe author of GEB wrote a book called "I am a Strange Loop"
22:58defnhttp://en.wikipedia.org/wiki/I_Am_a_Strange_Loop
22:59Rayneseckroth: Aye, read-string shouldn't even been allowed. Thanks for letting me know.
22:59a_strange_guydamn, I have to read that
22:59defna_strange_guy: :) It's fantastic.
22:59RaynesOh wait.
23:00RaynesI was thinking of read-line.
23:00RaynesThat is odd. It doesn't seem to be halted though.
23:00defna_strange_guy: I also very much recommend "The Mind's I"
23:00defnby Hofstadter and Dennett
23:01Raynes-> (read-string "{:a 1 :b 2}")
23:01sexpbot=> {:a 1, :b 2}
23:01RaynesOdd.
23:01defnthat could be naughty.
23:01a_strange_guydefn: thanks, GEB already blew my mind
23:01RaynesThat's beside the point.
23:02RaynesI have no clue why it would make it freeze (if only temporarily).
23:02a_strange_guythis seem to be its successor ^^
23:02Raynes(read-string "3") works
23:02defn-> (read-string "#=(var foo)")
23:02sexpbotjava.lang.Exception: EvalReader not allowed when *read-eval* is false.
23:03RaynesIt only fails with maps it seems.
23:03defnhm, weird
23:03Raynesdefn: Licenser isn't that stupid. ;)
23:03defnRaynes: haha :)
23:03RaynesIt even works with vectors.
23:03eckrothRaynes: yeah, odd :)
23:04RaynesLicenser: When you get back, check out the backlog. This might be a job for the almighty Heinz. I don't even know where to start.
23:04defn-> (map class [{} [] '()])
23:04sexpbot=> (clojure.lang.PersistentArrayMap clojure.lang.PersistentVector clojure.lang.PersistentList$EmptyList)
23:04RaynesSeems like Licenser does more work on tryclojure than I do these days. ._.
23:04defnwhat's the REPL say
23:06defnRaynes: might wanna look at clojure.lang.RT as well
23:07Raynesdefn: ?
23:07defnjust thinking out loud
23:07RaynesI don't know what you mean.
23:08RaynesOr what you're implying.
23:08Raynes:p
23:09defnRaynes: no implication, simply places I would begin investigating-- read-string uses clojure.lang.RT
23:09RaynesOh.
23:10RaynesI know what I need to do. I can find out if this is a sandbox problem, and if it is, I can just whine to Heinz.
23:10RaynesLuckily, try-clojure has a bit of a public API I can use without the Javascript console.
23:11Raynesjava.lang.NullPointerException
23:12RaynesWell, I see the problem.
23:13Raynesdefn: http://try-clojure.org/magics?code=(read-string%20%22{:a%201%20:b%202}%22)
23:13RaynesTell me what you see.
23:13Raynes;)
23:14defnRaynes: hah
23:14defnRaynes: you know, i had a similar problem with walton
23:15defnfunctions which were in the sandbox which just refused to show up
23:15RaynesThe problem is that the console does nothing but sit there if nothing is returned by it's callback.
23:15Rayneseckroth: It isn't locking up, the cursor is just disappearing. After you type the read-string stuff, you can move the cursor with the arrow buttons and then delete what you typed.
23:16RaynesBut the actual reason that it isn't returning anything is the real problem.
23:16RaynesI'll work on that later tonight or tomorrow.
23:24defngoogle analytics is great
23:25defn(doc root-cause)
23:25clojurebotGabh mo leithscéal?
23:25defn->(doc root-cause)
23:25sexpbotjava.lang.Exception: Unable to resolve var: root-cause in this context
23:27Raynes->(doc clojure.stacktrace)
23:27sexpbotjava.lang.SecurityException: Code did not pass sandbox guidelines: (#'clojure.core/print-namespace-doc)
23:27Raynes->(doc clojure.stacktrace/root-cause)
23:27sexpbot=> ------------------------- clojure.stacktrace/root-cause ([tr]) Returns the last 'cause' Throwable in a chain of Throwables. nil
23:27defndanke
23:27defn(read-string (read-string
23:27defngrr
23:27defn-> (read-string (read-string "{:a 1 :b 2}"))
23:27sexpbotjava.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to java.lang.String
23:41no_mindare there any plans to get rid of JVM from clojure in near or distant future ?
23:43RaynesNo. Why would there be?
23:43Raynes:o
23:43RaynesClojure in Clojure is one current focus, and it'll make it easier for their to be other implementations of Clojure, but as of now, the JVM is the primary platform for Clojure.
23:54mmarczykhey guys, I've just done a write-up on Compojure... I'm not (at all) a web programmer, but I am becoming interested in the field, so it was an interesting exercise... anyway: any comments?
23:54mmarczykhttp://stackoverflow.com/questions/3488353/whats-the-big-idea-behind-compojure-routes/3490479#3490479
23:54mmarczykhi Raynes :-)
23:56Raynesmmarczyk: Hai.
23:58Raynesmmarczyk: I want to read that, but I don't know if I have the energy.
23:58Raynes;P
23:58mmarczykoh come on :-P
23:59mmarczykon a more serious note, I'd love to find out whether the general picture is correct and what I'm missing...
23:59mmarczykno hurry, though ;-)
23:59RaynesActually, this is something that might help me understand Compojure better.