#clojure logs

2009-11-16

00:06solussdJust finished my highlfe implementation in clojure, if anyone's interested in some late night REPL fun: http://www.solussd.com/?p=118
00:08tomojsolussd: what are you using to highlight clojure code?
00:09solussd"SyntaxHighlighter Evolved" for wordpress. It isn't perfect, but you can easily edit the "brushes" for a language's syntax
00:10tomojthanks
00:10tomojjust installed wordpress for the first time the other day
00:13solussdI I found the clojure syntax highlighter brush here: http://travis-whitton.blogspot.com/2009/06/syntaxhighlighter-for-clojure.html Turn it into a javascript file called shBrushClojure.js. You'll have to make some small modifications to the syntaxhighlighter evolved plugin to tell it where to find it.
00:13tomojfor now I am just going to embed gists I think
00:14solussdYou can make the plugin changes directly from the wordpress 'admin' screens (click the modify link next to the plugin).
00:14solussdok- If you do decide to install the plugin, you can do it right from wordpress's admin screens using the plugin installer.
00:18duncanmtechnomancy: i just installed slime via elpa, and i'm getting a FileNotFoundException
00:18duncanmtechnomancy: is there something i'm missing? java.io.FileNotFoundException: Could not locate swank/swank__init.class or swank/swank.clj on classpath: (NO_SOURCE_FILE:0)
00:19defnwhy is (if test then else?)
00:19defnnot in the api documentation on clojure.org?
00:20arbschtduncanm: did you add (clojure-slime-config ...) to your init file as instructed?
00:21somniumdefn: http://clojure.org/special_forms#toc2
00:22somniumduncanm: I installed a few hours ago, had to clean out .clojure and then it installed everything. though swank-clojure-project looks for the swank-jar in lib
00:24defnsomnium: i know about that page -- but the special forms are completely missing from the API link
00:24defnwhich seems wrong to me, but *shrug*
00:24defnI know there's the direction to read special forms, but I don't see why you wouldn't include them in the larger list of api documentation
00:25duncanmarbscht: where are the instructions?
00:26arbschtduncanm: at the end of the clojure-install procedure
00:26somniumarbscht: I think that configuration step isn't necessary with the just released version
00:26somniumclojure-install says its deprecated now when I tried to run it
00:26arbschtoh?
00:26arbschtI see
00:26somniumnew version just up on elpa
00:27duncanmsomnium: that's nice
00:29maravillassolussd: i added a comment recently regarding that clojure brush
00:29maravillasneed to tweak a couple of the regexes to highlight keywords properly
00:30solussdmaravillas- cool, do you have the tweak? I'll try it now. :)
00:30maravillasand unfortunately the tool's getKeywords method doesn't provide a way to specify "keyword" boundaries
00:31maravillas{ regex: /:[a-z][A-Za-z0-9_\-]*/g, ...
00:31maravillasonly difference is the \- in the pattern
00:36solussdthanks
00:36maravillasno problem
00:36_ato,:+-*/.<>=!?$%_&~^:@
00:36clojurebot:+-*/.<>=!?$
00:36maravillasheh
00:36maravillaswell then
00:36maravillasguess there's more work to do
00:36_ato,:+-*/.<>=!?$_&~^:@
00:36clojurebot:+-*/.<>=!?$_&
00:36_ato,:+-*/.<>=!?$_&^:
00:36clojurebot:+-*/.<>=!?$_&
00:37_atohehe
00:37maravillasah yes, looks like the question mark at least is applicable to you, solussd :)
00:38solussdI love being able to use a question mark and exclamation points.
00:39solussdeven better, I like using dashes in symbol names. this-is-much-more-readable thanTryingToReadStupidCamelCase
00:39maravillasof course they seem to be valid, but i wonder how often people use anything other than alphanumerics and dashes in keywords?
00:39solussd... and hitting the shift key is for suckers..
00:40solussdquestion marks are good for predicates
00:40solussde.g. (if alive? (something) (something-else))
00:40_atolike {:alive? true, :name "Rupert"}
00:40maravillassure, but i mean keywords
00:40_atoha, we picked the same example
00:41maravillaswell, i'll concede question marks, i guess
00:41duncanmmaravillas: having ! in identifiers is common in other lisps too
00:42duncanmthings like initialize!
00:42maravillasi mean only keywords
00:42duncanmruby copied that into its libraries, afaik
00:42duncanmmaravillas: why does it matter anyhow?
00:42maravillasit doesn't
00:42maravillasi'm just curious :)
00:43duncanmin CLOS, i think there's a style of using <Point> to notate a class
00:43duncanm$foo is often used to refer to fluid variables
00:43maravillasno, i get all that
00:43maravillasi mean specifically clojure keywords
00:43maravillasmeaning, for example, :initialize!
00:44solussdI use :alive? in my highlife program. :)
00:44_atoI could see :+ :< :& etc being used in the context of something like {:operation :+}
00:45duncanmon a separate topic, i thought it might be cool to extend the literal syntax, so that there're literals for URLs and Paths (coming in JDK7)
00:45maravillasah yes, good point
00:47maravillaswhat were you considering?
00:48duncanmah, "The read table is currently not accessible to user programs." -- so no user-defined reader macros for now ;-P
00:48duncanmhaving |/home/duncan/foo| ought to be pretty handy
00:49duncanmor maybe #|/foo/bar|
00:49duncanmi work on Windows during the day, so having support for DOS-style paths would be great
00:49duncanm#|C:\Program Files|
00:50jkkrameranyone know if it's possible yet to get a value from a transient hash set without specifying a key? e.g. something like (nth (transient #{1 2 3}) 0) => 1 ?
00:51chouser[most] urls are already valid symbols
00:51chouser'http://foo.bar.baz/bing/bang.html
00:51chouser,'http://foo.bar.baz/bing/bang.html
00:51clojurebothttp://foo.bar.baz/bing/bang.html
00:52duncanmchouser: i don't get your point
00:53duncanmmaybe it's not worthwhile to add more literal syntax, (File. "/foo/bar") is not *that* much longer
00:53chouserwell -- what were you going to use literal syntax for URLs to do?
00:53_atojkkramer: you can't, you'll have to call persistent on it
00:53jkkramer:(
00:54jkkramerthere's a commit saying TransientHashSet was implemented, but seems like only conj! and disj! work, not get or nth. those work for TransientVector
00:56duncanmchouser: i've been using clojure to write a lot of shell-script like programs, and esp. having to reverse my \s into /s has been kinda annoying
00:56tomojwhat do you expect nth to do on sets?
00:56_atommm, HashSets are HashMaps underneath and TransientHashMap doesn't support nth either
00:56duncanmtwbray: did you restart your phone? maybe you need to soft reboot it
00:57twbrayduncanm: several times
00:57chouserduncanm: \ is already reversed. / is the right way to separate paths. ;-)
00:57_atoah yeah nth doesn't work on a set at all
00:57duncanmtwbray: did you jsut turn it on and off? or did you do the red button + home key thing?
00:58jkkrameri actually just want to get an arbitrary value from a persistent set, doesn't matter which one. i just don't want to have to specify the key
00:58twbrayduncanm: Had to do that a couple times as part of the upgrade process. could do it again. Searching, maybe a known problem :(
00:58jkkramerwas groping around for something like first or nth or something
00:58duncanmoh
00:59duncanmtwbray: i have a G1 from T-Mobile, the update worked for me fine, sorry.
00:59twbrayduncanm: Yeah, problem seems specific to the Ion AKA Google I/O devie
01:46mikemhi, what's the clojure way to execute a series of functions in order? in common-lisp the prog form is used for that
01:48hoeck1mikem: do
01:48hoeck1,(do 'foo 'bar)
01:48clojurebotbar
01:48mikemhoeck1: ah, great, thanks
01:49hoeck1mikem: np :)
02:51hiredman,(apply conj (ring-buffer 10 [] 0) (range 1000))
02:51clojurebot#<sandbox$ring_buffer$reify__3709 [990 991 992 993 994 995 996 997 998 999 989]>
03:58mikemis (assoc a (count a) "item"), where a is a vector, the best way to append an item to the end of a vector?
03:58hiredmanuse conj
03:58mikemby "append" i mean "return a new vector that's the same as a with item appended" of course
03:58mikemhiredman: ah yes, conj. Thanks
04:46Licensermorning everyone
04:51AWizzArdMoin Licenser
04:52LicenserHow are things going in the clojure worlds?
04:52yason_Licenser: almost purely functional, thank you for asking
04:53Licenserglad to hear that :)
05:23LicenserI've a macro that encalpsulates a ssh session and allows to run commands and stuff on a remote host, what is the more ideomatic name for ti with-session or do-session, it kind of both makes sense to me. Do since it has side effects and with since it kind of is a with-open block in my eyes
05:24_atoI'd call it with-session
05:25Licenserthanks that was what I went with in the first place too
05:25_atodo-stuff tends to make me think of doto, doseq, dotimes etc. Things that change the code structure
05:27Chousukegenerally do is used to imply that the thing is used for side-effects.
05:28Chousukepresumably running commands over ssh is rather side-effecty, but with-session is idiomatic for a macro that creates a context.
06:35Drakesonhow can I interrupt a slime repl? C-c C-c does not seem to work.
06:36_atoC-c C-b
06:36_atodoesn't always work though
06:40Licensersorry for the delay and thanks for the input I'll stay with with-session then
06:43Licenserhmm exec, scp-put, scp-get something else that might be important?
06:51_atoLicenser: do you support directory copies (ie the "D" scp command) with scp-put? if not, that might be something useful if you're making a general clojure ssh library
06:54Licensergood idea
06:54Licenserlets figure out how that works :P
07:19Licenserhrm jsch sems not tu support that :/
07:19_atowait... jsch has builtin scp support? gah.. I did it myself
07:20AWizzArdrhickey: in the last but one example at http://www.assembla.com/wiki/show/clojure/Protocols it could also be 'AMultiProtocol' vs without 'Multi'
07:21_atoLicenser: http://blogs.sun.com/janp/entry/how_the_scp_protocol_works
07:26Licenser_ato: it has a very neat sftp support
07:26Licensernot scp directly
07:28_atoah right
07:30Licenserscp looks very ugly and I didn't liked it so I used sftp, I stumbled about the same stuff you linked me to - I found it way too complicated
07:30Licenserthen again a good scp library for clojoure would be cool I guess
07:30Licensersince sftp does not seem to copy directories :/
07:32_atothere must be a way to do it somehow as the sftp command supports it
07:33_atomaybe JSch just doesn't implement it :/
07:33_atooh well :)
07:33Licenser_ato: might not be implemented in jsch,
07:33Licenserwell or ti does but does not document it :P with couldn't be surprising
08:31Licenserhmm apply does not work with special forms? o.O
08:33chouserLicenser: I don't see how it could. what are you trying to do?
08:35Licenserjust tried to use (apply . object method arglist)
08:36chouserah, yes.
08:36Licenserwhich isn't working too well :P
08:36chouser"method" is not evaluated so that's just not going to work. If you know the method name at compile time, you have an excuse to write a macro.
08:37Licenserthen again I am horrible with amcros
08:37Licensermethod is not something to be evaluated I know the method name
08:38Licenserhttps://gist.github.com/a6e903ef4c7998d82d34 <- that is what I'm trying to do :P mostly at least
08:39yasonLicenser: would memfn help?
08:40chouserthat's a lot of code for a macro.
08:40chousermemfn hardly ever helps -- you can just use #(something) instead
08:40Licenserhmm chouser I think you're right
08:43chouserit's a macro so you can capture 'session ?
08:45Licenser(with-session "user" "pass" "host" 22 (do-sftp (:put "D:/test/1.txt" "/tmp") (:get "/tmp/1.txt" "D:/")))
08:45_atoLicenser: might be better to use a binding instead and just use a regular function for do-sftp
08:46_atooh wait... you want a list
08:46Licenserso a) I can fetch session and b) to not have to pass nice () stuff instead of ugly '() stuff
08:46_atohmm
08:47chouserwould you find [:get "/tmp/1.txt" "D:/"] acceptable?
08:47Licenserhmm it kind of is not as nice as ()
08:49chouserok, so I'd recommend your do-sftp macro just repackage your args -- capture 'session if you want and convert your (:put ...) to [:put ...], and then pass it all to a function to do the real work.
08:49chouserah. like that!
08:49chouser:-)
08:49Licenser^^
08:49Licenserbriliant minds think alike, and sometimes even I get teh same idea if it's obviouse enough .P
08:49chouserthough you could probably move even more things into the fn
08:50Licenser*nods* the open and close likely
08:50Licenseror connect and disconnect
08:50ohpauleezI'm new to Clojure but not to Lisp in general. What does the hash after a symbol do?
08:50chouserohpauleez: auto-gensym
08:50Licenserit generates a id'ed symbol for macros
08:50ohpauleezahhh cool
08:50ohpauleezthank you both
08:52Licenserhey I'm glad if I once can help and don't just ask all the time :P
08:52chouserLicenser: note the way you've got it there, you can only pass in literal strings for your (:get ...) args.
08:53ohpauleez:) I understand the feeling. I remembered seeing it here (http://en.wikibooks.org/wiki/Learning_Clojure#Macros) but forgot when I was looking at your code
08:53Licenser^^
08:54LicenserI see, you're right again chouser that is bad'ish
08:54Licenserhmm bindings kind of broke stuff soo
08:55_atoLicenser: https://gist.github.com/989fbc3b6972c145d1a3
08:55_atoI'd do something more like that
08:55_atoso you can put ifs and stuff in the body
08:55_atobut that might not be what you're going for
08:56Licenser_ato: actually it pretty much is, so I wanted to remove the sftp prefixes from the stuff
09:00Licenser_ato: so I like how you do that with binding
09:01_atoyeah, means you can use functions instead of macros, and the calling code can also use functions without having to worry about passing the myserious invisible session and sftp symbols around
09:10rhickey_http://paste.lisp.org/display/90495
09:10rhickey_I think I want something like this for when defs are being explicitly provided^^
09:11chousercan you do extend more than once on the same type without overwriting?
09:14Licenser_ato: mind if I pick up from that idea?
09:15_atosure go for it
09:17Licenserthanks
09:19rhickey_chouser: separate extends?, yes, only overwrite same protocol/type combo
09:19rhickey_ big part of protocols is independent extension
09:19chouserah, of course.
09:20rhickey_fred write P, ethel writes T, lucy extends T to P
09:20chouserok, so you could mix extend-type with extend if one of the protocols needed merge but the others didn't
09:20rhickey_right
09:20rhickey_I just see a lot of impls being explicit and inline, where the map stuff is just in the way
09:21rhickey_also the type hint could come from the type up top and not be repeated
09:24rhickey_anyone want to take a crack at those?
09:27chouserif you don't mind waiting a couple days, I bet someone on the dev group would like to get involved.
09:28_atothat reminds me
09:28_atorhickey_: don't suppose you've received my CA yet?
09:28ohpauleezAre the protocols in clojure similar to that of ObjC?
09:29ohpauleeznvm: http://www.assembla.com/wiki/show/clojure/Protocols
09:29rhickey__ato: all people with CAs are listed on the contributors page, if you are not there I haven't gotten it (note I only check the box every week or so)
09:29_atoah ok, thanks
09:30_atosent it on the 6th so it'll probably be there next time you check
09:30_atono worries :)
09:32rhickey_ohpauleez: they differ in significant ways - ObjC is duck-typed, and protocols map to class methods
09:33rhickey_Clojure protocol functions are not methods of the classes that extend the protocol
09:33rhickey_you do not indicate support of a protocol in the definition of the extending class
09:33rhickey_they are not duck-typed
09:33ohpauleezthey're generic, which opens up a lot of cool possibilities
09:33ohpauleezI'm reading that wiki page now
09:34ohpauleezps: I'm Paul, I worked on the JVM backend for PyPy
09:34rhickey_cool
09:34ohpauleezI'm migrating here, catching up, and digging in
09:35chouserohpauleez: I've got some functional-flavoured kool-aid here if you'd like a sip.
09:36ohpauleezI tend to do more functional-esque styles in Python than OO stuff, and really enjoy Common Lisp
09:37ohpauleezclojure has answered many of my issues with common lisp, it's an ideal middle ground for me
10:53the-kennyWhat can cause (take 24 @my-agent) to fail with a NullPointerException when (take 23 @my-agent) works? (last works too, as does nth)
10:54the-kennyI think something very strange is happening here... The code worked for some hours now, but suddenly I get this NPE.
10:54chousermy-agent could be a lazy seq that errors when it tries to compute the 24th item
10:54chouseroh, 'last' works?
10:54chouserhmph
10:54the-kennyYes
10:54the-kennyAS does nth
10:57the-kennyI use this agent as a simple queue were elements get added from a thread pool.
10:57chouserthe stack trace doesn't point you anywhere?
10:57the-kennyThe add-method is just a simple (if (> (count state *limit*) (commit-to-couchdb) (cons state json))
10:59the-kennychouser: hm strage, emacs has hidden the stacktrace.. bad emacs, bad!
10:59the-kennySomewhere in the regex-api
11:01the-kennyhm strange, I can't imagine how lazyness could cause such an error
11:03the-kennyhm.. I think it would help to force the evaluation of the json before I add it to the queue, right?
11:04the-kenny..maybe evaluation is the wrong word.
11:04chouseryeah, if you're reading from a file or stream into a lazy seq and then passing that off to another thread, there's definitely more timing complexity there than you probably want to deal with.
11:05the-kennyhm.. ok. It's just strange that this happens after hours and not before.
11:06the-kenny(Sorry, my english isn't very good :)
11:06chouseryour english is fine. yeah, I can't tell you what's wrong without more details.
11:07the-kennyI read from a stream (http), parse this as json, pass some parts of the json to some functions to extract new data, collect this data into a new json struct, add this to the queue and push the queue to couchdb :)
11:10AWizzArdWhat foo do I need to have (= ::x (foo (deftype x []))) ==> true ?
11:10AWizzArdSo, how do I go from a Var to a keyword, including the namespace?
11:13chouseryou really want to process the return value of deftype, not the return value of (x ...) ?
11:13stuartsierra(defn foo [var] (let [m (meta var)] (symbol (name (:name m)) (name (ns-name (:ns m))))))
11:13Licensergeez stupid questio, how to :use :only within a ns?
11:14stuartsierraLicenser: (ns ... (:use [foo :only (one two three)]))
11:15Licenserwoooh thanks stuartsierra i think I treid every other combination form m[ and (
11:15AWizzArdchouser: yes, I would like to know if/how I can go from a var to a Namespace-Keyword.
11:18AWizzArdand maybe other than (keyword (subs (str #'user) 2)) :-)
11:19chouserstuartsierra gave the right answer, at least until we can talk rhickey into having Vars implement Named
11:21arohnerIs swank known to work on the deftype/defprotocol branch?
11:21arohnerI'm getting java.lang.NoSuchMethodError: clojure.lang.RestFn.<init>(I)V
11:21arohner at swank.util$flet__9.<init>(util.clj:5)
11:23the-kennyoh strange
11:23the-kennychouser: (nth 23 @my-agent) throws now too.
11:23the-kennyLooks like the 23th element is broken
11:24the-kennyIs there something like a reverse-take?
11:24stuartsierraarohner: I got the same error
11:25arohnergreat, mvn compile against swank downloads its own clojure.jar, rather than trying to build against my branch
11:26chouser(doc take-last)
11:26clojurebot"([n coll]); Returns a seq of the last n items in coll. Depending on the type of coll may be no better than linear time. For vectors, see also subvec."
11:26the-kennyThanks :) The 23th element is definately broken.
11:29rhickey_extend-type and extend-class are up
11:31stuartsierraarohner: You can build your own Clojure JAR and install it with Maven
11:31arohnerstuartsierra: how do I do that? Build the jar and then copy it to...?
11:32stuartsierraGet the Clojure sources, checkout the new branch, and run "mvn install"
11:32stuartsierraIn the Clojure source dir
11:32rhickey_would extend-protocol be too confusing? when you want to provide several impls of the same protocol in one shot
11:33rhickey_(extend-protocol P AType (foo ...) (bar ...) BType (foo ...) (bar ...) AClass (foo ...) (bar ...) ...)
11:33chouserhmph. my extend-type is just now working.
11:33chouserI have no self-control.
11:33rhickey_if only I knew you were trying it
11:33chouseror I you
11:34rhickey_right
11:34chouseroh well, your is better
11:34chouserhttp://paste.lisp.org/display/90495#1
11:35rhickey_I ended up bailing on the keyword-izing, for two reasons, one, it can get confusing when you need to use the keyword and not, and two, extend-type can now work on classes or nil too
11:35chouserok.
11:36chouserkeywordizing qualified vs. unqualified symbols required surprising work
11:36rhickey_iirc in CLOS I was confused about when to quote clasnames
11:36AWizzArdWhy do Vars have a .ns with some content and a .sym whose namespace is nil?
11:36arohnerstuartsierra: my new clojure claims it is 1.1-alpha, but swank-clojure builds against clojure-1.0.0. should I rename the jar, or do something else?
11:37rhickey_chouser: there really isn't a good rationale for how to 'resolve' to a keyword, as the user might or might not have pulled in the name otherwise
11:37arohnernm, I see the dependency line in the pom
11:37stuartsierraarohner: change the version in the swank-clojure POM to match your new Clojure build
11:37rhickey_chouser: what do you think of extend-protocol idea ^^ ?
11:38rhickey_flips protocol/type
11:40chouserto let you compose in roughly the groupings that core.clj does today
11:42rhickey_yeah, just looking t replacing things like RT.count
11:42rhickey_else if(o instanceof String) return ((String) o).length();
11:42rhickey_becomes
11:42rhickey_(extend-class String Countable (cnt [s] (.length s)))
11:43rhickey_but with extend-protocol, a bunch of these could be grouped together:
11:43rhickey_(extend-protocol Countable
11:43rhickey_ String (cnt [s] (.length s)))
11:44chouserI think it's probably quite reasonable. It's just that protocols vs types are still a bit slippery for me.
11:44chouserHaving said that, I don't know that extend-protocol would make that particularly worse.
11:45rhickey_this seems pretty snazzy:
11:45rhickey_(extend-protocol Countable
11:45rhickey_ clojure.lang.Counted (cnt [c] (.count c))
11:45rhickey_ String (cnt [s] (.length s))
11:45rhickey_ java.util.Map (cnt [c] (.size c))
11:45rhickey_ nil (cnt [_] 0))
11:46chouseryeah, can't really argue with that
11:46AWizzArdOtherwise many "extend"s would be needed?
11:46chouseresp. since the alternative would be to say "extend foo Countable" a lot
11:47ohpauleezfwiw, I totally favor that (rhickey)
11:47ohpauleezI just ran into that this past weekend actually
11:47rhickey_(extend-class clojure.lang.Counted Countable (cnt [c] (.count c)))
11:47rhickey_(extend-class String Countable (cnt [s] (.length s)))
11:47rhickey_(extend-type nil Countable (cnt [_] 0))
11:47rhickey_(extend-class java.util.Collection Countable (cnt [c] (.size c)))
11:47rhickey_(extend-class java.util.Map Countable (cnt [c] (.size c)))
11:47chouserString #(.length %) ?
11:48wavisif i pass a seq into a method, and that argument is referenced once, is the head of the seq retained until the end of the method despite not being used?
11:48rhickey_chouser: not in these macros, at least not if they auto-type hint
11:49rhickey_one problem with extend-protocol would be determining when it could type hint, since it could be a mix of extended types/classes/nil
11:50chousertypes would use keywords right?
11:54rhickey_chouser: yes, actually not so bad, extend-protocol probably a simple macro on top of extend-type/class
11:55rhickey_another problem with #(.length %) is there's no place for the fn name, which must be present as the protocol might have multiple fns
11:56chouseroh, right, it's actually String (count [s] (.length s))
11:56rhickey_yup
11:56chouseryou were using cnt because it's not cinc quite yet, and count is something else
11:56rhickey_right
11:57rhickey_just experimenting with the perf of a protocol versus the RT methods
11:57rhickey_so far, faster
11:57chouserbeautiful
11:57rhickey_and of course, much better in that they are extensible
11:57chouserI'll have to spend some time eventually figuring out what I'm doing wrong with the finger trees.
11:58chousercons dispatches on the wrong arg
11:58rhickey_yeah, I didn't invent cons :)
11:59chouserhehe
11:59chouserfinger trees want to differentiate between cons and conj
11:59rhickey_but things like that are just a matter of a fn on a protocol fn
11:59chousermaybe cons can be (defn cons [x c] (consLeft c x))
11:59chousersorry!
11:59chousermaybe cons can be (defn cons [x c] (cons-left c x))
12:00chouseroh, that's what you just said.
12:01ChousukeI keep wanting to rewrite the reader on top of protocols and deftype all the time but other things keep me too busy to do that ;(
12:01rhickey_right, the protocol might not be the ultimate end-user api
12:02chousergah. wth is this thing trying to use fcase.clj
12:03rhickey_chouser: allowing for other-than-first arg would add a lot of complexity and reduce flexibility, so I opted out
12:03chouserno, not at all worth it.
12:03chouserfor simple things like cons, the solution is simple.
12:03chouserfor complex things, multimethods are right there
12:19arohnerstuartsierra: I fixed that java.lang.NoSuchMethodError: clojure.lang.RestFn.<init>(I)V by rebuilding clojure-contrib
12:19arohnerI also had to clean clojure-contrib before it would build happily
12:20hiredmanthat exception, as far as I can tell, always means you need to rebuild contrib
12:20hiredmanI don't recall ever seeing it any other time
12:21arohnerhiredman: where were you an hour ago? :-)
12:28rhickey_extend-protocol is up
12:36AWizzArdthx
12:39wavishow do I process a large coll within a method without retaining the head?
12:39stuartsierrarhickey_: really, protocol methods are faster than RT? Awesome. I assumed they would be slightly slower.
12:40stuartsierraSo this means any new type can implement conj/count/first/rest/..., with the same performance as built-in types?
12:41arohner,(doc dorun)
12:41clojurebot"([coll] [n coll]); When lazy sequences are produced via functions that have side effects, any effects other than those needed to produce the first element in the seq do not occur until the seq is consumed. dorun can be used to force any effects. Walks through the successive nexts of the seq, does not retain the head and returns nil."
12:41wavisarohner: doesn't work. the head of the coll is retained until the end of the method
12:43wavisi made it work by creating a once-accessible IDeref that sets its value to null after the first access. but that's messy.
12:43stuartsierrawavis: you can iterate over a large collection safely with loop/recur
12:44hiredmanor iterate?
12:45wavisstuartsierra: I haven't tried that, but isn't it essentially the same solution as dorun? I'll open a loop in the mehtod, but the head of the coll will stick around until the end. maybe I need to do something other than use large collections.
12:45hiredmanwavis: are you sure dorun is hanging on to the head?
12:46wavisdorun isn't, but because i pass the collection into the method as an arg, the arg is.
12:46arohner~def dorun
12:46rhickey_stuartsierra: yes, that's the idea
12:46arohnerlooks like the head is only present in the first iteration
12:47rhickey_once count/first/rest become protocols
12:47hiredmanwavis: args are cleared on tail calls
12:47stuartsierrarhickey_: awesome
12:47rhickey_the RT methods a) still have to be wrapped in Clojure fns
12:47rhickey_b) have manual dispatch using conditionals
12:48rhickey_a protocol implementation will get wired into a call site, and even sites that change do caching
12:48rhickey_so most of the time there is no lookup
12:49stuartsierraAh, yes. That's how polymorphism is supposed to work. :)
12:50wavishiredman: right. so i need to compose two methods, one which processes the coll, and hands off to the second step in the process where the head is not retained. OK gracias
12:51rhickey_(defprotocol S (s [x]))
12:51rhickey_(extend-class clojure.lang.ISeq S (s [x] (.seq x)))
12:51rhickey_(def #^clojure.lang.ISeq sq (seq [1 2 3]))
12:51rhickey_(time (dotimes [_ 100000000] (seq sq)))
12:52rhickey_user=> "Elapsed time: 916.738 msecs"
12:52rhickey_(time (dotimes [_ 100000000] (s sq)))
12:52rhickey_user=> "Elapsed time: 619.931 msecs"
13:44pjstadig~suddenly
13:44clojurebotCLABANGO!
13:44pjstadighehe
13:44pjstadigstill works
13:44danlarkindemons have been summoned
13:45danlarkinor should I say daemons have
13:45danlarkinha!
13:50polypusis there a map function which preserves the data-structure type?
13:51technomancypolypus: I usually use reduce for that
13:51polypus(map #(str % "!") ['a 'b 'c]) -> [a! b! c!] not a seq
13:52polypusok thx, just checking
13:58djpowellwrap it in (into (empty s)
14:08danlarkinwhat's the best way to check if a symbol is bound to a byte array?
14:09danlarkin(= (type (make-byte-array) (type v)) is lame
14:09danlarkinoops, mismatched parens there, but you get the idea
14:11AWizzArdrhickey: can one extend Arrays of "long" with a protocol?
14:11AWizzArdOr ArrayList of Foos?
14:20mrSpecHello
14:24ohpauleezis there an easy way to do something like python's "in" as a predicate? ex: if 4 in [2, 4, 1, 3, 5, 6, etc] returns true if 4 is in the collection
14:25ohpauleezI was looking through the cookbook and special forms, but I'm not coming up with anything
14:25piccolino(contains? [2 4 1 3] 4)
14:25ohpauleezalso looked in seq-utils in contrib
14:25ohpauleezahh, thank you
14:25hiredmanbe sure to read the docstring for contains?
14:26rhickey_(some #{4} '[2, 4, 1, 3, 5, 6, etc] )
14:26rhickey_,(some #{4} '[2, 4, 1, 3, 5, 6, etc] )
14:26clojurebot4
14:26ohpauleezAh, that's awesome too
14:27ohpauleezthanks hiredman
14:27rhickey_not only awesome, but correct, the contains? thing isn't
14:27rhickey_,(contains? [2 4 1 3] 4)
14:27clojurebotfalse
14:28piccolinoYeah. That's what I get for guessing a function name.
14:28rhickey_contains? tests associative things for their keys, which for arrays is their indices
14:29ohpauleezI just read the doc and realized that
14:29rhickey_Java's Collection.contains is available, however
14:29rhickey_,(.contains [2 4 1 3] 4)
14:29clojurebottrue
14:29hiredmanreading docs is good
14:31ohpauleezyeah I just couldn't find the common idiomatic approach, thanks guys
14:44rhickeyAWizzArd: arrays of long, yes, if a bit icky (Class/forName "[J")
14:44rhickeyArrayList of Foos, no, generic types are not reified
14:45rhickeybut ArrayList, yes
15:17krumholt_hi i am reading on the clojure.org page about vars and the global environment. i am not a native english speaker so maybe i don't get the meaning but what does this mean? "Bindings created with binding can be assigned to, which provides a means for nested contexts to communicate with code before it the call stack." Is it possible there is a word missing?
15:18kanakkrumholt_: "before _it_ in the call stack" maybe?
15:19hiredmanon
15:19chouserright. "before it on the call stack"
15:20chouserit's a scary little feature, fortunately very rarely used.
15:20krumholt_ok
15:20chouserin fact, I think I've only seen it used in Compiler.java
15:20kanakisn't binding somewhat like special variables?
15:21krumholt_i used binding to get a thread local version of a global variable. just wanted to read up on it and didn't understand the sentence
15:22chousergetting a thread local of a global var is good and common
15:22dnolenkanak: yes
15:22krumholt_ok
15:22krumholt_good thanks :)
15:23chouserchanging it on a deeper part of the call stack in order to communicate up the call stack is unusual, too-clever, and a bit scary.
15:24rhickeyI never got around to wrapping that in a Sow/Reap thing like Mathematica has
15:25rhickeyhttp://reference.wolfram.com/mathematica/tutorial/CollectingExpressionsDuringEvaluation.html
15:25chouserdoes that make it less scary? reaping doesn't *sound* less scary.
15:26rhickeyheh
15:28lisppaste8Chouser pasted "using binding to pass extra return values" at http://paste.lisp.org/display/90515
15:29chouserhm! possibly less scary.
15:31kanakwhat would the disadvantages of having a CL-style multiple return values be?
15:32tomojjava?
15:32chouserkanak: clojure fn calls could no longer be simply java method calls (and vice-versa)
15:33chouserkanak: though someone did build a CL-style multiple return value lib on top of thread-local bindings
15:33chouserages ago
15:33rhickeyearly Clojure prototypes had it
15:34notallamahow do you get a specific branch with git? (i'm trying to download new)
15:34kanakchouser: thanks for the reply.
15:35chouserhttp://paste.lisp.org/display/68919 -- jochu, 1 year, 3 weeks ago
15:35rhickeybut yes, you can't manipulate the real stack using JVM bytecode the way you'd want, so you end up with thread locals, and making it transparent to use either one or more than one of the returns (the key CL feature vs just returning tuples) makes all calls less efficient
15:35rhickeyso it's out
15:35arohnernotallama: git checkout <branchname>
15:36chouser huh. I bet that code all still works. not too shabby.
15:37chouseroh, nope. old 'when' form
15:37chouserbah, nm. that didn't change. :-P
15:37notallamaarohner: i get "error: pathspec 'new' did not match any file(s) known to git."
15:38arohnernotallama: git branch -a to see the list of branches
15:38arohneryou'll probably want git branch -t origin/new
15:40dakroneis there a contrib function similar to duck stream's read-lines, but for reading a # of bytes?
15:40arohnernotallama: that sets up a local branch to track the remote branch, so you can stay up to date with it
15:42notallamaarohner: i have no idea what that means. got it working well enough for my needs, though. thanks!
15:43arohnernotallama: this describes tracking in more detail, if you're interested
15:43arohnerhttp://book.git-scm.com/4_tracking_branches.html
15:43hiredman(comp first (juxt first #(.read (second %) (first %)) (juxt (comp (partial make-array Byte/TYPE) first) second) list)
15:43hiredmanor something
15:44hiredmandakrone: I don't know, but if you are dealing with an inputstream it is pretty trivial to use the .read method directly
15:45dnolenpeople who are up the deftype, defprotocol work - is declaring a protocol the same as writing and loading a Java interface except you can do it dynamically at runtime?
15:46dakronehiredman: doesn't read-lines returns it as a lazy-seq? I was trying to do a pmap over a giant file in 8192-byte sized chucks, would .read work for that?
15:46dakronewithout loading the entire thing into memory
15:46hiredmandakrone: yes
15:46hiredmanit would be slightly more complicated
15:46chouserdnolen: there are several important differences, but that'll do as a sort of rough-cut of the general category of functionaly protocol provides.
15:47dakronehiredman: okay, I'll try using .read directly
15:47dakronethanks
15:47hiredmanyou would use repeatedly
15:47chouserrhickey: is there a story now for consuming protocol-related things in Java?
15:47hiredmanand a thunk that calls .read
15:49dnolenchouser: k good to know.
15:49rhickeychouser: same story, just tell them to implement an interface, on the Clojure side (extend ThatInterface TheProtocol)
15:50rhickeyor now, (extend-class TheInterface ...)
15:50chouserI meant the other way around -- if IPersistentCollection is just a protocol, how does Java use one?
15:50rhickeythe extend-* are definitely handy
15:51rhickeychouser: it always required an interface for Java, and always will. So, there will be matching interfaces if only for that purpose
15:51rhickeyeven with :on that was still the case
15:52rhickeybut, and this is true today as well, any interface for which extend is already written is an ok way to connect to the protocol
15:52rhickeye.g. things that are Java collections and Iterables will work, because the protocols will be extended to them anyway
15:53chouserhm, I think I get it. With :on I was imagining there'd often be a protocol that with just the same methods as the interface.
15:53chouserbut there's no point in that, you can just extend the interface instead of the protocol
15:53rhickeychouser: that may still be, but still 2 things
15:54rhickeya protocol isn't a thing in Java type terms, so not something you could derive from
15:54chouserright, I get that.
15:54rhickeyI have one more idea for :on that might yield some additional advantage to having it, at some implementation complexity cost TBD
15:55dnolenrhickey: so why would you use extend-protocol? (sorry still trying to understand, just saw that you added that)
15:55spuzWhat's the correct syntax for the load-file function? When I try (load-file "sub/dir/file.clj") I get "No such namespace: sub/dir"
15:56hiredman,(doc load-file)
15:56clojurebot"([name]); Sequentially read and evaluate the set of forms contained in the file."
15:56hiredman:|
15:56hiredmanspuz: needs a file://
15:56rhickeywhen you want to write the implementation of a single protocol for several types all at once, reduces repetition
15:56rhickeydnolen: ^^
15:56hiredmanspuz: I think
15:56chouserdnolen: it just lets you group your implementation fns differently: http://clojure-log.n01se.net/date/2009-11-16.html#11:42c
15:56hiredmanactually
15:57spuzhiredman: really? Hmm I'm sure I've used it with the direct file name in the past. Maybe it has to be on the class path?
15:57chouserI've used load-file with a plain path string not on the classpath
15:58lisppaste8rhickey pasted "doc extend-protocol" at http://paste.lisp.org/display/90517
15:58chouserspuz: you're suring there's nothing wrong in the file itself, some reference to "sub/dir"?
15:58dnolenrhickey: so that instead of multiple deftype with an interface plus method implementations?
15:58dnolenI suppose I'm confused by the fact you can provide method implementations in deftype and other ways.
15:58chouseryes, try to ignore deftype method definitions
15:59spuzchouser: yes, but perhaps my cwd is not the same as the path I launched clojure from...
15:59dnolenchouser: as in that's not something that should generally be done?
15:59chouserdnolen: they're just there to confuse you (and to solve interop issues)
15:59rhickeydnolen: methods and protocol functions are completely different things, it's easiest to learn about the latter if you ignore the former
15:59dnolenchouser: it definitely worked :)
15:59spuzchouser: eh, actually, it's working now, no idea why it wasn't earlier...
16:01dnolenrhickey: so deftype with fields + protocols is the better way to think about things.
16:01rhickeydnolen: that's the pure protocol way, yes
16:01AWizzArdNice video of Guy Steele, talking about functional programming and parallelism: http://vimeo.com/6624203
16:02AWizzArdfits well to rhickeys talk about time management, which was recently uploaded
16:02hiredmangah, I still don't understand how github can be so broken with firefox
16:02dnolenrhickey: chouser: thx much for the clarifications. I think I'm beginning to understand.
16:07fyuryuanyone got the clojur-maven-plugin + clojure:swank goal working on Windows?
16:51qedhttp://pastie.org/private/cxw8cedwaate4y4lmj7y8a
16:52qedwhat's wrong with this picture?
16:54hiredmanno docstring?
16:54qedhehe, is there anything wrong with the general form of it?
16:54qed(step n) returns n/2 if its even , and 3n+1 if odd
16:55lenstit never halts
16:55qedim trying to make a vector starting at n = let's say 100, and have it conj onto the vector for each step
16:55hiredmanqed: I imagine it loops forever because you never change n
16:55qedoh rigt
16:55qedright*
16:57_mstand even then you've only gone from "will never halt" to "might never halt" ;)
16:57ohpauleezhaha
16:57qedlol
16:57hiredman_mst: :)
16:57qednevermind
17:20johnmn3hello
17:21johnmn3I was reading the tutorial at riddel.us. I was wondering if there are tutorials for using the new branch
17:22duncanmla la la
17:23Chousukejohnmn3: I don't think there are tutorials but the assembla wiki pages contain the current documentation :P
17:24johnmn3yea, I've been checking that out.
17:24johnmn3I'm sure people are running the new branch on emacs.. are there any caveats?
17:24johnmn3or is it as simple as replacing the jar?
17:26arohner_johnmn3: I had to rebuild clojure-contrib and swank to get things to work on the new branch
17:26Chousukeyou may need to recompile contrib/swank/whatever
17:27johnmn3hmm. ok. There's a new build of contrib on the build site.
17:27johnmn3which, I believe was said to be compatible with new
17:34stuartsierrajohnmn3: you still have to rebuild contrib/swank with the new branch of clojure for it all to work, I think
17:35KirinDaveHey folks. is there a concurrency guide for clojure?
17:35KirinDaveLike if I wanted to segment a task (say fetching urls) into groups and threading them out
17:35KirinDaveis that just a job for agents?
17:36johnmn3stuartsierra: ok. Thanks.
17:36the-kennyKirinDave: I've managed to do this with a ThreadPool from java for the processing and an agent for collecting the results.
17:36KirinDavethe-kenny: Yeah I could use the underlying java threading primitives
17:36hiredman,(doc pmap)
17:36clojurebot"([f coll] [f coll & colls]); Like map, except f is applied in parallel. Semi-lazy in that the parallel computation stays ahead of the consumption, but doesn't realize the entire result unless required. Only useful for computationally intensive functions where the time of f dominates the coordination overhead."
17:36AWizzArdContrib json module says: (json-str {200 [1 2 3], 401 [0 0 8]}) ==> "{\"200\":[1,2,3],\"401\":[0,0,8]}" - is this really allowed? Aren't {} objects in JS and need named fields as their keys?
17:37hiredmanAWizzArd: looks valid to me
17:37KirinDavehiredman: How do I know how "wide" that operation is going to be? Do I have any way of knowing or controlling that?
17:38AWizzArdhiredman: oki
17:38KirinDaveLike I could imagine for a width N operation saying (partition N (map agent urls-to-fetch))
17:38KirinDaveand then sending to all of them.
17:38KirinDaveBut then I wouldn't really know how many underlying threads are in the threadpool that agent purports to use.
17:38hiredman:(
17:39hiredmanKirinDave: depends
17:40KirinDavehiredman: Please do go on :)
17:40AWizzArdhiredman: yes, you are right, the rfc says it's ok
17:40hiredmanif you send via send the agent's action is run on a threadpool bounded by 1 or 2 plus the number of cores
17:40KirinDaveOh so it is based of the number of cores?
17:40hiredmanif you use send-off the threadpool is unbounded
17:40KirinDaveSo I can assume the number is going to be reasonable?
17:40hiredmanKirinDave: just use pmap
17:41hiredmanseriously
17:41KirinDaveSo pmap and then force?
17:41hiredmanor not, as you please
17:41KirinDaveWell, if the job is fetching URLs :)
17:42KirinDaveI've gotta confess this is so murky to me. I've been spoiled by erlang's fire-and-forget concurrency.
17:42technomancypmap will attempt to stay ahead of the consumer IIRC
17:42hiredmanKirinDave: pmap is fire and forget
17:42KirinDavetechnomancy: So it claims in the documentation.
17:42KirinDavehiredman: That's cool and I didn't know about pmap, so thank you.
17:43KirinDavehiredman: But if I wanted to say, ensure at most 4 simultaneous connections?
17:43hiredmanah
17:43hiredmanwell
17:43technomancyunslot your extra cores from the die
17:43KirinDaveLol
17:43hiredmanyou can use agents
17:44hiredmanI guess you could use them in the manner you suggested
17:44KirinDaveIs it frowned upon?
17:44hiredmanI am more partial to something like (cycle (take 4 (repeatedly #(agent nil))))
17:44technomancyKirinDave: you could make a version of pmap that accepts a concurrency-count as an argument; it's a simple enough function to just copy
17:44KirinDaveI've seen examples where people just go (map agent (range 5))
17:45KirinDaveTo do stuff like that.
17:45hiredmanwell
17:45hiredmanyou know, why not make an agetn per url
17:45hiredmanagent
17:45hiredman(like your example did)
17:45KirinDave(take 4 ...), wait on them
17:45KirinDaveand then continue?
17:45hiredmanI mean, agents are already backed by threadpools
17:46hiredmanKirinDave: nah, do it the wya you were doing it
17:46KirinDave(map agent (partition width urls-to-fetch))
17:46KirinDaveOkay
17:47KirinDaveWould it be unreasonable to desire that you could link agents to a specific threadpool
17:47KirinDaveIf you wanted to make a more dynamic behavior change in flight?
17:49hiredman(map fetch (map agent urls))
17:50AWizzArdá propos map.. (dotimes [i 100000000] (inc %)) takes one second to run on my system. (def x (map #(do (dotimes [i 100000000] (inc %)) %) (range 10))) immediately returns, as expected. But why does (time (nth x 2)) take 10 seconds, and not only 3? And when I then want to print x in the repl it returns immediately. I would thought that only then all 10 runs be done.
17:50AWizzArd"would thought" ==> "would think"
17:52AWizzArdWhen I replace map with pmap then it also immediately returns, but i see how my both cores are burning for around 5 seconds. Seems that pmap very much stays ahead.
17:52AWizzArdstrange
17:53hiredman(dotimes [i 100000000] (inc %)) doesn't actually run
17:53AWizzArdyes, it was i instead of %
17:53AWizzArdbut in the map i replaced the i with the % so that i can use the #() reader macro vs. (fn [_] ...)
18:00AWizzArdhiredman: can you reproduce that? I don't understand it so far :-)
18:03krumholt_,(let [+ -] (+ 1 1))
18:03clojurebot0
18:03krumholt_,(binding [+ -] (+ 1 1))
18:03clojurebot2
18:03hiredmankrumholt_: + is inlined
18:03krumholt_can someone explain the difference?
18:04hiredmanAWizzArd: try (def x (map #(do (dotimes [i 100000000] (inc %)) (println %) %) (range 10))) with nth
18:05krumholt_hiredman, so the compiler optimizes the call to + ? in binding but not in let ?
18:05Chousukekrumholt_: the thing is, in the binding form the + refers to the var #'+, but in the let form it's just a local
18:06krumholt_ah ok thanks
18:06Chousukekrumholt_: and because the compiler inlines + for two arguments, the binding fails to work.
18:06krumholt_i get it thanks a lot
18:06Chousuke,(binding [+ -] (+ 1 2 3)); no inlining
18:06clojurebot-4
18:06krumholt_bad compiler :)
18:07Chousukethe clojure compiler has next to no smarts
18:07Chousukewell, besides "big" optimisations I guess.
18:07hiredman,(nth (map pr (range 10)) 2)
18:07clojurebot0123456789
18:07Chousukebut any details are left to the JVM.
18:07hiredmanthat is rather tourbling
18:08hiredmantroubling
18:08duncanmhiredman: yeah, that's no good
18:08ChousukeI think that's because range is chunked
18:08AWizzArdhiredman: yes, it printed all
18:09duncanmhiredman: on my machine, running Clojure 1.0, i get user> (nth (map pr (range 10)) 2)
18:09hiredmanI see
18:09duncanm012nil
18:09hiredmanduncanm: yes
18:09Chousuke,(nth (map pr (range 64)) 2)
18:09clojurebot012345678910111213141516171819202122232425262728293031
18:09Chousukenote, first 32 items only :)
18:09Chousuke(the size of the chunk)
18:10hiredmanChousuke: still troubling for people expect map to be lazy
18:10hiredmanexpecting
18:10AWizzArdi didn't know that
18:10Chousukemoral of the story: laziness is not a guarantee, and you should keep it away from side-effects
18:10AWizzArdi thought that map is indeed very lazy
18:10hiredmanChousuke: what?
18:11ChousukeAWizzArd: it depends on the data structure.
18:11hiredmanmore like someone changed the semantics of map
18:11Chousukehiredman: it hasn't changed.
18:11hiredmanChousuke: not directly
18:11Chousukehiredman: there was never a guarantee that it only evaluates things one-by-one :)
18:11hiredmanChousuke: bull
18:12Chousukehiredman: where does it say that in the docs?
18:12Chousukeit only specifies a lazy seq.
18:12AWizzArdi would think that i tried this in the past and did not see this behaviour
18:12ChousukeAWizzArd: it's an optimisation
18:12ChousukeAWizzArd: for example, it makes no sense to map things one-by-one over a vector.
18:12hiredmanChousuke: no it isn't
18:12Chousukeyes it is.
18:12hiredmanit changes the semantics of the code
18:13AWizzArdbut is this new behaviour?
18:13Chousukehiredman: no it doesn't, if it's purely functional :)
18:13hiredmanChousuke: so?
18:13ChousukeAWizzArd: it's existed since chunked sequences.
18:13hiredmanclojure has never been purely functional
18:13Chousukehiredman: you're not supposed to use lazy sequences for side-effects :P
18:13hiredmanit means you might end up running more computations then you want to
18:14hiredmaneven if you are purely functional
18:14AWizzArdi think lazyness is the optimization... *not* doing stuff
18:14Chousukewhich is an optimisation in some cases.
18:14Chousukefor example. reducing or mapping over a vector is much faster thanks to chunking.
18:14AWizzArdif my f in (map f coll) is expensive, say, 20 minutes runtime, then I am happy if I only need to calculate 3 and not 19
18:14hiredman(nth (map some-calculation (range 10)) i)
18:15hiredmanwhere some-calculation is a pure function and i is a number determined somehow
18:15Chousukeyes.
18:15hiredmansuddenly your code is slower because it is doing more
18:15Chousukeit'll calculate all 10
18:15arohner_hiredman: it could be worse. In scheme, they don't even specify that map evaluates in order
18:15arohner_:-)
18:15Chousukethat very probably won't matter.
18:15AWizzArdwould be nice to have a lmap, which really is lazy
18:16michaeljaakaHi
18:16AWizzArdand plmap
18:16michaeljaakaI'm tring to run my app
18:16michaeljaakaI have some functions in clj
18:16Chousuke,(nth (map pr (seq (range 10))) 2)
18:16arohner_AWizzArd: you mean, guarantees one-at-a-time evaluation?
18:16clojurebot0123456789
18:16Chousukehmm
18:16michaeljaakaand I want to call one of them to start
18:16AWizzArdarohner_: yes
18:16michaeljaakajava -cp MyClojureProject.jar:lib/clojure-1.0.0.jar:lib/clojure-contrib-1.0.0.jar:lib/DistributedCommunication.jar:lib/JRuceCommons.jar clojure.main -e "(require 'com.yourcompany.receiver)(com.yourcompany.receiver/runr)"
18:16michaeljaakaError occurred during initialization of VM
18:16michaeljaakajava.lang.Error: Properties init: Could not determine current working directory.
18:16michaeljaaka at java.lang.System.initProperties(Native Method)
18:16michaeljaaka at java.lang.System.initializeSystemClass(System.java:1087)
18:16arohner_AWizzArd: how do you tell the difference?
18:16AWizzArdfor plmap it would be okay to stay ahead of the consumer, but it does not necessarily mean to be eager
18:16Chousukehiredman: but seriously, this thing *is* an optimisation. you can ask rhickey :)
18:16michaeljaakawhat is wrong with that?
18:17hiredmanChousuke: I understand that chunked seqs are supposed to be an optimization
18:17hiredmanmichaeljaaka: what is wrong is a failure to use a pastebin
18:17AWizzArdarohner_: the difference is that for a f with a runtime of 20 minutes (second (map f (range 19))) would not run 40 minutes, but over 6 hours
18:17hiredmanChousuke: but this completely alters the behaviour of map
18:18michaeljaakapastebin?
18:18Chousukehiredman: behaviour which was never specified :P
18:18Chousukehiredman: so it's fine to alter.
18:18hiredman~google pastebin
18:18clojurebotFirst, out of 151000 results is:
18:18clojurebotpastebin - collaborative debugging tool
18:18clojurebothttp://pastebin.com/
18:18michaeljaakaok
18:18hiredmanChousuke: it's not fine
18:18ChousukeAWizzArd: in weird cases like those you'd ensure the seq is not chunked.
18:19hiredmanwhen people have programs that rely on the old behaviour that break
18:19Chousukehiredman: sure it is. at least in this case.
18:19Chousukehiredman: what happens is that some silly programs may become a bit slower.
18:19Chousukehiredman: while most get a lot faster.
18:19hiredman
18:19_atomichaeljaaka: might be a filesystem permissions problem. what directory are you running it from?
18:19michaeljaakahttp://pastebin.com/m656eaf9f
18:20michaeljaakaI'm running it from my home directory
18:20Chousukehiredman: the thing is, supporting the old behaviour would require not having chunked seqs.
18:20AWizzArdi think a new map construct could be used to work as map currently does, while the old map would automatically ensure that its colls are not chunks then
18:20Chousukehiredman: that's not an okay tradeoff :)
18:20_atohmm odd then
18:20_atomichaeljaaka: does the clojure repl work if you run it without all the other jars?
18:20hiredmanChousuke: not for people who relied on the lazy behaviour of map
18:21michaeljaakayes
18:21michaeljaakait works too
18:21hiredmanmap is no longer lazy then
18:21Chousukeit is
18:21Chousukejust less lazy than it was before.
18:21Chousukefor SOME seqs.
18:21_atomichaeljaaka: I guess one of those jars is messing up java's system properties then
18:21michaeljaakabecause the first jar has meta-info ith set classpath to all others jars in libs
18:21AWizzArd,(chunked-seq? (range 10))
18:21clojurebotfalse
18:21Chousukehmm. that should be true.
18:21hiredmanthe whole move to the lazier branch was to avoid this kind of non-lazy behaviour
18:22Chousuke(nth (map pr (iterate inc 1)) 2)
18:22Chousuke,(nth (map pr (iterate inc 1)) 2)
18:22clojurebot123
18:22Chousukehiredman: but sometimes laziness is less performant.
18:22michaeljaakahmmm I will try to make dummy example project to see if it works
18:23AWizzArd,(chunked-seq? (iterate inc 10))
18:23clojurebotfalse
18:23hiredmanChousuke: sure, but this negates http://clojure.org/lazier
18:23Chousukehiredman: negates? how?
18:23notallamaso i have 4 functions that work on fns, and they work fine. i get all sorts of errors if i instead define a protocall with those 4 functions, and extend IFn with the same bodies. am i doing it wrong, or is it broken? http://paste.lisp.org/display/90530
18:24Chousukehiredman: full laziness is still possible.
18:24Chousukehiredman: but for some seqs, map is not fully lazy because it makes no sense.
18:24hiredmanChousuke: why doesn't it make sense?
18:25AWizzArdi also have to admit that i find this unexpected...
18:25Chousukehiredman: either because the data is already there. or the overhead of laziness is too high.
18:26hiredmanChousuke: sure, the data is already there for the range, but not the map
18:26michaeljaakahmmm, It works for dummy project ;(
18:26Chousukehiredman: yes, but that really doesn't matter.
18:26hiredmanit does!
18:27AWizzArdChousuke: so, how do i make (first (map #(pr % ",") (range 100))) really lazy?
18:27Chousukehiredman: if your operation is so expensive you can't afford to computer it ahead by at most 32 items, you should use pmap or some other model altogether :P
18:27Chousukecompute*
18:27Chousukeat most 31, even.
18:28AWizzArdChousuke: but even pmap will let my 32 core machine burn on all cores for 20 minutes then
18:28AWizzArdi just wanted the first 2 elements, and only knew this at runtime
18:28Chousukean easy way to unchunk a seq is to concat an empty list to it
18:28hiredman
18:29AWizzArdthis won't work for (range 10) tho, as this isn't even a chunked seq..
18:29Chousukebut seriously, any concerns you are having are purely theoretical
18:29hiredman,(nth (rest (concat () (map pr (range 10)))) 2)
18:29clojurebot0123456789
18:29hiredman:|
18:29michaeljaaka_ato: I know what it was
18:29AWizzArdso, how can this be really lazy?
18:30hiredmanChousuke: any assurances you've given have been purely theoretical
18:30Chousukehiredman: has anyone actually been bit by this?
18:30michaeljaaka_ato: I'm using enclojure, I rebuilded the project and the Terminal has just lost the dist directory because it was deleted by netbeans
18:30Chousukehiredman: this has been the default behaviour for who knows for how long already :P
18:30hiredmanChousuke: AWizzArd just was
18:30AWizzArdperhaps some more people were hit and just didn't find out yet
18:30michaeljaaka_ato: the new one was created but terminal had still old reference
18:30_atomichaeljaaka: ah right. :)
18:31michaeljaaka_ato: solution, exit and enter again
18:31hiredmanit means I have to reexamine everything
18:31AWizzArdChousuke: I didn't notice it for quite a long time and was totally convinced that it will really be lazy
18:31michaeljaaka_ato: thanks anyway!
18:31AWizzArdwith pmap okay, this will consume a bit more
18:31AWizzArdbut map is fully lazy - i thought
18:31hiredmanclojurebot's input fuzzer takes a long time to run, perhaps somewhere something is returning a lazy seq
18:31hiredmaner
18:31hiredmana chunked seq
18:32hiredmanso it is doing more work than it needs to
18:32AWizzArdwould be great if i could count on the lazyness, even if that reduces the runtime speed in some cases
18:33AWizzArdand, if there is a way to make map guaranteed work lazy, then map could ensure that it will always work like this, and we simply get a new-map
18:33AWizzArd(def new-map map) ... (defn map .. really lazy ...)
18:34Chousukeeither way, I don't see this as a big enough problem to be worth fixing :P
18:35AWizzArdso, do you have then a way how to make map work guaranteed lazy?
18:35ChousukeI thought the concat trick worked but hmm
18:35dreishJust use the pre-chunks implementation.
18:36AWizzArd,(set-mode map :pre-chunked)
18:36clojurebotjava.lang.Exception: Unable to resolve symbol: set-mode in this context
18:36Chousuke,(nth (map pr [1 2 3 4]) 2)
18:36clojurebot1234
18:36Chousuke,(nth (map pr (concat () [1 2 3 4])) 2)
18:36clojurebot1234
18:36Chousukehmm. :/
18:37AWizzArdso, map is mostly eager, but can in some cases be lazy
18:37Chousukeit's not mostly eager
18:37Chousukeit's mostly lazy, but can in some cases be eager :)
18:38hiredmanand you will never know when it will do which
18:38Chousukethe eager cases so far are vectors, maps, sets and ranges
18:38Chousukebecause those are "eager" data structures. except for range I guess.
18:38hiredmanChousuke: but the result is not eager!
18:38hiredmanor should not be
18:38AWizzArd,(first (filter (comp #(= % 3) pr) (range 100)))
18:38clojurebot0123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
18:39AWizzArd*sigh*
18:39hiredmanI might know all the values in a vector
18:39hiredmanbut that doesn't mean I want them eagerly mapped!
18:39Chousukehiredman: but in the overwhelming majority of cases that doesn't matter :/
18:39Chousukeit's not fully eager either. only 32 items at once.
18:39_atoAWizzArd: err... that pr returns nil causing the filter to run through the whole range
18:40AWizzArd,(first (filter #(do (pr %) (= % 3)) (range 100)))
18:40clojurebot3
18:40clojurebot012345678910111213141516171819202122232425262728293031
18:41AWizzArdChousuke: so what would be bad about having it fully lazy then?
18:41AWizzArdif people care about performance then there is always pmap
18:41ChousukeAWizzArd: it would not be as performant due to the overhead.
18:42dreishpmap isn't generally faster.
18:42ChousukeAWizzArd: pmap is even less performant.
18:42AWizzArdif f is not something like + then pmap will be more performant
18:42dreishAWizzArd: Really, just git checkout 14316ae2110a or whatever, look at the source of map at the time, call it map1, and go on with your life.
18:42dreishIt's really not that big a deal.
18:42AWizzArdbut if f is so cheap, why then care about pure lazyness?
18:42ChousukeAWizzArd: yes. and chunked seqs are more performant if the f IS +
18:43hiredmanAWizzArd: I think the issue is when f is not cheap
18:43ChousukeAWizzArd: laziness has a per-item overhead. chunked laziness cuts that overhead down to 1/32
18:43AWizzArdif f is not cheap then pmap is great
18:43AWizzArdif f is cheap it's still fast enough when map is fully lazy
18:43Chousukeno it's not if f is really cheap :)
18:43Chousukeif you're mapping lots of cheap operation the laziness overhead accumulates really quickly.
18:44hiredmanbut pmap still does extra work
18:44Chousukeoperations*
18:44hiredmanChousuke: then lets make some strict versions of the sequence functions
18:44AWizzArdand what about this vmap or whatever it is called in the PAR branch?
18:44hiredmaninstead of this hybrid nonsense
18:45ChousukeAWizzArd: that automatically parallelises itself, taking advantage of a vector's underlying structure. it's fully strict.
18:45Chousukehiredman: but that wouldn't be nice at all :)
18:45AWizzArdChousuke: so, map can be fully lazy, and those people who want to map + can use vmap?
18:45ChousukeAWizzArd: but chunked map is not eager.
18:46ChousukeAWizzArd: it's still lazy. only 32 times less than the fully lazy one.
18:46Chousukein SOME cases.
18:47hiredmanChousuke: it would be nicer than suddenly realizing that map is doing 32 times more work than you thought it was
18:47dreishAWizzArd: I think people want to use map the way it is.
18:47dreishHere's the old one: http://github.com/richhickey/clojure/blob/a9cb831fe714966e225a5297ef844513fe4a373a/src/clj/clojure/core.clj
18:47AWizzArddreish: I am not sure, I think most people would like map to be lazy.
18:47dreishIt is lazy.
18:47Chousukehiredman: except due to laziness overhead, doing "32 times the work" will in many cases be cheaper than being fully lazy.
18:48dreishWe've really got to stop doing this.
18:48_atoheh, it's a pity some magic can't measure the time the first element takes and if it's expensive compared to laziness overhead decide to not eagerly do the rest. But the timing would probably be expensive itself
18:48AWizzArdmap could be lazy again, and on the homepage one could have a link to git, so that people who want the chunked map can check it out, name it map1 and be happy with it.
18:48hiredmanChousuke: but not all the cases, and there is no way to tell
18:49Chousukeif those 32 items are killing your performace you can mod your algorithm suitably :P
18:49Chousukeeveryone else can just enjoy a faster map
18:49Chousukeand reduce.
18:49AWizzArdand this is not possible if map would be fully lazy?
18:49ChousukeAWizzArd: no, because laziness has overhead.
18:49AWizzArdmodifying the algorithm?
18:49AWizzArdi see
18:50hiredmanChousuke: or you can have a map and a map*, and depending if you want a lazy map or not you can pick
18:50AWizzArdwhy then stick with 32?
18:50Chousukethe purpose of the chunking optimisations was to allow people to use map even for cheap operations, where normal laziness overhead would kill performance and you'd have to write a loop.
18:50AWizzArdmaybe map can do 65536 chunks in one step?
18:50ChousukeAWizzArd: because vectors are internally chunks of 32 items and it's a good number.
18:50AWizzArdwhy 32 and not 1, or 2 or 64 or 768?
18:51Chousukeas I said above: vectors :P
18:51Chousukeand I guess other clojure data structures too
18:52hiredmanclojurebot: map?
18:52clojurebotmap is *LAZY*
18:52Chousukethey're internally chunked and processing them a chunk at a time is a *lot* faster than thunking each item to achieve full laziness.
18:52hiredmanclojurebot: forget map is *LAZY*
18:52Chousukethat will have to be fixed I guess :)
18:52clojurebotI forgot map is *LAZY*
18:52AWizzArd:(
18:52Chousukeclojurebot: map is lazy
18:52clojurebot'Sea, mhuise.
18:52dreishAWizzArd: Seriously, are you having an actual problem with this, or just "if my f were expensive"?
18:52hiredmanclojurebot: forget map is lazy
18:52clojurebotI forgot map is lazy
18:53hiredmanclojurebot: map is <reply>map and the other sequence functions used to be lazy, but with the advent of chunked sequences, may or may not be lazy, consult your local ouija board
18:53clojurebotIk begrijp
18:53AWizzArddreish: I worry because I don't know if I have an actual problem with it.
18:54dreishAWizzArd: Well, that's a difficult problem to solve.
18:54dreishIt's a lot easier to solve an actual problem in actual code than it is to solve the problem of being dissatisfied that rhickey chose one thing and not the other.
18:55dreishBut as I keep pointing out, the old code is still out there, and still fine. You could defn map1 and use it in your projects.
18:55dreishMaybe it should be part of the core, or contrib at least. I don't know.
18:55Chousuke2009-05-25 16:17 "rhickey: reduce+filter+map - 4x faster chunked" :P
18:55Chousukethat's when they were still in their own branch
18:55rhickey_I someone having an actual problem with map?
18:55hiredmanChousuke: I bet they would be even "faster" if we removed all laziness
18:55rhickey_is?
18:56hiredmanso lets do that
18:56AWizzArd2009-11-17 00:55 "AWizzArd: reduce+filter+map - 32x less lazy" :P
18:56dreishAWizzArd: How are you to know that non-chunked map wouldn't cause you actual performance problems? It most likely would, and those would be the more subtle ones because they would involve lots of little cases scattered all over the place instead of an expensive fn that would stick out in profiling.
18:56Chousukehiredman: you can use a loop
18:56AWizzArddreish: yes, can probably be solved somehow, it is just a new source of uncertainity
18:56hiredmanChousuke: you can use a loop, since you are willing to give up laziness
18:56dreishAWizzArd: Well, get out there and write some code and find out!
18:57rhickey_hiredman: no they wouldn't. The overhead for laziness was less than 10%, now 1/32 of that. You are unlikely to see any benefit and will find a ton of costs as you recalculate things or fully realize intermediate results
18:57AWizzArddreish: i have a big enough code base
18:57dreishSo why not profile it then?
18:57dreishOr benchmark it? Try it with chunks, and then without.
18:57AWizzArddreish: how to try it without chunks?
18:58rhickey_map on a non-chunked seq is non-chunked
18:58rhickey_i.e. same as always
18:58dreishI'm sure there's a more elegant way, but I would copy and paste the relevant functions in core from the URL above.
18:58notallamaprotocols are supposed to be the same as multimethod dispatch with (fn [a & as] (class a)) as the dispatch function, yes?
18:58AWizzArd,(chunked-seq? (range 10))
18:58clojurebotfalse
18:58hiredmanrhickey_: sure, but now (nth x 2) maps f over the 0 to the 31st thing, instead of just 0 to 2
18:58rhickey_notallama: no, they don't use the hierarchy system
18:59_ato,(chunked-seq? (seq (range 10)))
18:59clojurebottrue
18:59dreishrhickey_: Is there an easy way to convert a chunked seq to a non-chunked seq? Something like (unchunk s)?
18:59rhickey_hiredman: there may be a need for a seq-1 which will dribble even chunked seqs as non-chunked when that matters
18:59AWizzArd,(first (map pr (range 100)))
18:59rhickey_so, I am looking for use cases
18:59clojurebot012345678910111213141516171819202122232425262728293031
18:59AWizzArd,(first (map pr (seq (range 100))))
18:59clojurebot012345678910111213141516171819202122232425262728293031
18:59rhickey_not theoretical problems
18:59AWizzArd_ato: didn't help :(
19:00dreishSo far it's just vague worries, not even theoretical problems.
19:00dreishBut I would think there might be cases where a well-placed seq-1 could help.
19:00rhickey_In thinking about this, I came to the conclusion that all we need is a seq1
19:00AWizzArdit's scary that something that you thought is guaranteed lazy suddenly isn't
19:00rhickey_anything following it would be non-chunked
19:01dreishAWizzArd: Why is that scary if you're writing function programs/
19:01dreishfunctional
19:02hiredmanfunctional or not, it still burns cpu to run a pure function
19:02dreishAnd it burns CPU to cons atom by atom instead of chunk by chunk.
19:02dreishProve that one is better than the other.
19:02AWizzArdwell, with pmap i would expect this to happen, to some extent
19:03rhickey_yes, the main argument for laziness is to avoid fully realizing intermediate results
19:04rhickey_since the infrastructure of all lazy fns is still the same, its simply a matter of feeding then non-chunked seqs when you care - they are still fully lazy in that case
19:04hiredmandreish: sure, just map fib over a range, suddenly it takes a whole lot longer to complete
19:04AWizzArdrhickey_: it seems that (range 10) is not chunked
19:04AWizzArd,(chunked-seq? (range 10))
19:04clojurebotfalse
19:04ChousukeI guess a seq1 function would really solve this neatly. you could get full laziness when you really do care about it.
19:04rhickey_ah, fib, so, we are not talking about real programs ...
19:04dreishhiredman: So few of my programs involve mapping fib, though.
19:04ChousukeAWizzArd: the reason is it's not a seq :)
19:04hiredmanrhickey_: pardon me
19:05hiredmanrhickey_: dreish asked for proof that one is better than the other
19:05ChousukeAWizzArd: as _ato pointed above.
19:05dreishIn the GENERAL case.
19:05hiredmanfib just happens to be an easy proof
19:05rhickey_I really do care about this, and would like to hear peoples real experiences with chunked seqs
19:05AWizzArdChousuke: but *both* (range 10) and (seq (range 10)) let map behave in the same way, see above.
19:05ChousukeAWizzArd: because map calls seq
19:05dreishhiredman: As in, point to a big, real application and show how it performs with and without chunks.
19:05michaeljaaka_ato: how to get output from println, right now when I run scripts as standalone apps I can only get ouput via logger
19:06AWizzArddreish: if this is not easy, how can one then know that the current implementation is better?
19:06hiredmandreish: do you have such proof?
19:06hiredmanI have tons of calls to map everywhere
19:06dreishNo, I don't, I just think it's absurd to burn up this much time yakking about it.
19:06dreishIf it's a real problem, show why it is.
19:06_atomichaeljaaka: err... println should just be going to stdout in a script unless you've redirected it
19:06AWizzArdWould it not take some full analyzes of real apps to see if the current map performs better?
19:06hiredmanso do I have to hunt down ever call to see if there are chunked-seqs anywhere?
19:07dreishThis is driving me nuts. I'm getting dinner.
19:07Chousukehiredman: if we get this seq1 function you'd just need to add those to places where you really care about full laziness.
19:07hiredmanChousuke: sure
19:07Chousukehiredman: which won't be most uses of map :P
19:08rhickey_hiredman: as I said, if after trying with chunked seqs you have problems, bring them up and we'll work out solutions
19:08michaeljaakahmmm, when I type in script (println "Hello World") I can see it on output
19:09michaeljaakabut when I do that in a callback method of proxy object
19:09rhickey_chunked seqs have been in master for a while, and I haven't gotten any complaints
19:09Chousukethough seq1 looks ugly ;/ seq* would be neater, but I guess the 1 is kind of hinting at its purpose.
19:09michaeljaakaI can't see any output
19:10_atomichaeljaaka: strange. how about with (.println System/out "hello") in your callback?
19:10AWizzArdrhickey_: it is just that some people (like me) expect filter and map to be fully lazy. When doing Genetic Programming one could try to find the first f for which a good fitness value is found. Those f's could be running for days each.
19:11AWizzArdIf now someone is convinced that filter will stop immediately as soon a certain fitness value is met will wonder why is program was runing several many hours (or weeks).
19:11AWizzArdNow that I am aware about that I would not use find-first anymore
19:11rhickey_AWizzArd: I understand the theoretical argument
19:11AWizzArdit is totally practical
19:12AWizzArdonly by accident i stumbled upon this
19:12rhickey_only if you have no way to control that
19:12michaeljaaka_ato: nothing is showing
19:12michaeljaaka_ato: dorun helped
19:12AWizzArdnow i will use loop instead, but if i didn't find this out tonight I would probably have used find-first
19:12michaeljaaka_ato: dorun ( println "Hello there")
19:13_atomichaeljaaka: huh... I don't know what would cause that :/
19:13rhickey_AWizzArd: but switching your structure is completely unnecessary. filter and find-first are fully lazy when given a non-chunked seq, so all you need are the tools to give them one
19:13AWizzArdyes
19:14qedi think im getting dumber by the day -- i cannot figure out how to use loop... (loop [n (+ n 1)]
19:14notallamamy stuff works with regular functions and multimethods, but not protocols. (extending clojure.lang.AFn). as far as i can tell, it should be the same, but i'm getting "Wrong number of args passed to: arrow$eval--114$fn--147$G--103".
19:14_atoqed: you need to use recur with loop
19:15_atoqed: something like (loop [n n] (recur (inc n)))
19:16AWizzArdrhickey_: it seems that map is making some non-chunked seqs chunked.
19:16rhickey_AWizzArd: it can't do that
19:17qed_ato: yeah, i have my clojure book out, ill figure it out, but thanks
19:17AWizzArd[10 20 30] is a non-chunked seq
19:17AWizzArd,(first (map pr [10 20 30])) ; will print 10
19:17hiredmanthat is a vector
19:17clojurebot102030
19:17hiredmannot a seq
19:17hiredmanand vectors produce chunked seqs, I believe
19:17_ato,(chunked-seq? (seq [10 20 30]))
19:17clojurebottrue
19:18_ato,(seq? [1 2 3])
19:18clojurebotfalse
19:18_atoa vector is seqable (it can be turned into a seq) it's not a seq itself
19:18AWizzArdwell, then my understanding of chunked-seq? is wrong
19:19AWizzArdso, how do i make a seq (but non-chunked) out of a vector?
19:20rhickey_AWizzArd: that's what seq1 would be for
19:20AWizzArdok, i understand
19:20qed(defn step-seq [result n] (if (= n 1) 1 (recur (conj result n) (step n)))) -- im trying to make (step n) the new value that the loop takes as it's input
19:22_atoqed: that code works for me if I define step as 'dec' and call with say n = 10
19:22_atoqed: what's the problem?
19:23qedwont dec just decrement 10..9..8..7, etc? I want to call a function on the new value of step n, every time i go through the loop
19:24_ato(defn step-seq [result n] (if (= n 1) 1 (recur (conj result (f n)) (step n)))) ?
19:24_atowhere f is that function
19:24_ato?
19:24_atoor you want to do it to the result of step n, in which case just let-bind the result of (step n)
19:29qed_ato: I just get 1 as my return
19:29qedsomething seems broken..
19:30_atooh right
19:30_atothat's because if returns 1
19:30_atonot results
19:30qedahhhh
19:31qedsweet -- thanks _ato
19:38lisppaste8rhickey pasted "seq1" at http://paste.lisp.org/display/90536
19:42dnolenrhickey: this example brings up another question, so it's now possible to write something analogous Java classes using pure Clojure (i.e. the more confusing bits about deftype & protocols :) ?
19:42dnolenanalogous to
19:43rhickey_deftype can do a particular subset of things - deriving and defining the methods of interfaces
19:43rhickey_it can't derive from classes, can't define members not in the interfaces
19:44rhickey_if that subset works for you (and it should in most non-interop scenarios), then use deftype, otherwise there is still gen-class
19:44dnolenrhickey_: ah, I got burned by that. Tried to derive from an interface and I had some of my own dummy fields.
19:47rhickey_you get fields a b c from (deftype Foo [a b c])
19:56qed(defn count-and-track [result n] (loop [cnt n size (count (step-seq [] n))] (if (= n 1) result (recur (conj result size) (dec cnt)))))
19:57michaeljaakahi
19:57michaeljaakaI have (fn[o] (. o message "Hello") )
19:57michaeljaakawchich returns function
19:57michaeljaakaNow I want the same with #() macro
19:57michaeljaaka(#(println %1 "Hello"))
19:57michaeljaakadoesn't work because it want to be evaluated
19:58michaeljaakaI want a reference to that function just like with fn[o] had
19:58michaeljaaka(fn[o] println o "Hello" )
19:58michaeljaakashould be
19:58michaeljaakabut what about # ?
19:59dnolen,(do #(println "Hello"))
19:59clojurebot#<sandbox$eval__3860$fn__3862 sandbox$eval__3860$fn__3862@2a9403>
19:59dnolenmichaeljaaka: just remove the surrounding parens
20:00michaeljaakadnolen: thanks!!! :)
20:00dnolennp
20:01arohner_sigh. really:
20:01arohner_ * Implements a fast vector class without synchronized
20:01arohner_ * methods. Replaces java.util.Vector. (Synchronized methods tend to
20:01arohner_ * be slow.)
20:01arohner_from the WEKA source
20:04qedbest way to find the maximum value in an array?
20:04maravillas(ArrayList?)
20:04qederr sorry
20:04qeda vector
20:05arohner_qed: I wrote a little utility function to do it
20:05arohner_using reduce
20:06qedhmmm, how would you do that?
20:06arohner_lisppaste8: url
20:06lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
20:06lisppaste8arohner pasted "untitled" at http://paste.lisp.org/display/90537
20:07tomojif it's just numbers
20:07tomoj,(reduce max [1 2 3 4 5])
20:07clojurebot5
20:07qedoh man, im getting dumber and dumber as the day goes on
20:08arohner_wow that's a lot prettier
20:08arohner_find-max is some of my earliest clojure
20:09tomoj(apply max ..) works too but is slower, I wonder why
20:09Chousukehm
20:09arohner_tomoj: apply is usually slower than the alternative
20:09tomojyeah, but why?
20:09tomojthe &more fn for max just reduces on the rest
20:10arohner_~def apply
20:10arohner_you have an extra var deref + a copy of the arguments
20:11Chousuke,(let [a (vec (range 100000))] (time apply max a))
20:11clojurebotjava.lang.RuntimeException: java.lang.IllegalArgumentException: Wrong number of args passed to: core$time
20:11Chousuke...
20:11Chousuke,(let [a (vec (range 100000))] (time (apply max a))=
20:11clojurebotEOF while reading
20:11Chousuke,(let [a (vec (range 100000))] (time (apply max a)))
20:11clojurebot99999
20:11clojurebot"Elapsed time: 109.589 msecs"
20:11Chousuke,(let [a (vec (range 100000))] (time (reduce max a)))
20:11clojurebot99999
20:11clojurebot"Elapsed time: 11.49 msecs"
20:12Chousuke,(let [a (vec (range 100000))] (time (apply max a))) ; wonder if that was a fluke
20:12clojurebot99999
20:12clojurebot"Elapsed time: 9.841 msecs"
20:12arohner_hah, we're warming up clojurebot's JVM
20:12tomojit's consistently slower for me on (range 1000000)
20:13Chousuke,(let [a (list* (range 100000))] (time (apply max a))); hum
20:13clojurebot99999
20:13clojurebot"Elapsed time: 22.222 msecs"
20:13Chousuke,(let [a (list* (range 100000))] (time (apply reduce a)))
20:13clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$reduce
20:13Chousuke...
20:13Chousuke,(let [a (list* (range 100000))] (time (reduce max a)))
20:13clojurebot99999
20:13clojurebot"Elapsed time: 34.151 msecs"
20:14tomoj~def spread
20:14Chousukein any case, reducing over a vector should be faster than over a list
20:14arohner_on my box, they each take about 3 ms, with the reduce version about .1 ms faster on average
20:14ChousukeI guess the size is too small :P
20:15tomojapply spreads the rest of the arg which looks linear
20:15arohner_Chousuke: why should reducing over a vector be faster?
20:15michaeljaakahi
20:16michaeljaakahttp://pastebin.com/d6d2f2670
20:16michaeljaakaI want to define something like this
20:16michaeljaakabut I get
20:16michaeljaakahttp://pastebin.com/d4a04b69a
20:17Chousukearohner_: it's chunked. :)
20:17arohner_Chousuke: ah, right
20:17arohner_I was thinking in complexity, not implementation
20:18Chousukehm, this is problematic :(
20:19ngocHi, where can I look for information about meta programming in Clojure? For example, how to list all functions inside a namespace?
20:19ChousukeI can't even construct a list of million items in my repl without running out of heap
20:19Chousukebuilding a vector is okay though.
20:19_atongoc: have a look at: http://richhickey.github.com/clojure-contrib/ns-utils-api.html
20:20michaeljaakahow to make that iface is visible in whole function body
20:20_atongoc: as well as: http://clojure.org/namespaces
20:21Chousukemichaeljaaka: you should use a bit more spaces :P
20:21Chousukemichaeljaaka: anyway, the iface argument passed to proxy is not evaluated
20:22Chousukeie. it's just a symbol
20:22Chousukein short: you can't do that. You need a macro :)
20:22michaeljaakaugh
20:22arohner_michaeljaaka: you can write a macro that will do that though
20:22ngocThanks, is there a function to convert x_y_z.clj to x-y-z?
20:22qedwhy doesnt max-key work on a {}?
20:23Chousukein general if you define new named things you should use a macro.
20:24_ato,(apply max-key key {1 :a, 3 :b, 2 :c})
20:24clojurebot[3 :b]
20:24Chousuke(defmacro receiver [name iface mapping] `(new EchoReceiver ~name (init-proxy (proxy [~iface] []) ~mapping))) should do. though I can't quite tell what use an empty proxy is.
20:24_atooh you mean on an empty map?
20:24qedwhat goes is max-key if you have to tell it how large the largest key should be?
20:24qednevermind
20:27ngocI mean is there a function to convert a file name "x_y_z.clj" to a namespace name "x-y-z"?
20:29qedwow my code is ugly
20:30qedit's a good thing project euler stipulates the "if it takes less than 1 minute it's an okay solution"
20:30qedbecause otherwise id fail
20:31_atongoc: not as far as I know, but it's easy to do youself, just replace _ with - and chop off te .clj
20:32arohner_well obviously there's one somewhere, because the compiler uses it
20:32_atooh and change / to .
20:32arohner_whether it's accessible to users is a different question
20:35arohner_ngoc: I would grep through the src
20:35arohner_try looking for the error clojure throws when the file doesn't match the namespace
20:35_ato,(clojure.lang.RT/munge "a-b-c!")
20:35clojurebotjava.lang.IllegalArgumentException: No matching method: munge
20:36_ato,(clojure.lang.Compiler/munge "a-b-c!")
20:36clojurebot"a_b_c_BANG_"
20:36_atohmm
20:37dnolenerg *** slime
20:37arohner_aha!
20:37arohner_~def root-resource
20:38arohner_currently marked private, but at least you can copy it
20:39_ato,(@#'clojure.core/root-resource 'baz.foo-bar)
20:39clojurebot"/baz/foo_bar"
20:40qedCould someone take a look at my code and see if they can optimize it? http://devinwalters.com/posts/21
20:40qedmy result runs very slow
20:40_atoI think ngic wanted the other way around, but yeah, it is just replace _ with - and / with .
20:40_atos/ngic/ngoc/
20:41rlbAny suggestions regarding the best "clojure" way to handle input from /dev/input/event? with a timeout? I can already read the events via a DataInputStream, but I'd like to abstract it as a stream of events where you can ask for the next event with a timeout. I could probably work something out with send-off and await-for...
20:42arohner_rlb: you could make a lazy seq, or use futures
20:42arohner_,(doc future)
20:42clojurebot"([& body]); Takes a body of expressions and yields a future object that will invoke the body in another thread, and will cache the result and return it on all subsequent calls to deref/@. If the computation has not yet finished, calls to deref/@ will block."
20:42rlbarohner_: will that work with a hardware blocking call?
20:42_atorlb: if I remember correctly java's IO library is broken, you can't use read with a timeout on a file, you have to poll :(
20:42rlbi.e. (.read stream) may block indefinitely.
20:42_atoit's really annoying
20:42arohner_oh,wow
20:42arohner_was not aware of that
20:42rlbarohner_: I was assuming that via send-off I could just let a thread handle getting the next event.
20:43michaeljaaka,(doc let)
20:43clojurebot"([bindings & body]); Evaluates the exprs in a lexical context in which the symbols in the binding-forms are bound to their respective init-exprs or parts therein."
20:43arohner_futures run in the background
20:43_atoyou can do it on sockets using nio selectors but I couldn't figure out a way to do it with files
20:43arohner_they use the agent pool
20:43Chousukeisn't that why they're working on NIO2 :/
20:43rlbarohner_: send-off doesn't use the pool, right?
20:43arohner_that sounds right, but I'm not 100% certain
20:44rlb(though I may do that differently -- I'm not that keen on launching a thread for each event -- may just have a thread that fills a queue...)
20:44rlbAnyway, just wanted to make sure there wasn't something obvious I was overlooking.
20:45rlb(This is just a toy anyway -- managing a powermate, and looking for double-clicks...
20:45rlb)
20:46arohner_rlb: IIRC, there's a java lib for interacting with unix somewhere
20:47arohner_hrm. looks like there's a bunch of them
20:47arohner_anyways, there are several libs out there for making java & posix play nicer
20:47ngoc_ato: thanks a lot
20:47arohner_that might help
20:51weissjanyone know how i can make an ordered map so that items stay in the order they're added?
20:52rhickey_weissj: Clojure doesn't come with a data structure with those properties
20:52chouserweissj: use a sorted-map and include a globally incrementing counter in the key?
20:53qedanyone here know if there's a plugin or something out there that will let me do easy clojure syntax hilighting in rails?
20:53chouserI guess finger trees ought to be able to do that.
20:54rhickey_chouser: that depends on the meaning of "stay in the order they're added"
20:54weissjwhat are finger trees
20:55chouserweissj: they don't exist.
20:55weissji'm not too concerned about keys that are added more than once going to the end of the list vs staying in place
20:55michaeljaakahi, I have another challange
20:55michaeljaakaI have http://pastebin.com/d1e94de3c
20:55michaeljaakaI want to modify code so use would look like this
20:56funkenblatti guess in a functional language, the idea of "order of insertion" isn't supposed to matter
20:56michaeljaakahttp://pastebin.com/d4d1f7a3c
20:56michaeljaakaI know that there is a memfn
20:56weissjchouser: java has LinkedHashMap, is there any way to make that the backing store for a map?
20:56jensliweissj, maybe you could create a java LinkedHashMap,
20:57michaeljaakawhich do what I want but don't know exactly how to use it
20:57jensliOh, you alleady knew about that one.
20:58weissjyeah, that's sort of what i'm trying to reproduce here. i have a map of tests to test results, i want the order the tests are run to be preserved
20:58weissjthere's lots of ways to do this, but i'm trying to stick with built-in stuff as much as possible
20:58srader what about array-map?
20:59weissj,(doc array-map)
20:59clojurebot"([] [& keyvals]); Constructs an array-map."
20:59weissjnot very helpful doc :)
21:00rhickey_http://clojure.org/data_structures describes ArrayMaps
21:02weissjrhickey_ ok I suppose what i'm using is a "very small map", probably never more than a few hundred items. linear lookup is probably not going to be noticably slow
21:03weissjor maybe i'll just put a counter in the key :)
21:08michaeljaakawhat is wrong with that?
21:08michaeljaaka(import 'java.util.HashMap)
21:08michaeljaaka(def a (memfn put ))
21:08michaeljaaka(a (java.util.HashMap.) "32")
21:11rhickey_(def a (memfn put k v))
21:11michaeljaakaok, that is HashMap, thanks
21:11_ato,(macroexpand-1 '(memfn put k v))
21:11clojurebot(clojure.core/fn [target__5709__auto__ k v] (. target__5709__auto__ (put k v)))
21:12rhickey_#(.put ht k v) more idiomatic than memfn
21:12rhickey_memfn predates #()
21:14weissjhow does one create a comparator to use with sorted-map-by? proxy?
21:15weissjor is it just a plain ol function? i am not sure if it's wanting a java Comparator or what
21:15chouserweissj: just return a positive, negative, or zero
21:15chouserplain ol clojure fns are Comparators. :-)
21:16weissjchouser: oh, never occurred tome
21:16weissji guess they might as well be.
21:16chouser,(instance? java.util.Comparator #())
21:16clojurebottrue
21:17weissja fn that doesn't take 2 argsdoesnt' seem like a comparator, but why not eh
21:17chouserweissj: yeah, not very useful.
21:17_ato,(.compare #() 1 2)
21:17clojurebotjava.lang.RuntimeException: java.lang.IllegalArgumentException: Wrong number of args passed to: sandbox$eval--3955$fn
21:18_ato,(.compare #(- %1 %2) 1 2)
21:18clojurebot-1
21:18_atohm :)
21:26michaeljaakaany idea how to fix that macro ? http://pastebin.com/d6be08903
21:30_atoput parens around dorun
21:30_atoactually.. wait.. what's the dorun even for?
21:31michaeljaakait can be skiped
21:31_atooh does EchoSender.message() return a lazyseq
21:32_atomichaeljaaka: what's the problem that needs fixing?
21:32_atooh I ssee
21:32michaeljaakathis '(message "Hello World") must be expandend in macro to (. o message "Hello World")
21:33_atoyou need to move some tildes
21:33_atohang on a tick
21:36_atomichaeljaaka: http://gist.github.com/236571
21:36_atolet me know if you don't see why that worked
21:39michaeljaaka_ato: works great!!!
21:39michaeljaaka_ato: thanks a lot! exactly that I needed
21:40michaeljaaka_ato: these macros are very powerful
21:41michaeljaaka_ato: I see why it works
21:41michaeljaaka_ato: you may only explain why quote for (message "Hello") is not needed
21:41_atoah
21:42_atobecause arguments to macros aren't evaluated, so they don't need to be quoted
21:42michaeljaakaok :)
21:42michaeljaakaand what about @ what that mean?
21:43michaeljaaka&args in macrodef and in its body i can see ~@args
21:43_atoah, ~@ is different to @
21:43_ato~@ means splicing unquote
21:43clojurebotGabh mo leithscéal?
21:43_atoso
21:44_atosuppose v is [1 2 3]
21:44_atothen `(foo ~v) => (foo [1 2 3])
21:44_atowhile `(foo ~@v) => (foo 1 2 3)
21:44michaeljaakaI see
21:44michaeljaakasuper
21:44michaeljaaka:D
21:45michaeljaakaok, for today it is enough, thanks again everyone!
21:45_atoso yeah you could do: (. o# ~@ufun) instead of (. o# ~(first ufun) ~(second ufun))
21:46michaeljaakaI'm using IRC, google groups for the first time to learn new things, and your community is answome
21:47_ato:)
21:47michaeljaaka_ato: will it work even for method with many arguments?
21:48michaeljaakaI know that instead of second ther eshould be rest
21:50_atoshould do
21:50_atoshould expand to (. o f a b c)
21:52michaeljaakaok, thanks again and bye!
21:53qedI have some slowwww code I'd like to improve. Would anyone mind taking a look at : http://pastie.org/private/k530tmjmfozxvarkzriehw and possibly giving me some suggestions?
21:53qedRight now it runs in about 30sec, but that seems really meh, to me -- without changing my approach completely, how could I improve performance?
21:58arohner_qed: you could use transients
21:58qedarohner_: wuzzat?
21:58arohner_http://clojure.org/transients
21:58arohner_nm, maps aren't supported yet
21:59chouser,(transient {})
21:59clojurebot#<TransientArrayMap clojure.lang.PersistentArrayMap$TransientArrayMap@1d0fe80>
21:59qedah, interesting
21:59arohner_oh that's right, cgrand fixed them
21:59arohner_well then, the docs are out of date
21:59arohner_:-)
22:01qedhow does clojure.org do its syntax hilighting?
22:01qedim looking for a good way to do syntax hilighting in rails
22:01arohner_where do you see syntax highlighting on clojure.org?
22:01qedcgrand's code is be-ay-yootiful
22:01chouserclojure.org uses javascript something
22:02qedarohner_: on the transient page you linked?
22:02arohner_huh, I don't
22:02qednot even under example?
22:02qedreally?
22:02qedwhat browser are you using?
22:02arohner_chrome on OSX
22:02arohner_though it says the page has been loading since I linked it
22:02qedhm weird
22:02qedim using safari
22:02arohner_chrome and my internet connection are flaky sometimes
22:03qedmaybe ill just write up a clojure theme for one of the existing hilighting enginers
22:03qedengines
22:33arohner_is there existing support for making a seq out of a java.util.Enumeration?
22:33chouser(doc enumeration-seq)
22:33clojurebot"([e]); Returns a seq on a java.util.Enumeration"
22:33arohner_chouser: thanks!
22:37qedi have some big list of integers, and i have an integer that may or may not be in the list
22:37qedwhat is the fastest way to find out if the integer i have in my hand is inside the list?
22:37arohner_,(some #{3} [1 2 3 4 5])
22:37clojurebot3
22:37qedarohner_: nice! thanks man
22:37arohner_,(some #{10} [1 2 3 4 5])
22:37clojurebotnil
22:38qedthat works on lists and vectors and maps?
22:38qedor just lists and vectors?
22:38ohpauleezYou can also use .contains
22:38ohpauleezsome will return the first true value it finds
22:38ohpauleez(just asked this today!)
22:38qed:)
22:39ohpauleezcontains? will work on keys and indexes
22:39arohner_chouser: do you know why seq supports iterable, but not enumeration?
22:39ohpauleez(contains? [1 2 3 4 5] 5) => false
22:39ohpauleez(some #{5} [1 2 3 4 5]) => 5
22:40chouserarohner_: I'd have to dig a bit -- I believe seq used to support enumaration but that there was some kind of issue with it, so it was backed off to a separate function.
22:40leafwarohner_: enumeration? as in java.util.Enumeration? That is an outdated iterator type with poor semantics.
22:40arohner_leafw: yes, I'm aware it sucks. I'm forced to use it for inter-op :-(
22:41leafwarohner_: old libs ...
22:41arohner_WEKA still uses it in current versions
22:41leafwI've been using weka recently
22:41leafwit's quite bizarre, wehn it comes to write java classes that use its internals.
22:42leafwlots of statics and stateful procedural constructs.
22:42arohner_yeah, It's not fun
22:42leafwI isolated the damage in a single class file.
22:42leafwbest luck :)
22:43arohner_thanks :-)
23:03qedwow
23:04qedi think i actually learned some clojure today
23:04qedlol -- it took me quite a while to understand that whole loop/recur form for different situations
23:05qedkind of embaressing really
23:05ohpauleezbut once you get it, it makes total sense
23:05ohpauleezcongrats on the progress
23:06qedthanks man -- it's a good community we have here
23:06qedlots of eager minds
23:06ohpauleezI started working on project to port some of SQLAlchemy's features over to a new project build on contrib.sql and clj-crud
23:06qedcool!
23:07ohpauleezbuilt**
23:07qedi haven't 100% decided on what i'd like to build in clojure
23:07qedonce there is support for protocols, i was thinking about building sort of a collaborative coding platform
23:08technomancyqed: the Emacs implementation for Google Wave uses Clojure on the server-side
23:08qedthink Github meets irc, meets pair programming in a shared buffer
23:08qedtechnomancy: damn you technomancy !
23:08technomancymwahaaha
23:08qedalways one step ahead of me phil
23:08technomancywell it's not finished yet
23:08technomancystill a chance to help out! =)
23:09ohpauleezhaha, that's awesome
23:09qedtechnomancy: i know you have the basics going on there, but do you see what i was driving at?
23:09ohpauleezThe other project I had was to create some sort of sandbox
23:09qedlike you login to github, and you can edit code, in real time, with other committers, on the spot
23:10technomancyqed: so a shared buffer but with controls exposed for committing; viewing history, etc?
23:10ohpauleezqed: screen + emacs?
23:10qedohpauleez: yeah like that, technomancy yes
23:10technomancyI've been thinking of adding that kind of functionality to rudel: http://rudel.sf.net
23:10qedjust imagine pair programming in irc, like as a fixture of irc
23:10ohpauleezrock
23:11technomancyqed: that's a big problem though; making an editor that isn't painfully restricted is a huge task in and of itself without even considering the server-side
23:11qedlike i have my irc window up right now, but what if my drawer was a context-based text buffer, that showed people coding while i was talking in irc
23:11qedtechnomancy: yeah, no doubt
23:11qedit's still a great idea though
23:12technomancythere is textjure, but I have no idea how complete that is or even if it would be any good as a general-purpose editor
23:12qedrudel really has me psyched to do some coding with other people -- i was it wasnt so formal though
23:12qedit'd be nice to just drop in on some project, and say "hi, im just going to watch, and might consider adding a few lines"
23:12technomancythat's a very interesting idea
23:12technomancyfrom a social angle
23:12qedyeah, i feel like it would really facilitate the development of some projects
23:12technomancya collaborative-by-default project.
23:12qedlike "hey dude, im hanging out over in "some obscure repo" right now"
23:13qed"if you wanan talk, come over and code a little bit"
23:13qedwe all basically do it already
23:13qedpeople using pastie left and right
23:14qedexplaining concepts to eachother, sharing ideas
23:14qedone of the most annoying parts of reading other people's code is that you weren't there, but you could conceivably sit down and watch a project from the sidelines, and know how it all fits together"
23:15qed</rant>
23:15technomancyyou could set up a headless Emacs session with Rudel to subscribe to all buffers on a server and auto-save and auto-commit on an interval to get a persistent session going on.
23:15arohner_qed: I suspect you wouldn't get that from watching rhickey code
23:16arohner_honestly, I suspect part of the reason clojure has terrible error messages is that rhickey makes so few mistakes he doesn't notice them
23:16technomancyhah! that explains everything.
23:17qedthe real reason the error messages are so bad is that they
23:17qedthey're actually a cruel joke about error messages
23:18_atoI like it, would be interesting
23:18qedi didnt want to finish that thought, but when you accidentally hit enter, you're screwed
23:18qed_ato: i checked out technomancy's rudel the other night, and then you got me on ethaedit, and i really felt like i got way more out of that
23:19qedthan just sitting in irc reading contextually isolated lines of information
23:19qedyou learn faster in that environment
23:21djorkI have found the horrible stack traces and errors to be pretty easy to cope with after a little time
23:21djorknull reference my eye
23:22qedalso, when you think about it, one major problem with irc is that you cannot easily discern many people's lines at once, so there is all of this hate for "flooding", like > 3 lines and you're "flooding"
23:22qedall that does is make people less apt to praticipate, or if they do, they go through pastie, which is contextually separate from the discussion, which is a totally uneeded context switch
23:22qedim rambling, aren't i?
23:23_atohehe, frankly if Clojure's error messages just said "You suck!" with a line number they'd work about as effectively as they do now a lot of the time.. maybe even more so as you wouldn't have to go hunting through the nested exceptions to find the line number that actually matters :p
23:23technomancyqed: I feel that way whenever I use an IRC client that doesn't color nicknames
23:24qedi use uncolored nicknames in irssi :X
23:24technomancy_ato: maybe that will be an option in swank-clojure 2.0 =)
23:24leafwclj contrib had a nice error reporting system, but I can't find anymore. It removed all the non-relevant parts of the stack trace and formated the rest nicely.
23:35jkkrameri'm attempting to use clojure-mode's M-x swank-clojure-project and when it asks me for the project root, it doesn't do anything when i press return. this is in Aquamacs. M-x slime works fine. any ideas?
23:35_atojkkramer: do you have all the jars you need (including clojure.jar) in project/lib ?
23:35jkkrameri should say, when i press return, it actually prints a newline rather than doing anything
23:36jkkrameryes
23:36jkkramerthe slime repl works as expected
23:37_atoI dunno then :/
23:37_atoanything in the *Messages* buffer?
23:38technomancyjkkramer: known bug with an older version; try updating
23:39jkkrameri thought i did, to 1.6...hmm
23:39qedhow do you get the fancy slime startup?
23:39technomancyor enabling ido-mode; even better
23:39jkkrameroh, do i need to rerun clojure-install?
23:39technomancyjkkramer: the best way to install is through elpa: http://tromey.com/elpa/install.html
23:40qedah yes, (setq slime-startup-animation on)
23:45slyrusjkkramer: bah. you shouldn't need some fancy auto-installer just to get slime up and running. but you do need to be aware that swank-clojure doesn't work with slime's HEAD.
23:45DraggorI have a file with a bunch of declare statements, yet when I load later files that would use vars/functions that are declared, clojure claims they are unbound. Why is that?
23:45DraggorThey're all in the same package
23:45Draggorerr, namespace
23:45jkkrameri installed clojure-mode 1.5 through elpa a while back. i tried to upgrade to 1.6 but now i think my setup is fubar'd. is there an easy way to clear clojure stuff out and start fresh?
23:46technomancydon't resist elpa; it's going to be part of emacs 24
23:46technomancyjkkramer: just -rm -rf .emacs.d/elpa/clojure*
23:46slyrusjust because it will be part of it doesn't mean I have to use it...
23:47technomancyok, but I don't have to support you then. =)
23:48slyrusfair enough. but when something is legitimately (huh?) broken don't say "use the elpa version" either and we'll have a deal.
23:48arohner_Draggor: circular loads?
23:48technomancydear
23:48technomancy*deal
23:49Draggorarohner_: nope, one clj file that loads the others
23:49technomancyI just can't merge the latest swank-clojure to master without breaking clojure-install since the latter works off master
23:49technomancylack of foresight
23:49hiredmanDraggor: declared how?
23:50lgasis there an equivalent of the partition function that will not drop any odd remaining values? e.g. (partition 2 [1 2 3]) returns ((1 2)) but I would like ((1 2) (3))?
23:50hiredmanlisppaste8: url?
23:50lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
23:50slyrustechnomancy: you lost me there. are you saying you have a swank-clojure that works with the current SLIME head?
23:50technomancyno, but it fixes the problem jkkramer saw
23:52Draggorhiredman: I have three declares with a list of names afterwards in a file
23:53jkkramerok, cleared out everything and reinstalled 1.6 clojure-mode and swank-clojure. still seeing the return printing when i do M-x swank-clojure-project
23:53jkkramerM-x slime works
23:53technomancyjkkramer: maybe turn on M-x ido-mode and see if the problem persists
23:53technomancyif it does it's something else that I haven't seen before
23:53hiredmanDraggor: and how are you using the declared names?
23:54Draggorhiredman: function calls and variables. (declare func1) in the declare file. Then in another, later loaded file I might have a form (func1 some-arg)
23:54jkkramerawesome, that worked. thanks!
23:54jkkramerwhat's ido-mode, btw?
23:54technomancyjkkramer: ido ist awesome
23:55technomancyit's like magic press-fewer-keys mode
23:55hiredmanDraggor: just (func1 some-arg)?
23:55hiredmanbecause that's not going to work
23:55jkkramersounds good
23:56technomancy"i[nteractively] do [things]"
23:56_atojkkramer: it does fuzzy searching on find-file and buffer switching and such
23:56technomancyhttp://www.vimeo.com/1013263
23:56hiredman(func1 some-arg) is going to try and get the function in the var named func1
23:57jkkramerthanks for your work on clojure-mode, technomancy. makes it easier for folks like me that want to focus on coding and less on messing with tools
23:57hiredmanand declare just creates an empty var, if I recall
23:57Draggorhiredman: Also trying to use it in a map: {"func1", func1}
23:57technomancyjkkramer: glad it's helpful.
23:57jkkramerwill check that vid out
23:58technomancyjkkramer: were you seeing RET-inserts-newline behaviour in elpa's version of swank-clojure? that's odd.
23:58hiredmanDraggor: unless you have the name inside a function body (the value of the var won't be looked up until you execute the function) then declare is not going to help you
23:58technomancyor was it just clojure-mode that you got from elpa?
23:58cataskathe vid is made by the author of Programming Clojure
23:59jkkramerafter clearing things out, i marked clojure-mode and swank-clojure for elpa installation
23:59Draggorhiredman: Ahh, so could I cheat and just have my map definition in a closure that gets executed upon load?
23:59technomancyjkkramer: I'm guessing an old version of swank-clojure may have stuck around; perhaps it was loading out of ~/src/swank-clojure?
23:59hiredmanDraggor: still not going to help, unless the things you are declare are actually defined before you execute the fn