#clojure logs

2010-06-10

00:39_rata_,(doc flatten)
00:39clojurebot"([x]); Takes any nested combination of sequential things (lists, vectors, etc.) and returns their contents as a single, flat sequence. (flatten nil) returns nil."
01:10tomojoh shit
01:11tomojswank-clojure 1.2 supports slime-who-calls?!
01:14_rata_tomoj, what's that?
01:15tomojtells you which other functions call a particular function
01:15tomojexcept it doesn't work for me
01:15tomojswank.util conditionally defines flatten depending on the clojure version
01:16tomojbut for some reason I get an unbound var there :(
01:17toast`does clojure have much in the way of a language spec?
01:17tomojhmm.. I guess it would depend on who compiled the swank-clojure snapshot, eh? this seems.. unfortunate
01:20toast`i guess the soon to be released book will act as one?
01:23_rata_tomoj, maybe that's the reason why I don't have flatten either
01:23tomojon 1.2 you should have it in clojure.core
01:25_rata_I don't have it, don't know why... niether on 1.2 nor on 1.1
01:25tomojmaybe you have an old 1.2?
01:25_rata_yes, that could be a reason
01:25tomoj,*clojure-version*
01:25clojurebot{:interim true, :major 1, :minor 2, :incremental 0, :qualifier "master"}
01:25tomoj,flatten
01:25clojurebot#<core$flatten__6406 clojure.core$flatten__6406@162477e>
01:26_rata_I'll try updating it
01:27_rata_user=> *clojure-version*
01:27_rata_{:interim true, :major 1, :minor 2, :incremental 0, :qualifier "master"}
01:27_rata_that's what my clojure says
01:29tomojbut 1.2.0 is a snapshot, so you may have an older snapshot
01:31_rata_yes... I got it late
01:41_rata_si there a function like filter that works on "trees"? I mean, is there a filter that once it finds a lists it applies itself over that list?
01:49Blackfoot_rata_: you could have a function that does different things based on the argument it gets
01:50_rata_ok, I know that... the question was if that function already existed in clojure or clojure.contrib
01:51Blackfootyea.. not sure about all of contrib, i haven't gone too deep in there
01:51Blackfoot'walk' might help
01:52Blackfoot,(doc walk)
01:52clojurebotPardon?
01:52Blackfootwell, http://richhickey.github.com/clojure/branch-1.1.x/clojure.walk-api.html in any case
01:52lancepantz_rata_: i don't know if it specifically exists, i would look at keywordize-keys which basically does that, but applying keyword
01:53_rata_thanks, Blackfoot :)
02:00_rata_,(walk identity #(filter (comp not nil?) %1) [[nil 1] [2 3]])
02:00clojurebotjava.lang.Exception: Unable to resolve symbol: walk in this context
02:01_rata_,(use 'clojure.walk)
02:01clojurebotnil
02:01_rata_,(walk identity #(filter (comp not nil?) %1) [[nil 1] [2 3]])
02:01clojurebot([nil 1] [2 3])
02:01_rata_mmmm ¬¬
02:01_rata_it seems that I didn't understand what walk does
02:08tomoj,(remove nil? [1 nil 2 3 false])
02:08clojurebot(1 2 3 false)
02:10_rata_yes, i need that but in nested seqs too :)
02:10_rata_,(remove nil? [1 [2 nil] 3])
02:10clojurebot(1 [2 nil] 3)
02:13tomojwas just commenting on (comp not nil?)
02:15_rata_ah ok :)
02:35Raynesdanlarkin: Damn. Is it that bad? :\
02:37danlarkinyes
02:39Raynesdanlarkin: I might have to do it just to enlighten myself. Like skydiving.
02:40danlarkinit's not the writing that's hard
02:41danlarkinor rather, it's the 20%
02:41danlarkinand living with your day 1 design decisions for years
02:43RaynesThat makes sense. Nobody is ever satisfied with build tools. Like I said though, it's just an idea for a boredom project. I'll just hide it from people. :>
02:43Blackfoot_rata_: any luck with walk?
02:47_rata_Blackfoot, no, I didn't try it anymore... I found a better way to get rid of nils in nested seqs
02:49Blackfootah ok, was it basically a recursive call?
02:50lancepantzRaynes: danlarkin: mind if i ask what you guys are discussing?
02:50Rayneslancepantz: I mentioned on Twitter that I might start a build tool and dependency manager project tonight just for fun, and because I'm bored.
02:51_rata_no... i stopped producing them
02:51Rayneslancepantz: danlarkin promptly warned against doing so, telling me it would be the worst mistake of my life. :P
02:51lancepantzhahaha, i jumped down that hole a week ago
02:51lancepantzme and a co-worker thought it would take a few days
02:51lancepantzwe've been working on it full time for about 2 weeks now
02:51_rata_Blackfoot, i could do a filter with another recursive call (it already has one by default), but it was easier to stop producing those nils
02:52Blackfoot_rata_: oh haha taken care of at the source
02:52_rata_yea :)
02:52lancepantz*err: 2.5 weeks now
03:23hoecklancepantz: and do you have something to show after those 2 weeks?
03:51_rata_is it possible to install swank-clojure 1.2 via ELPA?
03:52tomojdoesn't look like it's available yet
03:52tomojdo you not use lein or maven?
03:53_rata_no :(
03:54_rata_(is it ok to say "via ELPA" in english?)
03:54KirinDaveit is not a naughty thing to say
03:55bozhidar_rata_: you might have also used "from" :-)
03:56_rata_bozhidar, ok :) thanks
03:56tomoj'via' sounds fine to my ears
03:56bozhidarI'm very fond of
03:56bozhidar'via' myself
03:57bozhidarnot so fond of ELPA, however
03:57tomoj_rata_: don't want to bother with lein?
03:57_rata_bozhidar, hahahahaha
03:57bozhidara package management system without upgrade capabilities...
03:57tomojwhat are "upgrade capabilities"?
03:58bozhidartomoj: you cannot upgrade packages automatically the way you'd do it with yum or apt
03:58tomojyou mean like, "upgrade all installed to the latest available"?
03:59bozhidartomoj: this is one, the other is that you cannot actually upgrade anything
03:59bozhidaryou have to delete the old version and install the new
03:59bozhidarwhich is helpful to a very limited degree IMHO
04:00tomojI see
04:00_rata_tomoj, what's lein for?
04:00bozhidarI guess that when ELPA enters Emacs it will be improved a lot, but at this point
04:00tomojmuch easier than doing it manually, I think, though?
04:00bozhidar_rata_: a build system
04:00tomojlein also can launch swank servers for you
04:01bozhidarit has a target lein:swank that allows to start swank-clojure server
04:01tomojand if you do it that way, you don't even need swank-clojure in emacs
04:01bozhidarto which you can connect from slime
04:01Raynesbobo_: Since when do you have to delete an old version of something to install a new version.
04:01bozhidarI personally prefer to use swank-clojure + clojure-project
04:01bozhidarmost of the time
04:02Raynesbozhidar: And you're thinking of maven. All you have to do to start a swank server with Lein is add [swank-clojure "1.2.1"] to your dev-dependencies, do 'lein deps' and then 'lein swank'.
04:02RaynesI mean, the target bit didn't make any sense in the context of Leiningen. Not saying you didn't know the last bit. Should have been separated into two messages. :p
04:03bozhidarRaynes: I'm pretty sure I'm not thinking of Maven and I know how to use lein :-)
04:03RaynesAlso, didn't mean to ping bobo_. :<
04:03Raynesbozhidar: You said, and I quote "it has a target lein:swank that allows to start swank-clojure server"
04:03bozhidarI imagined so
04:03bobo_its ok, i didnt notice :-p
04:04RaynesI'm not sure that makes any sense in the context of leiningen. It has a plugin for starting a swank server. lein:swank looks mavenish.
04:04bozhidarRaynes: ops, that's a type I'd have to acknowledge - subconscious maven :-)
04:04Raynes:p
04:04bozhidarRaynes: as for ELPA - I'm pretty certain that you'll have to delete old version of packages
04:05bozhidarotherwise the old version will remain on the emacs load path
04:05Raynesbozhidar: I don't think so. I installed the new clojure-mode and slime about a week ago, and they're still sitting there. Emacs automatically used the newer versions.
04:05RaynesI mean, maybe in an other version or with other packages.
04:06Raynesolder*
04:06bozhidarhmm, when I updated slime it continued to use the old slime until I deleted it
04:06tomojpackage.el does seem to somewhat often not work
04:06tomojbut still, I like it
04:07_rata_mmmmm... but what if I don't want to start a project, but just play a bit with swank-clojure in emacs?
04:07Raynesbozhidar: Are you certain? technomany alerted me to a bug where slime warns you that the swank and slime versions are mismatched, when they actually aren't. He said deleting the elc file solves it.
04:07_rata_is lein useful for doing that?
04:08Raynes_rata_: Personally, I have an "experimentation" project for that that I can hop in whenever I want.
04:08bozhidarRaynes: it was some time ago, so my memory is a bit flimsy. I recall only how frustrated I was with ELPA...
04:08Raynesbozhidar: ELPA sucks pretty bad, I agree.
04:08_rata_mmmmm
04:09bozhidarI really hope someone will sit down and improve it before including it in Emacs by default
04:09bozhidarpackage management is a great concept and God knows Emacs needs it, but it must be implemented right
04:10tomojon osx I always run into very strange problems with package.el
04:11tomojfor example sometimes the installation itself will hang until I move the mouse
04:11RaynesOn OSX, you run into strange problems with * it seems.
04:11bozhidarmy favorite problem is the byte-compilation that almost never works
04:11Raynes:\
04:12bozhidaror the dependency resolution problems - sometimes deps come in just fine, other times - I have to mark every dep manually
04:12tomojyeah..
04:12_rata_I saw that when I installed swank-clojure 1.1 from ELPA, it installed three jar files in ~/.swank-clojure/
04:12tomojand then you wind up in weird states where something isn't installed but you also can't install it
04:13_rata_clojure*jar, clojure-contrib*jar and swank-clojure*jar
04:13bozhidar_rata_: clojure, clojure-contrib and swank
04:13bozhidarthat'
04:13bozhidars totally fine
04:13_rata_isn't there any way to the the same manually but with 1.2?
04:13esjMorning Everybody.
04:14_rata_where can I get the swank-clojure 1.2 jar?
04:14_rata_how can I tell emacs to use them without installing swank-clojure from ELPA?
04:14tomojI thought swank-clojure would download those jars itself after installation
04:15tomojif so it would make sense for swank-clojure 1.2 to install its jar as well
04:15tomojbut I don't know if that's really how it works
04:15_rata_but swank-clojure 1.2 is not in ELPA
04:15_rata_in fact, is it possible to use the system-wide clojure installation with swank-clojure?
04:15tomojwhat I am suggesting is to delete ~/.swank-clojure, install swank-clojure 1.2 manually, and then try using it
04:16tomojit should download the jars automatically
04:17tomojbut swank-clojure for emacs is obsolete, I think
04:17_rata_I've download swank-clojure's git, but there's no installation instructions
04:17tomojhttp://github.com/vu3rdd/swank-clojure-extra
04:17_rata_really?
04:18tomojI don't use that stuff so don't trust me too much
04:18tomojsee also http://groups.google.com/group/swank-clojure/browse_thread/thread/e6656cc66c5ac15f
04:19bozhidartomoj: swank-clojure is obsolete?
04:19bozhidarafter all slime for clojure depends on it :-)
04:20tomojnot swank-clojure, swank-clojure for emacs
04:20tomoji.e. swank-clojure.el
04:20cschreinerI always seem to pollute my namespace with definitions I don't want. How can I undefine a var from the repl?
04:21_rata_tomoj, ah ok... I read that in the git too
04:21bozhidartomoj: this seems unlikely to me, since in some point you have to bridge slime and clojure and you have to do it in Emacs Lisp...
04:21bozhidarat some point*
04:22_rata_bozhidar, not necessarily when you use slime-connect (IIRC)
04:22tomojI don't have swank-clojure installed in my emacs
04:23tomojyet I use slime for clojure
04:23tomojso, doesn't seem altogether unlikely to me
04:23tomoj,(doc ns-unmap)
04:23clojurebot"([ns sym]); Removes the mappings for the symbol from the namespace."
04:23tomojcschreiner: ^
04:23bozhidartomoj: I read the docs, you're right
04:24bozhidartomoj: it seems that swank-clojure.el simply provided the means to start swank-clojure from emacs
04:24cschreinertomoj: yeah, suspected that one, ty
04:32esjbozhidar: I'm not if this helps, but what I do to get a 1.2 repl in emacs is to run >lein swank for the the project directory to get a swank server, then in emacs >silme connect to get a repl
04:34_rata_the syntax highlighting in emacs is swank-clojure thing or a clojure-mode thing?
04:34tomojclojure-mode
04:34_rata_ok :)
04:43bozhidaresj: you probably meant to say _rata_ :-)
04:45esjbozhidar: apologies... that's what skim reading gets me
04:46bozhidaresj: np
04:57_rata_how can I know which swank-clojure I'm using?
04:59esj_rata_: why do you want to know that?
05:01esj_rata_: seriously, if what you want is Clojure 1.2, connected into emacs, my previous comment will get it for you.
05:01tomojonly with project overhead
05:03_rata_because I'd suppose that emacs doesn't have enough information to know where to find swank-clojure... plus I have two swank-clojure around and I don't know which one is using
05:03_rata_it's really not an important thing
05:03_rata_because I now have swank-clojure 1.2 :)
05:04_rata_and the flatten function :)
05:04_rata_it was just out of curiosity
05:04esjnice, enjoy !
05:05_rata_but I'm amazed at the way I could finally do it
05:05_rata_I was expecting it not to work
05:14brehauthmm. enlive could do with a defmultisnippet
05:15cgrandbrehaut: what would it do?
05:15brehautmashup of defsnippet and defmulti
05:16brehautit maybe that im too inexperienced to see how it would fit together
05:16brehautbut my attempts to use (snippet ...) as the rhs of a defmethod form all failed
05:16brehautand ive opted to define each snippet and then the method that applies them
05:18brehaut(i have a bunch of 'fragments' in a couchdb that i pull out. each has a :type that i switch on to work out how to render them)
05:23brehautcgrand: btw cheers for moustach and enlive. both are working out well for me
05:24cgrandbrehaut: http://gist.github.com/432752
05:25brehautcgrand: perfect :)
05:27cgrandbrehaut: you're welcome
05:47_rata_good bye guys :)
05:48_rata_thank you all
05:51LauJensenMorning all
05:51rrc7czgood morning
05:51lpetitMorning Lau
06:00esjHello Lau
06:14canderaAnyone know of any libraries for creating Swing UIs declaratively in Clojure?
06:15AWizzArdcandera: I know of a Clojure-Lib for creating Pivot applications. See http://github.com/hoeck/clj-pivot and for Pivot itself: http://pivot.apache.org/
06:17canderaAWizzArd: thanks. I'll check that out.
06:18Raynescandera: Licenser has written a sort of wrapper around Swing in Clojure. http://github.com/Licenser/clj-swing I believe
06:18kensanataYeah, apparently there's a form macro based on http://stuartsierra.com/2010/01/05/taming-the-gridbaglayout
06:19kensanataLicenser_: ping
06:19Licenserkensanata: pong
06:20canderaOK, cool. I remember seeing mention of that. Didn't know it had a home.
06:20Licenserit's incorporating it, not based on it :P
06:20kensanataHehe
06:21Licenserand there is stuff for text fields, trees, panels, combo boxes
06:22AWizzArdThough swing does not support data binding, and is unfortunately more ugly to code, and some nice other features are not available.
06:23Licenserwait clj-swing has data bindings, the trees, foends and combo boxes are all backed by cljure STM constructs as data bindings
06:24Licenserbut I think clj-pivot might be more compleat
06:27AWizzArdI am not sure if we mean the same thing by data binding. In Pivot terms it means that you can just say something like: (fill-form-fields my-map), and then all 12 fields in a form are filled. So, you don't need to write (do (.setText field1 (:name my-map)) (.setText field2 (:age my-map) ... (.setText field12 (:username my-map)))
06:28AWizzArdThough, it would be cool if you could add such a feature to clj-swing!
06:31AWizzArdAnd the other direction should also be supported. If you want to send a filled out form back to the server you only need to say in Pivot something like: (get-form-data the-form) ==> map-with-all-data
06:35LicenserAWizzArd: Swing is not the same as piviot, this sounds very webby
06:35Licenserswing is more interactive and less send stuff forth and back
06:36Licenseryou can certenly do something like that already just use a map of refs to represent data bindings
06:38AWizzArdWell, not so webby. Form data needs to be handled anyway to be useful. The target could be a text file or a database then.
06:42Licenseryes but the idea of sending data forth and back is kind of webby, opposite to just having it there
06:42Licenser
06:44esjcan somebody explain the reasoning behind what appears to be an inconsistency:
06:44esj,(subseq (sorted-set 4 5 6) > 7)
06:44clojurebotnil
06:44esj,(subseq (sorted-set 4 5 6) < 3)
06:44clojurebot()
06:44esjwhy nil in one case and empty set in the other ?
06:44AWizzArdLicenser: Just replace in my original statement that part with writing data from a db, or read it from there and put it into the form.
06:45AWizzArd,(doc subseq)
06:45clojurebot"([sc test key] [sc start-test start-key end-test end-key]); sc must be a sorted collection, test(s) one of <, <=, > or >=. Returns a seq of those entries with keys ek for which (test (.. sc comparator (compare ek key)) 0) is true"
06:45cemerickG0SUB: thanks for the happy msg on docuharvest :-)
06:46AWizzArdesj: the docstrings don't mention that subseq will return nil. It will always return a seq... in theory ;)
06:46rhickeyhas anyone tried the prim branch?
06:47AWizzArdWhat is special about it?
06:47rhickeyAWizzArd: it has static linking and primitive support in fns
06:48esjAWizzArd: OK, so its an 'undocumented feature'
06:48cemerickrhickey: I think an assembla page is needed for prim so people have an idea of what it's about
06:48AWizzArdrhickey: oh, that sounds good
06:48AWizzArdcemerick: yes, I didn't even notice that there is such a branch
06:48cemerick(benchmarks are a magnet for such things, too ;-))
06:48AWizzArdI only saw rhickey talking about :static and basically a day later he already said that he implemented it :)
06:49rhickeycemerick: Yes, have to make it first, then doc it. I'm wary of hype on it though
06:49cemerickAWizzArd: I knew about it, and looked at the code very briefly, but as much as I'm here, even I don't know the full story :-)
06:49cemerickrhickey: because it's thoroughly experimental, liable to be dropped, or just in flux?
06:49rhickeysome other useful things came out of the effort. I ran up against the max method size limit on the core init code, and added support for breaking up init into multiple methods
06:50rhickeycemerick: because I don't like hype
06:51cemerickoh, Rich. :-)
06:51cemerickrhickey: when I'm done here, I'll run your PR operation so you don't have to bother with it.
06:51cemerick;-)
06:51rhickeyheh
06:52rhickeyanyway, once the tea kicks in here I'll consider moving it into master
06:52rhickeythen I'll get feedback :)
06:52cemerickreally?
06:52cemerickI assumed this was post-1.2
06:54rhickeycemerick: It is an important complement to what's in 1.2. Right now I find I often am using definterface in order to get helper methods that take/return primitives for deftypes, there's no way to write factory functions to construct deftypes without boxing the ctor args, there are no knobs on direct linking. This work addresses all of that
06:55rhickeyI wouldn't want to wait 6 months or more for this, and back-to-back releases is a lot of non-productive work
06:57rhickey:static itself can be labelled experimental
06:57cemerickrhickey: I'm sure you're right, but there's tons of stuff that could be complimentary to stuff that's in 1.2.
06:57rhickeycemerick: like?
06:59cemerickI should have said "I'm sure there is tons of stuff...". The only thing off the top of my head is user-defined factory fns for defrecord, but by broader point is that more releases are better than fewer. I'm certain people wouldn't mind more frequent releases with fewer features / release.
06:59cemerickA regular cadence is also good for hype. ;-)
06:59TweyWhy is there this pattern I see in the docs of defining a bunch of arguments even when the last one ends with &rest?
06:59Twey,(doc partial) ; for example
06:59clojurebot"([f arg1] [f arg1 arg2] [f arg1 arg2 arg3] [f arg1 arg2 arg3 & more]); Takes a function f and fewer than the normal arguments to f, and returns a fn that takes a variable number of additional args. When called, the returned function calls f with args + additional args."
07:00TweyWhy isn't it just [f &args]?
07:00rhickeyTwey: performance
07:00TweyThe fixed ones are specialised somehow?
07:01rhickeythere is work involved in getting things out of the & seq that need not occur for args in hand
07:01TweyAh… hm, okay
07:01TweyCouldn't this be done behind the scenes somehow?
07:01rhickeyno
07:02rhickeythe body of [f arg1 arg2] uses arg1 and arg2 by name. Couldn't automatically create that code from just & args
07:04rhickeyyou might be able to write a macro to write such functions though. I haven't looked into that, but now that there are a few instances, one could look to automate it
07:05rhickeycemerick: keeping useful, already implemented features-to-be in master seems like a way to keep everyone on snapshots
07:06rhickeybut we are ready to pull the trigger on 1.2, you don't want primitive args?
07:06cemerickrhickey: the people who are willing to be on snapshots will *always* be on snapshots. The larger population isn't willing, and will only use releases.
07:07cemerickOh, I think *everyone* wants primitive args. I think there's a lot to be said for dropping a release now instead of adding significant changes that would need to percolate for....a few weeks, perhaps?
07:08rhickeycemerick: this release will have a true 'beta' period, as it already contains much not yet percolated
07:09cemerickeven more reason to not try to put a star on top of the already-laden tree then
07:09rhickeycemerick: then I should turn off current direct linking as that will not be the future, giving everyone a perf hit
07:10RaynesBut stars are pretty.
07:10cemerickrhickey: pulling that out when statics go in would be a breaking change?
07:10rhickeythe best way to help make this an informed decision is to try the prim branch
07:11rhickeycemerick: dunno, but I could either support issues around it (dead) or statics (future)
07:11cemerickkheh
07:12rhickeyplus, users can't actually use direct linking themselves, a huge loss. I know I want direct linking for my code
07:12cemerickfair enough, then.
07:13cemerickoh, I was never doubting the utility
07:13rhickeyright now we have tests for clojure and contrib, plus a suite called argos which contains several popular libs and their tests. All tests pass with prim
07:14cemerickgood to know
07:14cemerickwhere's this argos?
07:14rhickeyhttp://github.com/stuarthalloway/argos
07:14cemerickright, I knew about that :-/
07:15cemerickThen, ignoring primitives, I think everyone would like to see more frequent releases, as "non productive" as they are. ;-)
07:15cemerickJust moving the contrib stuff over could have constituted a release, IMO.
07:15cemerick(for example)
07:16rhickeyother neat things in this work - recognition of map (and soon vector/set) literals composed of literals, and avoiding evaluation of same
07:16rhickeycemerick: I wouldn't want to see releases of a language more frequent than every 6 months
07:17rhickeyfeature releases that is
07:17cemericknot sure what "feature releases" are
07:17rhickeyreleases that add features vs just fix bugs
07:17cemerickah
07:18cemerick6 months is a *long* time
07:18rhickeyto wait for new features in a language?
07:18rhickeyI disagree
07:19cemerickI think that might be appropriate for a "mature" language, where gotta-have-it features come up rarely
07:20rhickeyIf you gotta have it, there's git
07:23AWizzArdI was also thinking about this, and while a realese every 3 months does not leave too much room for improvements, it could be a target to have close to 2 releases per year.
07:34rrc7czare there any inspection fns for objects? I don't mean the inspector for a clj data structure, but I have an instance and I'd like to list its members and such
07:35AWizzArdrrc7cz: you can use JVM reflection.
07:36rrc7czAWizzArd: definitely, but I _really_ thought there was a clojure fn that did this
07:36AWizzArdrrc7cz: http://java.sun.com/javase/7/docs/api/java/lang/Class.html
07:36AWizzArd,(doc show)
07:36clojurebot"clojure.contrib.repl-utils/show;[[x] [x selector]]; With one arg prints all static and instance members of x or (class x). Each member is listed with a number which can be given as 'selector' to return the member object -- the REPL will print more details for that member. The selector also may be a string or regex, in which case only members whose names match 'selector' as a case-insensitive regex will be printed. Finally
07:36rrc7czthat's it!
07:36AWizzArdk
07:36rrc7czthanks
08:00rhickeyvector and set constants now in prim
08:01AWizzArdSo, those are really immutable?
08:01AWizzArdOr what does "constant" mean in this context?
08:12rhickeyAWizzArd: the evaluation model of literal vectors maps and sets in code is that their contents are evaluated, and a corresponding vectors/map/set created wit hthe result. This actually happens, even when the contents are themselves literals, meaning you always get the overhead of a ctor call at least. Now, if the contents are compile-time constants (e.g. 1, "fred", :ethel), so is the collection, no runtime cost
08:15tomoj"java.lang.IllegalArgumentException: Unable to resolve classname: ARef (inspector.clj:184)" weird
08:15tomojline 184 is in the middle of a comment
08:15rhickeye.g. in (let [a 1 b 2] [[a b] [1 2]]), the [a b] vector needs evaluation, the [1 2] vector doesn't
08:16AWizzArdrhickey: damn, you are good!
08:16AWizzArdI want that (:
08:16rhickeynot really, it should have always been this way
08:16rhickeyjust never got around to it
08:18AWizzArdNo really, that's great
08:19rrc7czhas anything changed in proxy/gen-class for allowing method overriding based on the type signature? The only method I know now is the Mark Triggs' fn name example -read-void, etc.
08:20rhickeyrrc7cz: genclass can have separate handlers for different type sigs
08:21rhickey-name-types
08:21rrc7czrhickey: okay, that's what I found in Mark's article
08:21tomojso after that last commit, with (defn foo [] [1 2 3]), (identical? (foo) (foo)) is true
08:21tomojnifty
08:22rrc7czrhickey: is there any reason why this isn't possible: (proxy [ASTVisitor] [] (visit [#^MethodDeclaration node] ...))
08:22rrc7czI mean, using the meta type hints to specify argument type?
08:22rhickeyproxies are name based
08:22rrc7czI mean in general, like any reason this wouldn't be a better option that embedding the type name in the fn name
08:23rhickeyso all with same name will flow to same function, but you could switch on the type there
08:23The-KennyI just asked myself the question what happens when there are two methods overloaded by argument-type.
08:24The-Kennylike void foo(int); foo(String)
08:24The-Kennywill proxy proxy both methods?
08:24rhickeyThe-Kenny: yes, all with same arity will go to the same place
08:24rhickeyname + arity
08:24rrc7czrhickey: I could, but then it requires writing a forwarding method for ASTVisitor, which has a ridiculous number of overrides :-) I'm mostly curious why you chose to embed the type name in the fn name instead of using the meta type hints
08:24The-Kennyrhickey: Ah, good. That's nice :)
08:26rhickeyrrc7cz: you are going to have to deal with the ridiculous number of overrides somewhere
08:27rrc7czrhickey: not when I only want to override one of them in my subclass, in this example a specific (visit [#^MethodDeclaration node]) versus forwarding on 30 others. I'm just trying to figure out why gen-class uses foo-Integer-String-Node [i s n] versus foo [#^Integer i #^String s #^Node n]
08:27rhickeyrrc7cz: to answer your question though, proxy has a tangible dispatch map. Keys differing only in metadata are not distinguishable
08:27rrc7czaha
08:28rrc7czbecause metadata is ignored during equality, right?
08:28rhickeyright
08:28rrc7czok
08:44cgrandrhickey: I'm sorry if I hyped prim
08:45rhickeycgrand: you never hype
08:45rhickey:)
08:45cgrandrhickey: on the "more constants" front, couldn't (long 42) and (double 3.14) be recognized as primitive constants?
08:46rhickeycgrand: the jit gets those calls there
08:46rhickeythey inline to static methods, always provided final arg...
08:47rhickeywhat I want to get rid of is (long 42)
08:48AWizzArdIn what way?
08:48cgrandah ok! And having 42L expands to (long 42) is a no go since it would be very surprising when writing macros...
08:48rhickeythat begs the semantic question of: should integer arithmetic auto-promote by default, or default to throw-on-overflow. The latter would unify Long and long behavior, so we could just write 42 in either context and get the same result
08:49rhickeymy preference is throw on overflow.
08:50rhickeyIt's probably the biggest thing I'd like to 'fix'
08:50rhickeybut definitely a breaking change
08:51rhickeyfor all those factorial demos :)
08:52cgrandyeah, I was going to ask if many production code relied on autopromotion
08:53rhickeythe problem is, when you talk about this, it becomes a theoretical debate rather than a practical one. IMO, auto-promotion is impractical on current hardware, and Lisp machines haven't caught on
08:55rhickeybut a single-character reader suffix for BigInteger *would* work, as arithmetic with them would be contagious (as with doubles)
08:55dnolenrhickey: did you see my bug report? #^ARef causing exception on prim branch?
08:55dnolen?
08:55rhickeyso just seed your factorial with 1B[ig] or whatever
08:56rhickeydnolen: no, where?
08:56rhickeywhat would the BigInteger suffix be?
08:56dnolenrhickey: http://groups.google.com/group/clojure/browse_thread/thread/82ca8e92b0461651
08:56rhickeyN?
08:56clojurebotcompilation is see compile
08:57cgrand,(class 1.4M)
08:57clojurebotjava.math.BigDecimal
08:57rhickeydnolen: is Aref imported?
08:57cgrandrhickey: there is already M
08:57rhickeycgrand: I suggested N
08:58cgrandoops I misread BigInt for BigDec
08:58rhickeyah
08:58rhickeydnolen: if not, you had a user-side bug before
08:58rhickeyalso, #^ is now ^
08:59dnolenrhickey: yes about #^. ah, ok, so that just wasn't throwing an error before. This is a swank-clojure bug that's biting me.
08:59_fogus_cgrand: There is an extra space in your final example --> ^{:static true :tag long : doc "docstring"}
09:00rhickeydnolen: hrm, swank-clojire is in argos, and tests pass there
09:00cgrand_fogus_: fixed, thanks
09:00_fogus_:)
09:02rhickeyso, any opinions on moving numeric semantics to throw-on-overflow by default, ask for BigInteger with contagious 1N constants (as well as bigint coercion op)
09:03rhickeymy feeling is contagion is the key. As with doubles, once you are in that space you stay there, without worry about every component of the calculation
09:03cgrandwhat about ratios?
09:04rhickeyare already ratios of bigints
09:04rhickeywould normalize to bigint I guess
09:05rhickey42/2 = 21N
09:05rhickeybigints would always print with N
09:09rhickeyyou'd never get bad numbers, and if you get the overflow exception you forehead-slap and add an N somewhere
09:11AWizzArdrhickey: can we detect where the N was forgotten?
09:12_fogus_I think that sounds fine. It's more work WRT the book, but what can you do? ;-)
09:12rhickeyAWizzArd: it's contagious
09:15rhickeycgrand: I think it is more likely people will break from 42 being a Long, rather than Integer
09:16rhickeypeople love switching on types
09:18_fogus_Maybe you could deprecate the type-based predicates (only half-joking)
09:21dnolenrhickey: definitely a bug in swank-clojure, just patched #^ARef -> ^clojure.lang.ARef and it works
09:21dnolenrickey: another issue, http://gist.github.com/432975, anything obviously wrong here? getting a java.lang.VerifyError
09:21opqdonutoh those are the best
09:22dnolenrhickey: if I leave out the v binding, that fn compiles fine.
09:29AWizzArdrhickey: so, Long will be the new default?
09:32The-Kennyhm.. what's the best way to get an inputStream from a String which is either an http-url or a local file?
09:34cemerickThe-Kenny: if you're on 1.2, clojure.java.io/input-stream
09:36chouseroh *there* it is. Couldn't find it.
09:37The-Kennycemerick: Thank you, that's perfect :)
09:37The-Kenny(I was searching in duck-streams)
09:37rhickeychouser: find what?
09:37cemerickclojure.java.io *is* duck-streams now, essentially
09:37chouserio in clojure.java. I was looking in clojure, clojure.core, ...
09:38The-Kennycemerick: Yeah, I didn't know that it existed
09:38ChousukeI like that hosty stuff was put under .java :P
09:38chouseryeah, it's a good decision, I just forgot
09:38ChousukeI suppose there might be a real clojure.io someday
09:49Twey« Note: this is not really "duck typing" as implemented in languages
09:49Tweylike Ruby. A better name would have been "do-what-I-mean-streams"
09:49Tweyor "just-give-me-a-stream", but ducks are funnier. »
09:49TweyHahaha.
09:52duck1123my type of streams
09:53Twey:-D
10:02pedroteixeirasince there is an internal-reduce, are there plans for internal-map? does it even make sense to speed up map over vectors?
10:03ChousukeI don't think so
10:03Chousukewith reduce you know you'll be going over the entire collection but map returns a lazy sequence
10:03pedroteixeiraChousuke: couldn't a map over a vector return a vector? when benchmarking here, map over list is much faster.
10:04Chousukevectors can't be lazy
10:04RaynesLazySeq, not LazyVector. :p
10:04pedroteixeiraare there hints then to improve performance when iterating a vector?
10:04Chousukethough Rich has implemented a parallel map operation for vectors in a (rather old) branch
10:05pedroteixeiramy use case is basically find the max item and its index, given a vector. trying different strategies here
10:05rhickeydnolen: fixed
10:05Chousukemanual looping is probably fastest
10:05pedroteixeirausing a doseq with an atom to keep current max seems slow also.
10:06Chousukethough since you need to go over the vector in any case, you can also use reduce
10:06Chousukeatoms are definitely not needed.
10:06pedroteixeiraChousuke: ok, will keep trying here. thanks.
10:08pedroteixeirathought about using reduce, but thought would be weird to keep passing the index around.. will benchmark it :) this function needs to be ultra-fast
10:09chouserpedroteixeira: the simplest solution might be max-key. Not sure if loop/recur would beat that or not.
10:10pedroteixeirachouser: currently i'm using max-key, but I do a map before with (range (count v)) to get the item's index also. the map is slow, so trying to create a max-key-index for vectors.
10:13chouser,(let [v [3 1 6 4], i (apply max-key v (range (count v)))] [i (v i)])
10:13clojurebot[2 6]
10:13chouserI was thinking something like that.
10:16pedroteixeirachouser: wow, that's really clever.. absorbing it still here, going to test it.
10:16chouserwith .
10:17chouserI don't know why I said "with ."
10:17eintris there a convenient way to make a reader that reads just a range of bytes from a file (offset, length)?
10:40hoeckeintr: java.io.FileInputStream ?
10:40hoeckaren't readers for character-data only?
10:41dnolenrhickey: a lot of things seem faster in the prim branch, but naive benchmarks on map/reduce seem more than 1.5X slower than master, (doall (map inc (range 1000000))), is that expected?
10:42rhickeydnolen: did you see your bug fixed?^^
10:42eintri'm trying to get supercsv to parse a portion of a file, and it takes a Reader as argument.. so i need a Reader that will only "emit" parts of the file.
10:43dnolenrhickey: let me check now
10:43AWizzArdeintr: what class does the manual of supercsv suggest to use?
10:43hoeckeintr: then use the .skip method of the reader to jump to the offset
10:45eintrhoeck: sure, that far I got as well.. but as for stopping :)
10:47eintrhoeck: i need to limit the number of bytes read by the inputstream.. with a wrapper or something
10:47hoeckeintr:ah, now I do understand your problem, either subclass reader to only emit n characters
10:47hoeckor read the portion of that file into a string and wrap the string into a StringReader
10:51hoeckeintr: sth along: http://gist.github.com/433105
10:53eintrhoeck: thx cool.. i'll probably need a subclass though, 'cause i'm streaming large files.. thanks for the hint though :)
10:56hoeckeintr: then it may be worth to look into the java.nio CharBuffer, or ByteBuffer
10:59rrc7czwhy might "lein compile" not generate a class when :aot [foo.bar] is configured, where (ns foo.bar (:gen-class :extends blah blah...). No errors, the /classes folder is created, but it's just empty
11:00rrc7czI got it to generate the class when I used (gen-class) instead of (ns foo.bar (:gen-class))
11:03cgrandrrc7cz: did you try :namespaces instead of :aot?
11:05dnolenrhickey: yes, code compiles now w/o error. thx!
11:06rhickeydnolen: perf degradation just some reflection that crept in, cleaning up now. Thanks for the reports!
11:06rrc7czcgrand: still not working. My understanding was that namespaces was simply an alias for aot
11:08dnolenrhickey: yet another weird bug about not being able to find unchecked-remainder, sound plausible?
11:08rrc7czthe only thing I can think of is that using (gen-class) I explicitly give a :name foo.bar.Baz, whereas with (ns (:gen-class)) I simply have the namespace foo.bar.
11:10rrc7czcgrand: actually that fixed it! I had two "ss" in namespaces when I first tried it
11:10rrc7czcgrand: if namespace is simply an alias of aot according to the documentation, why does this fix it?
11:10cgrandrrc7cz: I don't know: I got the same problem the other day and no time to investigate
11:11rrc7czcgrand: anyway, thanks for the tip
11:46technomancydnolen: I can't repro the swank problem you reported with clojure master (which prim got merged to)... are you still seeing it?
11:46technomancyoh never mind; I misread. it didn't get merged.
11:47dnolentechnomancy: yeah, it's a simple fix really. In fact I note that it's probably an oversight, all the other type hints have the clojure.lang prefix except for ARef
11:47dnolenin inspector.clj
11:48technomancyyeah, I am somewhat surprised it works without being fully-qualified. edge case of lookup rules, I guess.
11:49dnolentechnomancy: it would also be nice to get my pretty print macroexpand patch in :)
11:50technomancydnolen: it's certainly on my list. it's just that "it's broke" reports are higher priority. =)
11:51defnI'm looking to take a collection of integers [11 21 22 23 24 26] and return [11, 22, 24]
11:51defnbasically the first, third, and fifth elements in a collection will be the return
11:57rhickeydnolen: perf fixed
11:57dnolenrhickey: ^ did you see the unchecked-remainder thing I mentioned?
11:57rhickeydnolen: do you have a gist of the unchecked-remainder thing?
11:57dnolenyes one second
12:01dnolenrhickey: http://gist.github.com/433208
12:02dnolenrhickey: if you run the last perf test in the comment at the bottom you'll see what I'm talking about.
12:02rhickeydnolen: that's too much context for me to look at, I'm afraid
12:03dnolenrhickey: heh yeah, let me come up with something smalle based on what I'm seeing.
12:03yacin,(doc key)
12:03clojurebot"([e]); Returns the key of the map entry."
12:03dnolens/smalle/smaller
12:03yacinwhat are map entries?
12:03yacini don't understand what this does or how it's used
12:04Chousukeyacin: running seq on a map gives you a seq of map entries
12:04Chousukeyacin: they're basically two-element vectors
12:04yacingot it
12:05yacinthanks
12:06Twey,(key ['a 'b])
12:06clojurebotjava.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.util.Map$Entry
12:06yacin,(map key {:a :b})
12:06clojurebot(:a)
12:06yacin,(map val {:a :b})
12:06clojurebot(:b)
12:06Twey,(map id {:a :b})
12:06clojurebotjava.lang.Exception: Unable to resolve symbol: id in this context
12:06TweyEh
12:06Twey,(map (fn [a] a) {:a :b})
12:06clojurebot([:a :b])
12:07chouser,(seq {:a :b :c :d})
12:07clojurebot([:a :b] [:c :d])
12:07TweyAh ☺
12:07Twey,((compose class first seq) {:a :b})
12:07clojurebotjava.lang.Exception: Unable to resolve symbol: compose in this context
12:07Twey,((comp class first seq) {:a :b})
12:07clojurebotclojure.lang.MapEntry
12:08Twey,((comp meta first seq) {:a :b})
12:08clojurebotnil
12:08a_strange_guy,(type (find :a {:a 1 :b 2}))
12:08clojurebotjava.lang.ClassCastException: clojure.lang.Keyword cannot be cast to java.util.Map
12:08TweyI've never found anything for which ‘meta’ doesn't return nil
12:08a_strange_guy,(type (find {:a 1 :b 2} :a))
12:08clojurebotclojure.lang.MapEntry
12:08TweyAre there any built-in values that use it?
12:08a_strange_guy(meta +)
12:08Twey,(meta +)
12:08clojurebot{:ns #<Namespace clojure.core>, :name +, :file "clojure/core.clj", :line 793, :arglists ([] [x] [x y] [x y & more]), :added "1.0", :inline-arities #{2}, :inline #<core$_PLUS___3866 clojure.core$_PLUS___3866@1b7713d>, :doc "Returns the sum of nums. (+) returns 0."}
12:08TweyOh
12:09TweyHuh
12:09TweyI don't get that in my local REPL
12:09a_strange_guyall vars and fns have metadata
12:09TweyJust nil
12:09a_strange_guy,(meta #'seq)
12:09clojurebot{:macro false, :ns #<Namespace clojure.core>, :name seq, :file "clojure/core.clj", :line 114, :arglists ([coll]), :doc "Returns a seq on the collection. If the collection is\n empty, returns nil. (seq nil) returns nil. seq also works on\n Strings, native Java arrays (of reference types) and any objects\n that implement Iterable.", :tag clojure.lang.ISeq, :added "1.0"}
12:09yacini also get nil
12:09TweyAh, I get the metadata for #'seq
12:09yacinyeah, #' fixes it
12:09a_strange_guyyou use 1.1?
12:10a_strange_guyin 1.2 functions can have metadata
12:10TweyYeah, I'm on 1.1
12:10a_strange_guybefore that only collections, reftypes(inc. vars) and symbols could have metadata
12:11TweyNo 1.2 in AUR yet… I'll upgrade when it comes
12:14raekwhich metadata does functions in 1.2 usually have? same as the var that contains it?
12:15chouseryep
12:25dnolenrhickey: ok, probably related, should areduce work inside of a defn ^:static?
12:29rahulkmrI am using emacs 23, slime and swank. Multithreaded programs don't work for me, or rather only run once. After that they throw a error: java.util.concurrent.RejectedExecutionException (par_scan.clj:0) Is it a known issue?
12:29rahulkmrI am running it as C-c C-k
12:37rhickeydnolen: areduce should be fine
12:39dnolenrhickey: http://gist.github.com/433269
12:40dnolenrhickey: both amap and adreduce seem to be affected
12:40rhickeydnolen: works here
12:41rhickeydnolen: you running on a clean rebuild?
12:43dnolenrhickey: yes, gist updated, this seems weird now
12:44dnolenrhickey: I added a second definition and then then I get the exception
12:45rhickeystill works
12:45rhickeyah, with namespace it doesn't
12:46rhickeyI'll look
12:51rhickeydnolen: fixed, thanks for the report
13:04dnolenrhickey: ah, so (unchecked-remainder (int 0) (long 500)) should not work?
13:04rhickeydnolen: must match
13:07The-Kennyhm... is there a easier way to convert an InputStream to a ByteBuffer than reading from it in a loop/recur?
13:13dnolenrhickey: gotcha, thx
13:17technomancyThe-Kenny: clojure.java.io/copy probably
13:18The-Kennytechnomancy: "Output may be an OutputStream, Writer, or File." - Doesn't look so
13:21technomancyThe-Kenny: wrap a ByteArrayOutputStream?
13:22The-Kennytechnomancy: Huh, what a great idea (You see why I just hate java-io)
13:23The-Kennyclojure should have binary-slurp as a counterpart to slurp :)
13:45cmiles74k
14:00rhickeykeyword callsites now compatible with static
14:01chouserprim's is for post-1.2, right?
14:02cemerickrhickey: see, I'm just your canary in the coal mine ;-)
14:03rhickeyhere's the difference: http://gist.github.com/433369
14:04rhickeynote, this is not using primitives, and no change to core code other than from direct linking to statics
14:04rhickeycemerick: still want to wait?
14:04cemerickdamn, numbers really help with decision-making!
14:05cemerickrhickey: note, I never said it wasn't a good change ... forward progress is still orthogonal to comprehension and such by the broader community, new users, etc.
14:05LauJensenWhat are these statistics mentioned?
14:06rhickeythis is just the tip of the iceberg of what you can do with the prim branch, perfwise. I'm quite surprised to see this big an increase for no real change in user code
14:06cemerickrhickey: I promise I will not be the one to hype that gist.
14:06cemerick:-D
14:06rhickeycemerick: I understand, believe me, this could have been in master already
14:09rhickeyhowever at this point, barring ay more bug reports (thanks dnolen!), I think it's done
14:10a_strange_guymay I ask what makes static defn's so fast
14:12rhickeya_strange_guy: normal fn calls go through a var, which, being variable, is volatile, and an inhibitor to inlining by hotspot. Direct linking improved that by caching the fn object. statics get rid of the fn object in some calls, replacing it with a static method that does the same job. HotSpot can inline right through those, quite easily
14:13a_strange_guyso it works like those fns like + etc.
14:13a_strange_guyinlining calls to a static method when possible, and else use the fn?
14:13a_strange_guynice
14:13rhickeya_strange_guy: somewhat, but they required me to write a JAva static method _and_ a fn, and declare the fn inline etc. This now fall out of putting (defn ^:static foo ...)
14:14technomancyah, so it's more to help out hotspot than _just_ to avoid the var lookup cost. that makes sense.
14:15rhickeya_strange_guy: a fn object is still in the var for use as a fn value, i.e. inc in that gist is not being called via the static
14:18a_strange_guyrhickey: any interest on a proposal to make deftype/record real fns, but still directly constructable, when performance is needed?
14:18rhickeya_strange_guy: this work is needed in part to support other options in that area, yes
14:19a_strange_guyhttp://gist.github.com/429080
14:19rhickeyin particular, removing the 'do something else when performance needed' bit
14:20a_strange_guybasically its putting the classname in the metadata on the var and fn
14:21a_strange_guyso (Foo 1 2 3) is a Fn call through a var
14:21a_strange_guyand (new Foo 1 2 3) or (Foo. 1 2 3) would be a direct call of the ctor
14:25LauJensenrhickey: Is this going in 1.2 ?
14:26rhickeyLauJensen: dunno - you all should try it and tell me
14:28LauJensenrhickey: You looking for any specific feedback, or should we just run it on recent code and see if anything breaks?
14:29dnolenLauJensen: probably more useful to take some of your performance examples and convert to statics.
14:29rhickeyLauJensen: you can just try your stuff and look for breakage, and/or try the new static and primitives stuff
14:30LauJensenI'll drop a line if anything breaks
14:38raekdoes this static thingy affect redefinition of functions?
14:38dnolenraek: no
14:38chouseryes
14:38LauJensenmaybe
14:39dnolenchouser? really?
14:39a_strange_guyyes it does
14:39dnolenchouser: oh yeah, if you called by name in some *other* function
14:40chouserif fn b uses static fn a, and then you redefine a, b will continue to use the old version until you also reload b
14:40chouserdnolen: right
14:40raekok, makes sense
14:40rhickeystatics essentially follow rules similar to macros
14:41rhickeybut there is no reason to tag something as static until you are essentially done with it
14:42dnolenrhickey: I like the design. You can evolve your program to be fast.
14:42LauJensenaha. Isnt there a way to provide some kind of warning of you redef something, which wont take effect because its called from another fn which needs redef also? Or automate it or something like that?
14:43bobo_LauJensen: if you didnt know the gist you posted on twitter is deleted.
14:44LauJensenbobo_: ah thanks - Anybody forked it?
14:45rhickeyNote - I haven't been able to reproduce the results in my gist, so I've deleted it. Things are faster but not by that much. My 1.2 session must have been mucked up in some way
14:45slyphon1/
14:45LauJensenrhickey: ah ok
14:46yacinis there a limit to the size of the string that can be passed into sh with :in?
14:47yacini'm trying to throw a 66k line string into it, and it just hangs
14:47yacintrying to avoid having to dump to a tempfile and input from there
14:48chouseryacin: sh probably needs to be multithreaded to avoid getting hung up on inputs or outputs larger than the OS's buffer
14:48chouserthere was a message on the list. I just haven't had the time to deal with it yet.
14:49yacingotcha
14:49chouserI don't actually use sh much. :-/
14:49yacinyeah, i try and avoid it if at all possible
14:49yacinbut this particular web service i'm using makes a point of saying it only works with gnu netcat
14:51yacinis there anyway to do <, > or | with sh?
14:51LauJensencemerick: I heard some talk about the need for a quality Clojure IDE and that some people were willing to pay 500$ per seat for it - Just wondering, why isnt something like Enclojure filling that spot?
14:51chouseryacin: you can use (sh "bash" "-c" "whatever < here")
15:03chouserrhickey: love the stack comments :-)
15:04LauJensenno comments on wether the redeffing could be helped along some?
15:06a_strange_guyLauJensen: I think this would require something like ADSF
15:06LauJensen?!
15:06LauJensena_strange_guy: giving some compiler warnings in Clojure would require the packagemanager from Common Lisp?
15:07timcharperLauJensen: I read that article. He said paredit mode was a requirement for that IDE
15:07timcharper(and I would agree)
15:07timcharperalso... toggleable rainbow parens
15:07LauJensenoh - I think I should start selling Emacs installations for 500$/seat then :)
15:07a_strange_guyi don't think compiler warnings would be useful
15:07timcharperLauJensen: Good idea! For both fun and profit!
15:08a_strange_guybecause every macro, static, and deftype would emit them
15:08LauJensentimcharper: I think seriously, if you listed all the features of Emacs and called it "Hyper Max IDE 2010" then you could probably sell quite a few licenses
15:08LauJensen(until rms found out)
15:09chouserto be useful, I think every user of a macro or static would have to register itself such that when the macro or static is redefined it could tell you what else might need to be reloaded
15:09timcharperhey... "distribution fees" are allowed with the GPL, aren't they?
15:09timcharperIt costs me $500 to burn this to a CD or let you download it.
15:09chouserbut that would surely be a modularity problem in the general case. Maybe something an IDE could do for you?
15:10LauJensenchouser: perhaps - wouldnt it make sense in core?
15:10timcharperOK, I'm stretching it, and I'm being part of what's wrong with the world.
15:10a_strange_guyI personally think that such registering should be in the language
15:10chouserLauJensen: you want every var in core to have list all the function using it?
15:10dnolenLaujensen: I'd first like to see if it's really problem.
15:11LauJensendnolen: Its been a problem for me in the past with macros
15:11a_strange_guydnolen: it surely is a problem
15:11dnolenI suspect that people will only use statics only in very perf critical components of their programs. At that point you know what you're doing anyway.
15:11LauJensenchouser: If thats whats needed
15:11dnolenLaujensen: only a problem if you're doing REPL heavy stuff
15:12LauJensendnolen: Which Im always doing
15:12dnolenaround performance
15:12dnolenwhich you should be doing often
15:12dnolenshouldn't I mean
15:12chousernot a problem if you tend to use :reload-all to get your repl up-to-date
15:12arohnerI use the nuclear option (require 'my-top-level-ns :reload-all). I never have problems
15:13chouserstring's not in core yet?
15:13chouserarohner: yes
15:14LauJensenOdd, its rare that I use that work-flow
15:15chouserLauJensen: how often do you forget to send a form to the repl and have to go jump around in your file sending things?
15:15LauJensenClose to never
15:16dakroneLauJensen: what happened to your gist on twitter? Did you delete it?
15:16dnolenstatics nicely solve the inner loop arithmetic performance problem that has plagued clojure, and it makes core calls zippy. What else does it buy us?
15:16LauJensendakrone: Yes - It had an error, sorry
15:16chousersimply because you don't forget to send forms when you're done editing them, or what?
15:16dakroneahh, okay
15:16LauJensenchouser: yes
15:16LauJensenIts also wired into my fingers to eval every time I close a parens :)
15:17yacinchouser: thanks, worked like a charm
15:18a_strange_guyyou could hack such a dependency tracking system using watchers & metadata probably
15:19chousera_strange_guy: ah, interesting!
15:20a_strange_guyif all the special forms were macros or namespaced you could redefine def to find all references to other vars and save them
15:22arohnera_strange_guy: def isn't a macro, but fn is
15:22a_strange_guyit should be hooked onto the creation of a var
15:22arohnersomeone (technomancy?) already has an fn source metadata hack that's pretty cool
15:23a_strange_guyor even better onto 'defn !
15:24chouserit'd be hard to get 100% coverage without hooking into the compiler more deeply than I know how without a patch.
15:24chousereven then, it would be hard to know how to re-compile all possible users.
15:25chouser(defn ^:static f []) (add-watcher #'g :c (fn [k r o n] (f)))
15:26chousernow #'g has a watcher fn that uses a static.
15:26a_strange_guyif you know what vars are using another var, then you could use the linenumbers to reeval the code
15:26chouser(defn ^:static f [] :new-f)
15:27a_strange_guyi think tracking other vars would cover 99% pecent of usecases
15:27chousera watcher on f could now notify you that it's been updated, but did you hook add-watcher to register :c? And if you did, how do you update it -- remove the old watcher and add a new one?
15:27chousera_strange_guy: yes. 99% is much easier than 100%
15:28a_strange_guydefn could be redefined to walk the body of its code
15:28a_strange_guyand to try resolve all the symbols
15:29a_strange_guywhen it hits a var, you have a dependency
15:29chousera_strange_guy: yes, you'd have to do something like that.
15:29a_strange_guyhackish, but possible
15:29arohnerhaving watchers on namespaces would also do it. watching a namespace seems pretty cool actually
15:29a_strange_guyif you have compler support it would be much cleaner
15:29chouserof course it would have to not register things that *look* like a var-call but actually aren't.
15:33LauJensenSounds complicated. And 99% accuracy is 100% unrealiability
15:34a_strange_guynot if you have compler support
15:34chouserbut with compiler support comes modularity problems
15:34a_strange_guyaxi: thanx iiiiiiiiii
15:34chouserif every fn has refs to every fn that uses it, those users can never go away
15:34LauJensenchouser: like what?
15:35chouserdnolen: yeah
15:36a_strange_guychouser: you mean gc?
15:36LauJensendnolen: Its not that I dont understand macros or statics, Im just saying Ive been forgetful with redefs in the past, and if there was a simple way to ensure no future breakages like that, I'd be happier
15:36chousera_strange_guy: yeah
15:36a_strange_guyJava has some stuff that one could use
15:36a_strange_guyReferencequeues etc.
15:37chousereven with compiler support, how do you handle anonymous fns like my watch example above?
15:37dnolenLaujensen: sure. Also I wish GCC to point out magically point out memory leaks in C code :)
15:38arohnerdnolen: have you tried valgrind? it's magical
15:38a_strange_guychouser: probably not
15:38a_strange_guybut this would only work for sourcefiles that only have definitions
15:39a_strange_guya good compromise would be to track only 'def forms
15:41Chousukednolen: we'll probably see lots of newbies using statics everywhere though :P
15:42dnolenChousuke: yup and that's what we're here for :)
15:42Chousukeheh
15:42Chousukehumans are very good at doing the wrong thing
15:42a_strange_guythis is why I hate "performance first" mentality
15:42Chousukefortunately they're a bit better at learning from mistakes than other animals
15:46LauJensenChousuke: I'll label that: self delusion
15:50kotarakYeah. ClojureCheck is back. As an extension to clojure.test. :)
15:55lpetitHi
16:42timcharperI would like to build a lazy sequence that is processed by another thread
16:43kotarak(doc seque)
16:43clojurebot"([s] [n-or-q s]); Creates a queued seq on another (presumably lazy) seq s. The queued seq will produce a concrete seq in the background, and can get up to n items ahead of the consumer. n-or-q can be an integer n buffer size, or an instance of java.util.concurrent BlockingQueue. Note that reading from a seque can block if the reader gets ahead of the producer."
16:44timcharper(com.mongodb.ObjectId.)
16:44timcharperoops, I am lame.
16:45timcharperkotarak: thank you!
16:45timcharperhow does seque differ from fill-queue ?
16:45kotarak(doc fill-queue)
16:45clojurebot"clojure.contrib.seq-utils/fill-queue;[[filler-func & optseq]]; filler-func will be called in another thread with a single arg 'fill'. filler-func may call fill repeatedly with one arg each time which will be pushed onto a queue, blocking if needed until this is possible. fill-queue will return a lazy seq of the values filler-func has pushed onto the queue, blocking if needed until each next element becomes available. fill
16:45kotarakdunno
16:46timcharperI'm already using fill-queue to create an eagerly-processed lazy queue pipeline
16:47timcharperIt's great because the lazy seq (queue) is filled up to the queue-size in another thread, so items are ready
16:48timcharperbut I'm trying to write something where I can do a "send-off-and-forget" operation, in this case, queuing up a bunch of insert operations as if they were individual, and then bulk-inserting the whole thing every 32 or so
16:48a_strange_guythey both seem to do the same
16:48timcharper(as with congomongo, bulk-insert! can be about 5 times faster than insert! in my measurements)
16:49timcharperhmm...
16:49a_strange_guyfill-queue just has an imperative interface
16:49a_strange_guyand seque has a functional interface
16:49timcharperso what I want is kind of like a flip-flopped version of fill-queue. Rather than the populator in a different thread, I want the consumer in a different thread.
16:50a_strange_guyyou want a pipe?
16:51chouserhm, I think that's a weakness of fill-queue's interface rather than its design.
16:51chouser~google future pipe dream
16:51clojurebotFirst, out of 266000 results is:
16:51clojurebotLTE in Consumer Devices: Technophile&#39;s Pipedream or Future Reality ...
16:51clojurebothttp://www.juniperresearch.com/analyst-xpress-blog/2010/05/28/lte-in-consumer-devices-technophiles/
16:51chouser~google clojure future pipe dream
16:51clojurebotFirst, out of 418 results is:
16:51clojurebotClojure and me » Are pipe dreams made of promises?
16:51clojurebothttp://clj-me.cgrand.net/2009/11/18/are-pipe-dreams-made-of-promises/
16:51chousertimcharper: take a look at that last one
16:51a_strange_guyi actually dont like this implementation
16:52chousera_strange_guy: fill-queue's you mean?
16:52a_strange_guyno, cgrand's pipe
16:53chouseroh. yeah, he's said it's more of a demonstration than something he'd recommend people use
16:53a_strange_guyshould wrap a BlockingQueue instead
16:53chouserbut it might be a place to start
16:53timcharperok :) cool
16:53timcharperthanks
16:54timcharperI've had my eye on the pipe dream post for some time (http://twitter.com/timcharper/status/15282633029)
16:54TeXnomancyhas there been any discussion of getting clj-stacktrace merged into clojure.stacktrace?
16:54TeXnomancyI just started using it and am kicking myself for not trying it sooner.
16:55timcharperI don't like that it's using futures so much
16:55TeXnomancybut you kinda have to monkeypatch to do anything useful with it; would be much nicer if clojure.test could be made to use it without trickery.
16:55a_strange_guyyou mean promises?
16:56timcharperoh... wait... it's not creating a future for every item.
16:56timcharper(duh)
16:56timcharpera_strange_guy: thank you for pointing that out
16:56timcharperare promises pretty cheap?
16:57a_strange_guydon't think so
16:58a_strange_guythey use CountDownLatches internally
16:58a_strange_guywhich normally aren't used for that purpose
16:58rfg /join #erlang
16:59rfgWell that didn't work.
16:59rfg:)
17:01garybuI tried the prim branch to see if it improved "loading request" time on Google App Engine. The loading time went from 8 seconds to 5 seconds for my test application. This number might not be accurate because loading request times can vary for unknown reasons.
17:02cemerickLauJensen: enclojure gets the job done, and covers my necessities at the moment, but is by no means polished or a final solution.
17:03LauJensencemerick: except paredit, whats missing?
17:03cemerickparedit is largely not a concern for me -- it's not like I'm used to it, though I see the utility
17:04cemerickIt's missing a variety of things, some simple, some not so simple.
17:04cemerickWhen I get a few hours, I'm going to start a feature grid on that wiki page and start filling it in.
17:04LauJensenk cool
17:05LauJensenI gotta jet - Thursday came and went in Denmark, good night all
17:06islonanyone knows how can I use connection pool with clojure contrib sql?
17:07islonis there any example?
17:31pedroteixeiraanyone knows an easy way to make dotrace accept a var?
17:33pedroteixeiramy use case is to have something like (def fns (vals (ns-publics (find-ns 'clojure.core)))) (dotrace fns ...)
17:42powr-toccemerick: I'd like to see swank support in the IDE's myself
17:43cemerickpowr-toc: I don't know enough about it to have an opinion there. I use enclojure's remote REPL library, which has been steady as a rock for me.
17:43powr-toccemerick: do you have a link for that?
17:44cemerickobviously, some kind of remote repl capability is a requirement. It'd be nice to have a clojure-native one be the standard at some point.
17:44cemerickpowr-toc: it's poorly documented :-/
17:44cemerickso, no
17:44cemerickit's worth a blog post
17:44powr-toccemerick: I'd just like all the IDE's to converge on a single solution for remote REPLs... that way you can use clojure-maven-plugin or lein (or anything else) for classpath management etc...
17:45cemerickabsolutely
17:45cemerick*all* repls should be remote repls as well. I don't know if any environments are exec'ing clojure anymore, but if they are, they should stop.
17:45powr-toccemerick: And I think all the IDE's and slime-connect should be able to talk to it...
17:46cemerickI've overheard people complain about swank and slime from a project management point of view (e.g. breaking changes from upstream and such). I'm also wary of the CL roots insofar as it becoming a clojure-land standard.
17:46cemerickthough it's a de facto standard already :-)
17:47powr-toccemerick: I agree... though there are still lots of situations where you'd want to start a JVM in another manner
17:47kotarakI'm happy with VimClojure: it is basically a remote repl and I use it with gradle for classpath management. gradle runNailgun and there you go... :)
17:47cemerickwell, that's orthogonal to whether the environment *connects* to the vm over a socket vs. using exec's streams to communicate
17:48powr-toccemerick: yeah... I guess that's a concern...
17:48cemerickgradle, huh? Brave :-)
17:48kotarakcemerick: gradle is quite nice, actually.
17:48cemerickkotarak: you certainly seem to have captured the vim market :-)
17:48powr-toccemerick: my point exactly
17:48cemerickI'm sure it is...never used it.
17:49kotarakcemerick: I think, it is underrepresented in the maven vs. lein discussion. But anyway, everyone as he likes...
17:50powr-toccemerick: plus the IDE's should use both mvn and lein to manage dependencies etc...
17:50kotaraksee... ;)
17:50cemerickkotarak: It seems to be an obvious choice in groovy-land. What is compelling about it?
17:51powr-tocI'm personally very happy with Emacs/SLIME etc... but clojure definitely needs better IDE support
17:51cemerickpowr-toc: if lein proves to have staying power, then yes
17:51kotarakcemerick: it is relatively declarative, but you can easily do more complex stuff. And the multiproject stuff is simply awesome.
17:52powr-toccemerick: naturally... though I thought lein was becoming pretty defacto...
17:53cemerickpowr-toc: I don't know what the numbers are like. Maven is used pretty commonly once one's project is past a certain degree of complexity AFAICT.
17:53kotarakcemerick: and some problems are just none with gradle. Eg. java compilation depending on the clojure side or the other way around. I don't define the order in the plugin. So you can do it yourself. Without much trouble and strange hacks.
17:54cemerickkotarak: surely gradle can't figure out the dependency relationship between two sets of sources on its own?
17:55powr-toccemerick: yeah... I'm using maven on one project... but prefer lein if I can get away with it.
17:55kotarakcemerick: no. clojure depending on java is maybe possible. I don't think the other way around is possible in general.
17:55cemerickpowr-toc: I suspect polyglot maven will be the next natural step once it's finished.
17:55powr-toccemerick: yes, maybe... though I've not really looked at it too much yet
17:56cemerickunderstandably. Still pre-release.
17:56powr-tocI think I'm letting enough blood with bleeding edge projects as it is! ;-)
18:04yacin,(bit-shift-right (expt 2 26) 31)
18:04clojurebotjava.lang.Exception: Unable to resolve symbol: expt in this context
18:04yacinerm
18:04yacin,(use 'clojure.contrib.math)
18:04clojurebotnil
18:04yacin,(bit-shift-right (expt 2 26) 31)
18:04clojurebot0
18:04yacin,(bit-shift-right (expt 2 26) 32)
18:04clojurebot67108864
18:04yacinis this wrap-around intended behavior?
18:04yacinactually
18:05yacinthis is just weird
18:05yacinany ideas as to what's going on?
18:28replacaQ: can someone remind me how I refer to an inner class in interop? Actually I need to refer to an enum in a class (in Java it's Color.Ansi.WHITE)
18:28lancepantzreplaca: Class$InnerClass
18:30replacahmm, that's what I thought. I must have something else confused. So it would be Color$Ansi/White, right?
18:30replaca* Color$Ansi/WHITE
18:33replacaAhh, I need to explicitly impoirt the inner class
18:34cemerickyeah, inner classes really are only "inner" w.r.t. java-the-language scoping
18:34cemerickand availability of the OuterClass.this reference
18:35hiredmanring needs a middleware to map uris to clojure namespaces
18:36hiredman(restify 'foo) then requests to /x/y/z call foo.x.y/z
18:56arohnerhiredman: I wrote that awhile ago. I had problems with http methods i.e. get vs. post
18:57replacaIn project.clj, does :jvm-opts "-D...=..." work? I'm trying to use it with lein swank and having no luck
18:57arohnerhiredman: so I wrote defroutefn instead. http://github.com/arohner/clj-blocks/blob/master/src/clj_blocks/routes.clj
18:59technomancyreplaca: it's a newish feature; hasn't been widely tested.
19:01replacatechnomancy: maybe my lein is out of date then. I'll make sure I'm uptodate
19:02replacatechnomancy: to update I get a new "lein" file and run self-install?
19:03technomancyreplaca: no, dev builds need a bootstrap step; see "hacking" in the readme
19:03technomancythough a stable release isn't far off
19:04replacaok, for today that's too big a detour. I'll try again with stable and run by hand for now
19:04technomancystable builds to respect JAVA_OPTS env var
19:05replacatechnomancy: they will or they already do?
19:06technomancysorry, they do. implemented in 1.1.0.
19:06replacatechnomancy: thanks, that's fine for what I'm doing now
19:22erikcw1I have a list of several hundred URLs that I need to process in parallel. Does anyone know of an implenation of pmap that has a user-adjustable thread pool size?
19:34tomojI saw something that might be almost what you want recently
19:35timcharpererikcw1, I have written some code to do something like what you want
19:35erikcw1I'm all ears! :-)
19:36tomojhttp://s-expressions.com/2010/06/08/medusa-0-1-a-supervised-thread-pool-for-clojure-futures-2/ is what I remembered
19:36timcharperis it more important that you control the number of threads, or that you control how eager the list is processed ?
19:36tomojnot user-adjustable, but will be someday, it says
19:36timcharperbecause you can control how many are processed concurrently by controlling how far ahead you allow the list to be processed
19:37erikcw1timcharper: probably the number of threads. I want to list processed as quickly as possible, but I don't want to spawn so many threads that the server starts swapping to disk
19:37tomojoh.. but medusa "futures" don't return values
19:37timcharpererikcw1: it seems that controlling how far ahead the list is processed would have the same effect, wouldn't it ?
19:37timcharper(preventing the server from swapping to disk)
19:37erikcw1tomoj: I saw medusa - -but until the thread pool is user adjustable, it won't work for me
19:38erikcw1timcharper: I suppose
19:38timcharperanyways... here's one possible route:
19:38timcharper...
19:38tomojit seems to me that making the thread pool size adjustable would be a trivial change
19:38KirinDaveSomeone recently did a big thing with clojure as their blogging software
19:38KirinDavewho was it?
19:39tomojbut i suppose it's not?
19:39KirinDaveI need to get something up and running at fayr.am soon
19:39tomojlau, I bet
19:39tomojhttp://www.bestinclass.dk/index.clj/2010/05/refresh-your-cache--best-in-class-has-been-baked.html
19:39tomojand http://www.bestinclass.dk/index.clj/2010/06/best-in-class--now-open-sourced.html
19:39tomojKirinDave: ^
19:42timcharpererikcw1: http://gist.github.com/433817
19:42erikcw1timcharper: thanks -- let me see here....
19:42timcharperif the overhead of futures is a concern, you can always chunk it and process chunks in parallel
19:43timcharperat the cost of greater memory usage (more needing to be in memory at a time)
19:44timcharper(pmap-queue odd? (range 1 10) :queue-size 5) will immediately start computing the first 5 elements in parallel
19:44timcharperit will always stay 5 ahead from the last consumed item of the lazy sequence
19:44timcharper(IE: it will keep 5 cores busy)
19:45timcharperthough... not very busy, using odd? :)
19:46erikcw1So if I'm processing a bunch of URLs (most of the time just blocking on the network), then setting the :queue-size 20 will run it on 20 threads right??
19:46timcharperyeah
19:46timcharperprovided you can consumer the results faster than it can produce them
19:46timcharper^consumer^consume
19:47timcharperhmm... actually... there's a slight difference
19:47timcharperif the first item takes 20 seconds, and next 19 items take 1 seconds, you would get into a state where you would be blocked by the first item
19:48erikcw1that's what I've been running into with the implementations I've been rolling myself
19:48erikcw1any ways around that?
19:48timcharperoh :)
19:49timcharperyeah... actually...
19:50timcharperone sec... it's on the tip of my brain
19:50erikcw1np
19:50timcharperI think you need a java.util.concurrent.LinkedBlockingQueue
19:51timcharperfire up 20 threads that are subscribed to that queue
19:51timcharperhave them stick their results in another LinkedBlockingQueue
19:52timcharperyour results will not come back in order... but based on your requirements, you probably don't care
19:52erikcw1yeah -- order is not important
19:53erikcw1I assume there is a way to tell when the queue has finished processed
19:53erikcw1processing*
19:53timcharperI don't know if there are any clojure methods that abstract that, but LinkedBlockingQueue is pretty easy to use
19:53timcharperyeah
19:53timcharperyou could set an atom that tells the consumers to quit
19:53timcharperhttp://java.sun.com/javase/6/docs/api/java/util/concurrent/LinkedBlockingQueue.html
19:54timcharperthe poll method of LinkedBlockingQueue can receive a timeout value
19:54timcharperyou probably wouldn't want to rely on being able to write faster than they can consume... would be safer to have some control
19:56erikcw1and that is what LinkedBlockingQueue will give me right?
19:58timcharperwhat ?
19:58timcharperoh... no
19:58erikcw1sorry -- still getting up to speed on the Java concurrency tools
19:58timcharperif you have 20 items consuming a queue, you're not guaranteed that the queue-filler will keep the queue full before there is no more work to do
19:59erikcw1but those 20 threads should just sleep if that happens right? More data comes in and they get back to work...
19:59timcharperyeah :)
19:59timcharperthat's why you would want to use poll
20:00timcharperpoll will sleep and wait for work if there is no work to do
20:00timcharperthen, the thread filling the queue can say "hey guys... seriously, there's nothing else... quit waiting, go home" by setting a boolean atom
20:03timcharper(loop (let [payload (.poll q 200 java.util.concurrent.TimeUnit//MILLISECONDS)] (if payload (do (process payload) (recur)) (when @still-processing (recur)))))
20:03timcharpersomething like that would be your worker
20:03timcharpererr... maybe @still-processing would be @work-pending... or something
20:04timcharperanyways.... I'm just sketching here... I'm don't consider myself an expert at this
20:04timcharpermaybe someone has a better idea, but that's how I would approach it
20:05erikcw1that makes a lot of sense
20:05erikcw1thank you!
20:05timcharpererikcw1: sure thing! trying to pay it forward... I get tons of help in this room
20:06timcharperoh... the (loop should be (loop []
20:07timcharperanyways.. you get the idea :)
20:12replacaHow do I type-hint for an array of ints? (Being lazy today!)
20:13tomoj^ints I think
20:14replacathanks!
20:29danlarkinwhat are situations in which a function sent to an agent wouldn't happen immediately
20:29danlarkinan idle agent
20:30danlarkinit's sent from within a transaction, so IIUC the action is only dispatch the the agent after transaction commit, but that doesn't seem to be what I'm seeing
20:42danlarkinif, instead of dispatching to an agent, I run the same code in a future, it happens right away
20:42danlarkinso I don't think it's that my code is blocking, I think somehow I'm blocking the agent from running
20:42danlarkinI just don't know how I could be doing that
20:55bhenryif i have a and b such that (def a [[1][1 2][1 2 3]]) (def b [2 3]) how can i replace (a 1) with b so that i get back [[1][2 3][1 2 3]]
20:58brehaut(assoc a 1 b)
20:58brehauthttp://clojure.org/data_structures
20:58bhenrybrehaut thanks!
20:58brehautno worries
21:57pedroteixeirawrote a compojure wrapper for logging trace, in case someone finds useful: http://gist.github.com/433930