#clojure logs

2010-12-07

00:13coldheaddefinitely a place for both, cky, but very little room for "here is 10000 lines of code i wrote all by myself, please make it better"
00:14coldheadnot that i'm bitter :)
04:04kjeldahlI want to like "cake", but there's always some issue about it. I've cloned it and symlinked bin/cake, and it makes a fuzz about missing classlojure . Any clues?
04:18hiredmankjeldahl: no reason you have to like or use cake
04:18kjeldahlhiredman: Well, it's a lot faster.
04:20kjeldahlAnd if a thing is supposed to work, I like to get it working before deciding. But you're right, if lein works and cake doesn't, it's a simple choice.
04:21kjeldahlThing is, it's working great on one computer, but not the other. Just trying to piece the puzzle together.
04:34kjeldahlHe he, how's that for a dependency.. Cake works, but only after running "lein deps" in it's source directory. It should probably ship with the required dependencies to make it runnable...
04:39kjeldahlLogged it as an issue: https://github.com/ninjudd/cake/issues/#issue/85
05:41harishtella(clojure + vim + unix) makes me feel like god
05:45bobo_required joke: then imageine how you would feel if you used emacs
05:56bartjhow do I download a jar version from http://clojars.org/clj-json
05:57bartjI am unable to build it on my machine
05:58kjeldahlbartj: List it as a dependency in project.clj (assuming you use lein/cake)?
05:58bartjkjeldahl, we have not yet migrated to lein/cake, etc
05:59kjeldahlbartj: http://clojars.org/repo/clj-json/clj-json/0.3.1/clj-json-0.3.1.jar
06:04bartjkjeldahl, thanks! how on earth did you get that jar?
06:04kjeldahlOn the front page of clojars.org, select "browse the repository". You're welcome!
06:12bartjhas anybody built clj-json and used it before?
06:16LauJensenkjeldahl: Cake is fantastic and you get great support in #cake.clj from among other ninjudd who has written the majority of the code in it
06:29Lajlabartj, are you Dutch too?
06:31AWizzArdAny Swing expert here? JTables...
06:33kjeldahlLauJensen: Yeah, I figured it must have something since the pros use it. Installing from git however, does not work "out of the box". It needs more stuff, which it does not fetch on it's own.
06:34LauJensenkjeldahl: You're supposed to install via gems, to get the latest stable
06:34bartjLajla, no
06:34kjeldahlLauJensen: Not according to the docs. git clone is supposed to work as well. But the docs may be wrong.
06:35LauJensenkjeldahl: Maybe Im the one who needs an update. Ive used it both in nix and windows via the gem installer/upgrader and it has always worked
06:35bartjI remember Lau recommending me to use clj-json
06:35LauJensenbartj: Was it good advice?
06:36LauJensenHmm... Actually, it must have been because you were using a greater evil, because normally I would never recommend JSON
06:36kjeldahlLauJensen: Maybe ;-) For me, not having to mess with Ruby is another pluss (my background is with perl...).
06:36LauJensenkjeldahl: You dont have to mess with anything
06:36kjeldahlLauJensen: You're assuming ruby and rubygems is already installed on all systems?
06:36LauJensenFor me it was "sudo pacman -S ruby && sudo gems install cake"
06:36LauJensenkjeldahl: no
06:37kjeldahlDoesn't pacman install ruby?
06:38kjeldahlIt's not that I'm not able to install ruby and rubygems (apt-get install in my case), but it seems a bit overkill for installing dependencies for a tool which is supposed to help me manage dependencies.. ;-)
06:38bartjLauJensen, I am yet to find out
06:38bartjthe sad part is that clj-json just doesn't cleanly compile :(
06:41bartjI just want to read json strings lazily
06:41bartjperhaps, I am being too lazy
06:54fliebelmorning
07:01LauJensenkjeldahl: pacman would install ruby yes, so you should use apt-get. Where lein uses bash, cake uses a little bit of Ruby. It makes sense to use the deployment tools already available for that language
07:03raek,(fn descriptive-name [x y] (+ x y))
07:03clojurebot#<sandbox$eval462$descriptive_name__463 sandbox$eval462$descriptive_name__463@176343e>
07:04LajlaBecause your name reminds me of raep
07:06kjeldahlLauJensen: Yes, I get how it works (now at least). I still think it's wierd. I got the impression that cake could be installed any way suggested on the homepage, but since it isn't "self bootstrapping" that's not really true. Bash is also a dependency, ok, but still more widely available than ruby. Compared to leiningen, which "just works" in more cases...
07:07LauJensenkjeldahl: Not if you're on Windows. But anyway, state your case in #cake.clj or raise it as an issue on github please
07:07raekor Solaris :)
07:07kjeldahlLauJensen: Anyway, I contributed a ticket at least on github. I guess the easiest solution is to state that additional packages are needed if not installed by ruby gems or similar.
07:11raekhave fun.
07:12Lajlaraek, that's what SHE said.
07:59AWizzArdWhich pros/cons does definterface vs defprotocol offer?
08:06cemerickThey both generate an interface, the latter is a protocol. :-P
08:08fogus`awaydefinterface allows primitive args and rets
08:21AWizzArdPrimitives are nice, good.
08:22AWizzArdI have a function that generates and returns a proxy. How do I typehint instances of it?
08:26ChousukeAWizzArd: Typehint it as whatever interfaces the proxy implements.
08:28AWizzArdChousuke: ah good, so I can simply use this 90-char type-hint :)
08:30AWizzArdChousuke: unfortunately it seems that a potentially random number is attached to the type name: my.projects.namespace.module.proxy$javax.swing.table.AbstractTableModel$TabelModelHelper$bb684924
08:34bsteuberAWizzArd: guess proxy internally uses sth. like gensym - but you shouldn't need the name
08:40AWizzArdbsteuber: do you have an idea how I can type-hint my proxies in a way that will be stable through restarts of a jvm?
08:41AWizzArdWhen rhickey joins I will ask him if it could make sense to extend 'proxy' taking a type-designator T, so that hinting can be done via: ^T my-proxy
08:41ChousukeAWizzArd: You shouldn't typehint the proxy by its class; that's frafile.
08:42Chousukefragile
08:42ChousukeAWizzArd: what you want to do is typehint the proxy as whatever its superclass is
08:42Chousukeso if you proxy FooClass, Typehint the proxy as FooClass
08:43AWizzArdChousuke: that unfortunately does not work they way I did it. My proxy proxies an AbstractTableModel. That is a class, implementing TableModel. It does not offer a method to delete all rows from a table.
08:43bsteuberAWizzArd: yeah just typehint it as AbstractTableModel
08:43AWizzArdSo I added a definterface that defines 3-4 methods that are useful. My proxy also implements that interface.
08:43bsteuberah
08:43Chousukethen you can typehint it as that interface.
08:43AWizzArdWhen I now say: (.clearTable ^AbstractTableModel my-table-model-proxy) <-- it can't find the right thing.
08:44AWizzArdYes, I currently do this, and type-hint it as the interface. But in Java or with defrecords this would not be required.
08:44AWizzArdI can type-hint instances as designated.
08:44bsteuberwhy do you need a type hint anyways?
08:44Chousukeneither java nor defrecord can redefine methods on the fly.
08:45Chousukeproxy works as it was designed, not having access to its classname for typehinting is a feature :)
08:45AWizzArdbsteuber: to remove the type-hint warning that Clojure generates for me. My question in general is the other way around: why not type-hint everything?
08:46AWizzArdChousuke: in Java the way would be to have class MyTableModel extends AbstractTableModel { ... }
08:46AWizzArdAnd in MyTableModel I could simply define 3-4 helper methods.
08:46ChousukeAWizzArd: yes, and that's nowhere as dynamic as proxy is
08:46Chousuke+near :P
08:46Chousukeany changes require a recompile
08:47Chousukebasically you're asking proxy to do things it wasn't designed for
08:47AWizzArdChousuke: can you give me an example of what you mean by 'dynamic'?
08:47bsteuberAWizzArd: change a method on the fly
08:47ChousukeAWizzArd: you can replace proxy methods with a new implementation at runtime, without having to touch existing code in any way.
08:47AWizzArdChousuke: there is no other lightweight way in Clojure to do this, as defrecord and deftype and reify can only take interfaces, but AbstractTableModel is a class unfortunately.
08:47fogus`Someone is wrong on the Internet!
08:48ChousukeAWizzArd: Then you need to use gen-class
08:48AWizzArdbsteuber: would that not be possible with an anon class in Java too?
08:48AWizzArdChousuke: yes, though this is not very lightweight anymore. More chatty syntax.
08:48Chousukethen write a macro :P
08:49bsteuberAWizzArd: can you change a method of an existing anonymous class? I don't think so
08:49AWizzArdIdeal would be a defrecord that could also take classes, or even more ideal: not one single Java class implements any method on its own, but *always* from interfaces. Then defrecord would always work. :)
08:50AWizzArdbsteuber: I currently don't see an application for that. But it may be very well much more chatty in Java to do this (via Bytecode generation *shrugs*).
08:50ChousukeI think defrecord allowing classes would break the data/behaviour separation.
08:50AWizzArdyes
08:50Chousukeso it's out of the question :)
08:50AWizzArdYes
08:50AWizzArdIt makes sense the way it is.
08:51AWizzArdOnly that it not operates well with the VM Clojure is running in.
08:51ChousukeI don't see a problem
08:51AWizzArdBecause Sun chose to add methods to classes that do not come from Interfaces.
08:51ChousukeGood java APIs are based on interfaces anyway
08:51Chousukethere are bad ones, but you just have to accept that.
08:51AWizzArdBut many Java APIs are not good ;)
08:52Chousukeyeah, and in those cases, just use gen-class :P
08:52AWizzArdAlthough this does not in its current version allow me to add fields as in defrecords?
08:52AWizzArdI can only have a :state which would be an atom or ref, which is way less performant when accessed.
08:53Chousukeit can also be a plain old mutable java object.
08:53AWizzArdChousuke: does defclass allow multiple slots or only one :state slot? I am not sure what the current state of it is.
08:54ChousukeI've no idea, I've never actually used it :P
08:54AWizzArdInteresting it would be if defclass worked like defrecord in that aspect.
08:59cemerickAWizzArd: defrecord and deftype are not intended to be fully-featured interop constructs
09:00AWizzArdAnd this makes sense.
09:00AWizzArdThey are serving a great purpose.
09:00AWizzArdIt is just the design of the main VM Clojure is currently running on which can cause sometimes a bit pain, which would go away if defrecord/deftype actually allowed to extend a class.
09:01AWizzArdcemerick: a better solution would be that *all* methods that any Java class defines in all cases would be an interface method.
09:01cemerickRight; well, that ship has sailed. :-)
09:02AWizzArdThis would of course bring tons of one-method interfaces into the game, but this would reflect the design style that Rich found to be better, and which he now implemented in Clojure.
09:02AWizzArddefrecords are just classes providing slots, with all methods coming from interfaces (protocolls). Sun however didn't.
09:03AWizzArdSo, when implementing ones own TableModel one has to chose: AbstractTableModel+proxy or TableModel+defrecord. The latter will require more work, as nothing would be implemented, as in the AbstractTableModel case.
09:06cemerickAWizzArd: why is the proxy route insufficient?
09:07jcromartiewhat's the best way to manage 3rd-party jars that can't be added to clojars for licensing reasons?
09:11cemerickjcromartie: ideally, have your own nexus or artifactory instance
09:11jcromartieI used http://maven.apache.org/plugins/maven-install-plugin/usage.html for a temp fix
09:11jcromartiebut yeah
09:13neotykHas anyone working version of slime-who-calls?
09:20Raynesfliebel: Seems to be fine.
09:21fliebelRaynes: Huh?
09:21Raynesfliebel: The blog.
09:21Raynesfliebel: I just checked and it's still up.
09:22fliebelRaynes: It's a http://www.acidrayne.net/ right?
09:22fliebelSafari can't find the server
09:22RaynesNo.
09:22Rayneshttp://blog.raynes.me
09:22LajlaUsing a mac counts as admission to flaming homosexuality under US law.
09:22fliebelRaynes: Then update your github and twitter page ;)
09:26fliebelRaynes: Wordpress, eh? Also, page_id=2 (a.k.a. About) is rather terse compared to the huge posts you write.
09:27RaynesWhat would you prefer I use over wordpress?
09:28fliebelWordpress is great, but something in Clojure would be nice, I guess. :D And if you must use WP, I recommend at least turning on permalinks ;)
09:29RaynesI don't really have any inclination to roll a blog in Clojure that wouldn't be even 10% as impressive as a default wordpress blog.
09:29bobo_Raynes: steal Lausjensens blogstuff?
09:29fliebelAgreed.
09:30RaynesI'd rather not.
09:30RaynesI actually don't mind wordpress.
09:30pppaulit's a blog, what's the big deal about what it runs under/
09:30bobo_i like the github stuff. because im lazy and it jsut worked
09:31jcromartieI cheated https://gist.github.com/731839
09:31pppaulunless you want to extend it...
09:31RaynesI'm in the process of writing a Clojure interface to wordpress and eventually various other engines and after that a desktop blogging client, so I have a reason to stay with Wordpress for now.
09:31pppaulsounds good
09:32fliebelRaynes: Wordpress is totally cool, but taking the time to configure and customize it does show of ;) You know how to do permalinks?
09:32RaynesNo, because I never cared about permalinks. I'm very good at google.
09:33fliebelRaynes: You prefer ?p=48 over /some-nice-title/?
09:33RaynesIt's shorter, more twitter-friendly.
09:34fliebelRaynes: You can get wp.me urls for every single page.
09:34RaynesI don't have to without permalinks.
09:37fliebelRaynes: Well, I like the fact that you do it as a consideration rather than just neglecting it. (You know you can set a custom permalink under the title field? so you can have /sexpbot/)
09:38RaynesIndeed.
09:40AWizzArdbsteuber and Chousuke: I just noticed that when my proxy proxies a class C and an interface I then for instances P of my proxy I can not ^C P or ^I P. So, type-hinting just won't work for such proxies it seems.
09:40fliebelRaynes: I just can't stand it thoug… hmmm, do you realize /48/ would be even shorter *and* more stylish?
09:41jcromartiefliebel: only ubergeeks and marketing people care about URLs
09:41fliebeljcromartie: Count me under geeks
09:41jcromartiefliebel: although Raynes' audience is ubergeeks
09:41Raynesfliebel: Well, nobody is forcing you to read it.
09:42Lajlafliebel, now you have admitted your famling homosexuality.
09:42LajlaNow what?
09:42LajlaAdmit it, you support Assange
09:42Lajlain his crimes against the freedom of the US
09:44fliebelLajla: Any interesting Clojure gotchas recently? ;)
09:44Lajlafliebel, you should know by now that I would never sell my soul to the darkside of lack of TCO.
09:46fliebelLajla: Total Cost of Ownership?
09:47Lajlafliebel, tail call optimization
10:03garytr25hmm, wouldn't you rather know when tail call is happening explicitly?
10:05lyonscfHey guys
10:06edwgarytr25: No. As someone who comes from a Scheme background, Clojure's (understandable) lack of TCO is like dealing with someone you love believing in astrology.
10:07garytr25you should love them for who they are, not who you want them to be :-)
10:08edwRight, that's why I really like Clojure, but I'll like her a lot more when she quits smoking.
10:09lyonscfWhat's the best way to traverse a map?
10:09lyonscfWell, it's a map of maps
10:10fliebelHm, what's that function called that is like map for nested sequences?
10:10lyonscfso I want to iterate over each element and take a couple of vals out of it and put it into a new list of maps
10:10fliebellyonscf: A map is just like a seq of key-value paris when traversing.
10:10edw(map identity (sequence {:a 1 :b 2 :c 3}))
10:11edwfliebel: zip?
10:14Raynesfliebel: clojure.walk/postwalk?
10:14lyonscfedw: could you perhaps break that down for me.
10:15tonyl&(map identity {:a 1 :b 2 :c 3})
10:15tonyl,(map identity {:a 1 :b 2 :c 3})
10:16clojurebot([:a 1] [:b 2] [:c 3])
10:16tonyl$google sexpbot
10:16fliebelRaynes: Probably, but I thought it was in core.
10:16Raynestonyl: sexpbot is down for a little bug fixing.
10:16tonylRaynes: :( ok
10:22Raynestonyl: I try to do this sort of thing late at night when everyone is asleep, but I actually slept through the night last night.
10:23tonylno worries, I take my sleeping seriously as of lately
10:26jcromartiehow do I create a Java vVector from a Clojure vector?
10:26jcromartieVector
10:27chouseryou're sure you need to?
10:27jcromartieI'm creating a JTree
10:27jcromartieand I figure the simplest route is the constructor that takes a vector of nodes
10:27jcromartiebefore I go making a proxy
10:28chouserClojure vectors are java.util.RandomAccess, java.util.Collection...
10:29chouserbut if you need to, ## (doto (java.util.Vector.) (.addAll [1 2 3 4]))
10:29sexpbot⟹ #<Vector [1, 2, 3, 4]>
10:30jcromartiehm
10:30jcromartielooks like to-array will work, there's an array constructor
10:47edwWhen I `lein repl' I get "Warning: problem requiring hooks: java.lang.IllegalAccessError: extract-javac-tasks is not public (javac.clj:1)". On Ubuntu 10.04 w/ Sun's JDK. Any ideas?
11:34BahmanHi all!
11:35tonylhello Bahman
11:37BahmanHi tonyl!
11:43Raynes&(+ 1 (- 2 (* 3 (/ 4.0 10))))
11:43sexpbot⟹ 1.7999999999999998
11:43RaynesYay!
11:43fliebelRaynes: What was that about?
11:43tonylsexpbot is up
11:43fliebelYay indeed!
11:44garytr25(+ 1 2 3)
11:44clojurebot*suffusion of yellow*
11:44garytr25&(+ 1 2 3)
11:44sexpbot⟹ 6
11:44garytr25nice!
11:45edwWhat's that first character sexpbot emits? A right-pointing arrow? A double-lined right-pointing arrow?
11:46garytr25yea
11:46garytr25(fn [] (+ 2 3 4))
11:46garytr25&(fn [] (+ 2 3 4))
11:46sexpbot⟹ #<sandbox6366$eval8383$fn__8384 sandbox6366$eval8383$fn__8384@8c0d5d>
11:47garytr25&((fn [] (+ 2 3 4)))
11:47sexpbot⟹ 9
11:47garytr25neato
11:47garytr25&(def x 5)
11:47sexpbotjava.lang.SecurityException: You tripped the alarm! def is bad!
11:47garytr25haha ok
11:49luciantry let :)
11:52garytr25&(let [x 5] ((fn [y] (+ y 1)) x))
11:52sexpbot⟹ 6
11:53fliebelCan anyone tell me how I can make a protocol extend a final java class? Or anything else for that matter. stuartsierra said it to be possible, but I can't find anything about "protocol inheritance"
11:53fliebelhttp://groups.google.com/group/clojure/browse_thread/thread/0241042e15696cc9/256f6d4f55dd41a0#256f6d4f55dd41a0
11:57kotarakfliebel: (extend-type YouFinalClass YourProtocol (funA ...) (funB...))
11:58kotarakfliebel: there is no "protocol inheritance" but you can mix in functionality with mapos
11:58kotarak-o
11:58tonylthis might help http://clojure.org/Protocols
11:59fliebelkotarak: But it think extend makes my final class support my protocol, while I need my protocol to be based on the final class.
11:59kotarakfliebel: exactly. You can't extend final class with more functionality. Or any non-final class for that matter...
12:00kotarakfliebel: you have to patch your clojure version and make Atom non-final. Just as Alyssa suggested.
12:01fliebelkotarak: Then I don't get the point of Stuarts's response. What does he want me to do?
12:01kotarakfliebel: he wants you to write a protocol. Extend it to atoms and your stuff. Then it can serve as a common API.
12:02fliebelI'm not looking to make atoms.fly, if that is what I can do with extend. I need to implement the Atom "interface" rather.
12:03tonylyou need a type for implementation
12:03tonyldeclare a type with the base protocol being the Atom interface and extend the methods
12:03kotarakfliebel: something like this: (defprotocol PAtom (swap! ...) (reset! ...)) and then do (ns your.namespace (:refer-clojure :exclude (swap! reset!)) (:use name.space.containing.protocol))
12:03hiredmanI think that is a bad idea, better make new similar reference types
12:05fliebelAlright, so I can replace or supplement Atom, but not implement it.
12:06kotarakfliebel: you can do (extend-type clojure.lang.Atom PAtom (swap! [this f & args] (apply clojure.core/swap! this f args)) (reset! [this v] (clojure.core/reset! this v)))
12:07kotarakfliebel: then also atoms support your API
12:10fliebelhuh… so I can 'replace' the methods of Atom to do what I want? That feels so much like monkeypatching…
12:11fogus`fliebel: In what way? Atom is not changed.
12:11chouserno, you'd just be using your own functions instead
12:12fliebelchouser: So I'm like shadowing Atom?
12:13chouserfliebel: kotarak is showing you how to explicitly manipulate your namespace so that the names 'swap!' and 'reset!' refer to your own protocol functions instead of the clojure.core/functions
12:14chousercompletely different functions in different namespaces
12:14chousernot quite shadowing because you have to explicitly exclude clojure.core's functions from being put in your namespace.
12:14fliebelchouser: Yea, that sounds better. Just make my own multimethod swap! that does either core swap or custom swap, depending on type.
12:15chouserright, that's what he was showing you, only with a protocol instead of multimethod
12:15fliebeloh, right :) hm, I'll reread
12:45garytr25&(let [[x y] '(5 6)] ((fn [z a] (+ z a 1)) x y))
12:45sexpbot⟹ 12
12:48amalloygarytr25: ##((fn [[z a]] (+ z a 1)) '(5 6))) works too if you're just exploring destructuring
12:48sexpbot⟹ 12
12:49garytr25nice
12:57amalloyand also, '(5 6) is somewhat un-idiomatic; i'd usually use [5 6]. but (let [[x y] [5 6]]) kinda looks less magical, so if you want to be awed go with the quote :)
13:24garytr25programs work best when they look the most magical
13:24Licensernow I've a hard decision: I have a idea for a program (web apploication) and am not sure if I should try to write it in erlang or clojure
13:26amalloyLicenser: it seems like, by asking this question in #clojure, you've predetermined what answer you'd like to get
13:26Licenseramalloy: yes that is why I am tricky and also asked in #erlang :P
13:27Licensernow I can paralellize my decision making process
13:27Licenserand since both erlang and clojure are good for paralell stuff I think it fits
13:27amalloyLicenser: see what #fortran thinks
13:27garytr25clojure doesn't do message passing stuff like erlang
13:28Licenseramalloy: good idea
13:28garytr25you might have to do more work to scale it up?
13:29Licensergarytr25: yes that is a + for erlang
13:30raekgarytr25: don't forget to take a look at the goodies in java.util.concurrent
13:30raekehr, Licenser: I mean
13:30raekgarytr25: sorry
13:31Licenserraek: *nods* I know that clojure does very well with concurrency
13:31Licensermy problem is I want to learn more aout both languages but am not sure which to choose here
13:32raekI'm preparing a mini-talk for the local clojure meeting about that stuff
13:32Licenserraek: web dev or concurrency?
13:33raekjust want to make sure that people do not ignore the java stuff that clojure treats as "fully working, no extra wrappers required"
13:33raekLicenser: concurrency. but my last one was about web dev
13:34Licenserraek: happen to have slides to look at? :P
13:34Licenserhmm I could make a compromise and use both
13:35Licensermaking it even more complicated
13:35raekvery very mini... so no slides
13:36raekhttps://github.com/raek/lcug-guestbook
13:37Licenserkk
13:37Licenserwas just curiose
13:37LicenserI get to cry since I can't use lein on my work PC fracking proxy's!
13:41Licenserokay the guys in #fortran were the most convincing - time to learn fortran
13:48garytr25i've heard you can write fortran in any language
13:52bartjI have a 10GB json file...any tips on how to go about reading it lazily?
13:53fliebelbartj: Write a json zipper? Hmm… Or strip the root element and read the sub elements.
13:53hiredmana single json object?
13:54hiredmanyou can't read a single json object lazily
13:54chouserreally?
13:54hiredman[ … 10 gigs … ]
13:55hiredmanthe object goes from [ to ]
13:55hiredmanthats readinga clojure form lazily
13:55Licenseryou could query the contens laziely
13:55chouseryeah, but that could be represented as a lazy seq
13:55fliebelhiredman: Make it a zipper, and you can only read [ and then go depth first and such...
13:55hiredmanfliebel: but thats not structured data
13:56cemerickjson array elements could be read lazily, but object (maps), not so much.
13:56hiredmanmaking a zipper out of a sequence of characters makes very little sense
13:56bartjmy first idea was to use (read-json...) but that returns a PersistentArrayMap which doesn't implement ISeq (I think)
13:56cemerickI guess you could do k/v pairs *shrug*
13:57fliebelcemerick: everytime do do z/down you only need to read up ot the next [ or { if I'm correct.
13:58cemerickfliebel: pairing zippers with IO seems like a disastrous idea…
13:58cemerickbartj: jackson lists "streaming" as a feature, you could give it a try: http://jackson.codehaus.org/
13:59jolyzipper would be on the JSON parse tree, which reads more characters from IO as needed?
13:59fliebelcemerick: Why? Do zippers need to be side-effect free? What about the xml zipper?
13:59cemerickholy crud, a 418-class JSON parser :-O
14:00bartjcemerick, it didn't cleanly build on the first try...so kind of looking for alternatives
14:00cemerickbartj: it's widely-used -- isn't it in central or some other repo?
14:01hiredmanjackson does smile too
14:01cemerickfliebel: c.c.zip-filter.xml, you mean? It operates over a fully-realized XML data structure.
14:01hiredmanclj-json is built on jackson
14:07bartjthank you all for the flurry of enthusiastic replies
14:07bartjI think I am going to jackson a shot once again
14:07bartj*give
14:07chouserc.c.lazy-xml lazily parses xml. It can be done.
14:08chouserI can't think why it couldn't be done for JSON similarly
14:10fliebelchouser: I agree :)
14:11chouserif you wanted the json objects and arrays to be represented by vanilla collections, that would be a problem
14:12chouserbut something that implements java.util.Map and something else that implements java.util.RandomAccess to represent objects and array respectively could certainly consume the input stream lazily
14:12fliebelchouser: So what do you propose?
14:12fliebelchouser: What about lazy seqs or zippers?
14:13chouserlazy-xml ignores the problem that you end up with the whole thing in memory if you read all the way to the end
14:13chouserif that's a problem you'd have to do something more clever there.
14:13fliebelchouser: Even if you doseq?
14:14chouserlazy-xml returns lazy externally immutable objects, like lazy-seq, that cache their values to allow random access
14:14chouserwrapping those in a zipper works just fine
14:15chouserand walking that zipper with zip-filter also works fine. :-)
14:15fliebelawesome
14:16chouserbut I have no recommendation for JSON, just suggesting it should be possible
14:19fliebelI remember someone mentioning a 2-way parser language, with something called lenses, anyone knows?
14:20fliebelah http://www.seas.upenn.edu/~harmony/
14:23fliebelBefore you can say 'supercalifragilisticexpialidocious' and after I finish a dozen other projects, I'll come up with an awesome lazy bidirectional Clojure parser framework.
14:26cemerickmy point before re: zippers and IO was that, esp. in a situation where you've got a large data source involved, you will inadvertently allocate and retain indeterminately.
14:27cemericki.e. z/left may cause you to hoover up a gig of data, and worse, not release your prior loc's contents
14:29fliebelcemerick: I'm not sure I get your point.
14:30amalloyfliebel: if you use a zipper to wrap some laziness around your IO, you'll have a hard time understanding/predicting what zipper operations will cause IO
14:30fliebelTrue, they might return instantly, or take a long time.
14:31amalloyfliebel: more importantly, zippers are complicated and i wouldn't be sure how much data they kept in memory
14:32fliebelBut any lazy implementation of JSON is unpredictible in the amount of IO that is involved per item.
14:33cemerickfliebel: The point is that you don't have a choice as to what is retained by a zipper.
14:33cemerickIf you're really working with large datasets, that's a problem.
14:34fliebelright...
14:35cemerickI'm not saying that zippers over e.g. lazy-xml don't work, but I'd be nervous about using them in cases where the laziness is there for a "good" reason.
14:36fliebelSo what you're saying is that it's fine for doing lazy stuff, but not fro being lazy for the sake of not having 10gb of ram :)
14:37amalloyfliebel: have you considered tracking down the sadist who wrote a 10GB json file?
14:39cemerickamalloy: these things happen…
14:39brehautusually from big slow moving corporations who arent tech companies
14:44cemerickI'm not sure being a "tech company" helps any if you've got to move NN gigs of data from here to there.
14:45brehautcemerick: sure. but non-tech companies can turn NN megs of data into NN gigs of data
14:45cemerickah; yeah, that can happen :-)
14:45brehautthrough liberal application of new buzzwords they dont understand :)
14:46brehauti learnt a lot about python's itertools and lazy evaluation working with that
14:58rata_hi all
14:58rata_has anybody used counted-sorted-sets to store maps?
14:58rata_chouser: do you know of a good comparison fn for storing maps in counted-sorted-sets?
14:59chouserdepends on how you want it sorted, I suppose
15:02rata_chouser: I don't really want it sorted... I'm just concerned with fast nth, disj and conj
15:03rata_(nth is for rand-nth)
15:03chouseroh. hm... so like hash, but guaranteed unique. bleh.
15:06rata_mmm... do you mean using hash like (compare (hash m1) (hash m2))?
15:12rata_chouser: ^
15:14dnolenhmm man I really want real TCO. There isn't a good guide on how to convert mutually recursive tail fn calls into a lazy sequence is there?
15:14hiredmandnolen: trampoline is kind of nice
15:14chouserrata_: right, but hash isn't guaranteed unique
15:15ckydnolen: I'd say you should use SRFI 41, but, that's for Scheme only. :-P
15:15hiredmanI also would love some TCO
15:15dnolenhiredman: yeah but it's too slow.
15:15hiredmaninfact, just this morning I said "all these jsrs and no tco"
15:16dnolenhiredman: I've been hacking away at this miniKanren impl, and it's pretty sweet. But it's incorrect, it has stack overflow errors on certain orderings because the Scheme impl assumes TCO.
15:16hiredman:/
15:16ckyhiredman: http://blogs.sun.com/jrose/entry/tail_calls_in_the_vm
15:16hiredmanI know
15:17ckyhiredman: (This is all in the future tense, as far as I know.)
15:17hiredmanby "all these jsrs" I was refering to the ones listed for java 7 and 8
15:17ckyhiredman: Heh.
15:19dnolenfor example is this safe? https://gist.github.com/732343
15:19dnolenif so I think I can do what I want.
15:20Chousukelooks safe to me
15:20dnolen*sweeeeeeeeeeeet*
15:20Chousukethe functions always return before the recursion happens.
15:20dnolengod bless rhickey
15:29chouserdoes java have a foreach?
15:29brehautchouser: something like it since 1.5 i think
15:30cemerickfor (String s : someIterable<String>) { … }
15:30chousercemerick: thank you!
15:34ckyJava's for-each loops aren't as cool as for-each in real languages, though. For example, you can't iterate through multiple iterables simultaneously.
15:35cky(Which is something I often find a use case for, and for which I've ended up having to write manual loops instead).
16:11jaleyhi everyone. can macros be overloaded on arity too?
16:12dakronejaley: yep
16:13jaleydakrone: thought so... and is it a sensible way to support optional arguments?
16:14dakronedepends, you could use '& args' also
16:14jaleydakrone: yeah but it'll be nicer for the call if the optional arg goes in the middle... :/
16:15cemerickjaley: keyword args to the rescue?
16:15dakronewhy? normally options args go at the end
16:15dakroneyea, or pass a map
16:15jaleydakrone, cemerick: i'm aiming for (with-response r body) and (with-response r validator-fn? body)
16:16jaleydakrone: at least i think it'd be nicer if the body part was always at the end, as it's potentially long?
16:16tonylyou can use arity with that
16:16tonyl2 args or 3 args
16:17dakronefor that, arity seems easiest
16:17jaleytonyl: right, that was my thinking, but for some reason by 2 arg version calling the 3 arg barfs with "wrong number of args (3) ...
16:17tonylwhat is the implementation that you have?
16:18amalloyjaley: probably wrong syntax for arity overloading?
16:18jaleyamalloy, tonyl: right i suspect so, but i wasn't sure if what i was doing was even the right approach so i wanted to check :-)
16:18amalloy(defmacro stuff ([a b] b) ([a b c] (+ c b)))
16:18dakronejaley: (defmacro foo ([a] a) ([a b] [a b]))
16:19amalloyyour error sounds like you did something more like (defmacro stuff [a b] b [a b c] (+ c b))
16:19jaleylet me pastebin it, i'll be 1 minute...
16:21jaleybroken: http://pastebin.ca/2013238
16:24fliebelHow many lines of code do you usually (re)produce in one day? I find it much harder to estimate time than LoC for a task. I was wondering if LoC is something reasonably constant. Inspired by a quote that all coders average at around 10 lines of code per day, where good coders spend more time thinking and bad coders on trial and error.
16:24amalloyjaley: the 2-arg version needs a `
16:25brehautfliebel: i dont think you can ever turn LoC into a meaningful metric
16:25jaleyamalloy: d'oh! thank you!
16:26zztrfiebel: +1 what brehaut said
16:26amalloybrehaut: it is a meaningful metric for, eg, estimating how big a hard drive to put on your vc server...:)
16:26brehautamalloy: hah
16:27tonylis there a way to know if a form is a macro?
16:27amalloy&(meta #'or)
16:27sexpbot⟹ {:macro true, :ns #<Namespace clojure.core>, :name or, :file "clojure/core.clj", :line 705, :arglists ([] [x] [x & next]), :added "1.0", :doc "Evaluates exprs one at a time, from left to right. If a form\n returns a logical true value, or returns that value and does... http://gist.github.com/732440
16:27Raynes&(meta for)
16:27sexpbotjava.lang.Exception: Can't take value of a macro: #'clojure.core/for
16:27Raynes&(meta #'for)
16:27sexpbot⟹ {:macro true, :ns #<Namespace clojure.core>, :name for, :file "clojure/core.clj", :line 3582, :arglists ([seq-exprs body-expr]), :added "1.0", :doc "List comprehension. Takes a vector of one or more\n binding-form/collection-expr pairs, each followed by zero or mor... http://gist.github.com/732442
16:27amalloyRaynes: too slow
16:27Raynesamalloy: Damn. I was too slow.
16:28RaynesAnd again.
16:28Raynestonyl: ##(:macro (meta #'for))
16:28sexpbot⟹ true
16:28amalloy&(-> for var meta :macro)
16:28sexpbot⟹ true
16:28RaynesMine is shorter.
16:29RaynesArguable more readable. Wanna fight about it?
16:29tonylthanks, I didn't know there was metadata for that
16:29Raynestonyl: A lot of core stuff even has line numbers in metadata.
16:29RaynesThat's how the $source command works.
16:30tonylwow nice to know
16:30amalloyRaynes: defn/defmacro include line numbers in the meta automatically
16:31Raynesamalloy: I assumed. Too bad def doesn't.
16:31fliebelSo source just fetches those lines? I thought it'd be something with getting the actual datastructure that was used to produce it.
16:32Raynesfliebel: Naw, source just looks at the metadata and links to the line on Github.
16:32amalloy$source source
16:32sexpbotSource not found.
16:32fliebelRaynes: Oh, I was thinking about ##(source source)
16:32sexpbotjava.lang.Exception: Unable to resolve symbol: source in this context
16:32Raynesfliebel: Oh, right.
16:33amalloy&(use '[clojure.repl :only [source]])
16:33sexpbot⟹ nil
16:33amalloy$source source
16:33sexpbotSource not found.
16:33amalloy&(source source)
16:33sexpbot⟹ Source not found nil
16:33amalloybah
16:33fliebelsource uses source-fn, which in turn does not have a source
16:35fliebelhttps://github.com/richhickey/clojure/blob/master/src/clj/clojure/repl.clj#L21
16:37amalloy&(-> clojure.repl/source-fn var meta ((juxt :file :line :source))
16:37sexpbotjava.lang.Exception: EOF while reading
16:37amalloy&(-> clojure.repl/source-fn var meta ((juxt :file :line :source)))
16:37sexpbot⟹ ["clojure/repl.clj" 21 nil]
16:37amalloy&(-> clojure.repl/source var meta ((juxt :file :line :source)))
16:37sexpbot⟹ ["clojure/repl.clj" 43 nil]
16:38amalloywell, i guess it makes sense that the source isn't directly in the meta. i just don't understand why (source) can find source but not source-fn, when they both have line numbers
16:43fliebelI don't think I understand source-fn. How does it figure out how many lines to read? It seems to read up to :line, but then I get lost in Java pushback readers and stuff.
16:46amalloyfliebel: it uses the built-in (read) function to read a single sexp, and as a side effect writes each character it reads to the stringbuilder. then it throws away the sexp it read and returns the string
16:47fliebelamalloy: Ah, the ambiguity! I'm not sure I have found the Clojure read amongst the java.io read methods.
16:48fliebelAh there it is...
16:48amalloyhttps://github.com/richhickey/clojure/blob/master/src/clj/clojure/repl.clj#L40
16:49hiredmanthat is a clever idea, but the implementation isn't so solid
16:50amalloyhiredman: the implementation of source-fn? i agree on both counts
16:50hiredmanproxy and pbr and then wrap it in another pbr?
16:50hiredmanproxy a
16:51fliebelAnd a lot of mutable Java stuff. Not sure it hurts that much in this case though.
16:52amalloyfliebel: bet you $N (for some small N) that it leads to the output of (source) having trailing spaces on occasion
16:53fliebelamalloy: Why would that happen?
16:53fliebelWould be fun to try… map over ns-publics, bind *out* to a string writer, call source-fn and see if it ends with a space.
16:53amalloythe pbr that appends to the stringbuilder can't know if the input stream gets pushed back. it's already appended to the string
16:54amalloyon thinking about it it probably is fine because (read) will never actually have to push back in order to read, but maybe there's some weird structure of source lines that would cause it
17:00bortrebhow do I efficiently subsample a vector?
17:01amalloybortreb: not sure what you mean by subsample. are you looking for ##(subvec [1 2 3 4 5] 2 4)?
17:01sexpbot⟹ [3 4]
17:01bortreblike, if I have a 25,000 vector and I take every 10th one to get a 2,500 vector
17:02fliebelamalloy: ##(not-every? identity (map #(.endsWith (or (source-fn (key %)) "") " ") (ns-publics 'clojure.core)))
17:02sexpbotjava.lang.SecurityException: You tripped the alarm! ns-publics is bad!
17:02amalloybortreb: take-nth probably isn't efficient since it falls back on treating the vec as a seq
17:04jdrannbauer,(hash-map :a :b :a :c)
17:04clojurebotjava.lang.IllegalArgumentException: Duplicate key: :a
17:05amalloy&(vec (take-while identity (map [1 2 3 4 5 6 7 8 9] (take-nth 2 (range)))))
17:05sexpbotjava.lang.IndexOutOfBoundsException
17:05jdrannbauerHmmmmm... Anyone know why the docs suggest that I can supply duplicate keys to hash-map but it throws an exception if I do?
17:06amalloy&(doc hash-map)
17:06sexpbot⟹ "([] [& keyvals]); keyval => key val Returns a new hash map with supplied mappings."
17:06amalloyjdrannbauer: where are the docs that make you think you can do this?
17:07jdrannbauerGood question. Saw it at this url: http://clojuredocs.org/clojure_core/clojure.core/hash-map. usually a good reference.
17:07amalloybortreb: anyway i think the answer will be vaguely like what i did above. use the vector as a function, and call it with the indexes you want
17:07bortrebah
17:07amalloyjust make sure you don't call it with bad indexes
17:08bortrebit's just (vec (map v (range 0 (count v) n))) to so subsampling because count is fast
17:09amalloyjdrannbauer: whoa that must be old
17:09amalloybortreb: oh, sure
17:09jdrannbauerAh! Cool. Too new to clojure to have noticed. Thanks for the heads up!
17:11jdrannbaueramalloy: Is there a sugary way to do what I am looking for? I want to convert [:a "b" :a "c"] to {:a "c"}
17:11amalloyjdrannbauer: ##(into {} [:a "b" :a "c"])
17:11sexpbotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Keyword
17:11amalloyjdrannbauer: ##(into {} (partition 2 [:a "b" :a "c"]))
17:12sexpbotjava.lang.ClassCastException: clojure.lang.Keyword cannot be cast to java.util.Map$Entry
17:12amalloybahhhhh
17:12hiredman,(apply hash-map [:a "b" :a "c"])
17:12clojurebotjava.lang.IllegalArgumentException: Duplicate key: :a
17:12hiredmanno kidding
17:12chouser,(into {} (map vec (partition 2 [:a "b" :a "c"])))
17:12clojurebot{:a "c"}
17:12chousermeh
17:12amalloyah right, map vec. thanks chouser
17:12fliebelchouser: I'm to slow, was about to try that.
17:13chouserI wouldn't call it sugary
17:14chouser,(let [v [:a "b" :a "c"]] (zipmap (take-nth 2 v) (take-nth 2 (next v))))
17:14clojurebot{:a "c"}
17:14jdrannbauerThanks everybody. Not as sugary as I was hoping but does exactly what I need.
17:15fliebelsomething like this.. but it doesnt work yet,,, maybe I'm stilll fast enough (reduce into {} (partition 2 [:a 1 :a 2]))
17:15jdrannbauerchouser: oooh, that's pretty cool.
17:16jarpiainbortreb: you could do something like this if you need the vector interface: https://gist.github.com/732529
17:23jaleycan anyone explain the *-suffix naming convention?
17:24cemerickfoo* often indicates a helper fn for a "public" foo fn or macro, or a function that is a variation of a primary foo implementation
17:25jaleycemerick: thanks!
17:31hdI fail to use "mvn clojure:swank" on windows vista, although I'm using the newest versions clojure-maven-plugin:1.3.8-SNAPSHOT and swank-clojure:1.3.0-SNAPSHOT
17:32hdThe error is the same as here http://goo.gl/moVYc
17:33hdException in thread "main" clojure.lang.LispReader$ReaderException: java.lang.Exception: Invalid token: C:
17:34hdCan anybody help?
17:35cemerickhd: I'd post to that thread and ask Mark to clarify where you can find the proper fix (it doesn't look like he explicitly states where a staged release is).
17:36hdI downloaded it from github and installed it from source, but got the same error.
17:36cemerickan even better reason to post. Squeaky wheel, and all that. :-)
17:36hd[INFO] --- clojure-maven-plugin:1.3.8-SNAPSHOT:swank (default-cli) @ m2doc ---
17:36hdException in thread "main" clojure.lang.LispReader$ReaderException: java.lang.Exception: Invalid token: C:
17:36hd at clojure.lang.LispReader.read(LispReader.java:180)
17:36hd
18:35amalloychouser: ##(apply assoc {} [:a 1 :a 2])
18:35sexpbot⟹ {:a 2}
18:35amalloylooks like the sugar jdrannbauer was looking for before he left
18:48javehas anyone got a clojure 1.2.0 applet working, in openjdk?
18:59pdkhow many folks use slime here
18:59pdkdumb q dealing with how to actually send it restarts when it gets an error
19:00shachafpdk: You'll probably have much better success if you ask it than if you ask about asking it.
19:00pdkprobably :p
19:01pdksay if i do M-x slime to start slime
19:01pdkthen in *inferior-lisp* buffer i try putting in something that causes an error like (thisfunctiondoesn'texist)
19:02bortrebhow can I make my objects defined with defrecord print in their own special way?
19:02pdkthen i dunno how to actually input one of the restarts it lists through the buffer so i just sit there :p
19:02pdkclicking on a restart in the list it gives seems obvious but apparently not, etc
19:02tonylb
19:03pdk!
19:03tonylbortreb: implementing the Object.toString method, i think that is how it is
19:03pdkcool beans tonyl
19:03pdkso i can just hit the top row numbers to use the restart of that number too
19:03tonylpressed enter too soon wih t
19:03pdkthough how does it handle entering a restart by name
19:04tonyli don't use slime, sorry i am not
19:04tonyl m
19:04tonylu
19:04pdkb surprisingly enough did something though so it's unintentional help :p
19:04tonyllol
19:06bortrebtonyl: thanks! I just forgot to recompile my namespace
19:08bortreber, actually that doesn't work after all
19:10bortrebyou apparently need to also define the print-method and print-dup multimethods for your defrecord type
19:10bortrebthen it works fine
19:10tonyluh interesting
20:35islondoes anyone know hot to remove all nils from a seq?
20:35islon*know how to
20:35brehaut,(filter identity [1 2 nil nil 3 nil])
20:35clojurebot(1 2 3)
20:36islonthanks
20:36brehautno worries
20:37brehautoh
20:37brehautthat also filters out falses
20:37brehauthow about
20:37brehaut,(remove nil? [nil 1 2 3 nil 4])
20:37clojurebot(1 2 3 4)
20:37brehautthats way smarter
20:38islonyes, my list can't contains falses anyway
20:39jcromartieanybody ever notice some weird buffering issues with lein repl?
20:39jcromartielike, with lots of output, sometimes it hangs and I have to type something in before I get the rest of it
20:39technomancyjcromartie: there were flushing bugs in 1.3; 1.4 is better
20:40jcromartiek
20:41amalloy&(keep identity [nil 1 false 2])
20:41sexpbot⟹ (1 false 2)
20:41amalloybrehaut, islon: ^^
20:41brehautamalloy: nice
20:42islongood
20:42amalloy&(keep last [[1 2] [1 false] []])
20:42sexpbot⟹ (2 false)
20:42amalloykeep is a nice little combo of map/filter
20:50islondoes anyone knows the function that return the intersection of two seqs?
20:55jcromartieislon: have you checked out clojure.set?
20:56jcromartie&(clojure.set/intersection #{1 2 3} #{2 3 4})
20:56sexpbot⟹ #{2 3}
20:56islonjcromartie: thanks, i used clojure.set/difference
21:01aligolehey guys
21:03aligoleanybody here knows how I can overload/ override + to be able to add a number to a list of lists of numbers like (+ 3 ((1 2) (3 4))
21:04jcromartiewhy?
21:04clojurebothttp://clojure.org/rationale
21:04jcromartiethanks, clizzin_
21:04jcromartieclojurebot:
21:04clojurebot#<ClassCastException java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.String;>
21:04jcromartiedurrrrrrrrrr
21:04aligole(+ 3 ((1 2) (3 4))
21:06aligoleraek: do you have a minute?
21:08aligolejcromartie: you asked me? "why"
21:08jcromartieyeah
21:08aduricHi, anyone have any experience with clj-plaza?
21:08aligolesorry
21:08jcromartieI'm not sure what you want to do
21:09clizzin_jcromartie: haha, i was wondering why someone said my name in here
21:09jcromartieheh
21:10aligoleI'm trying to implement a Matlab like thing! and I need to have and add function for matrices
21:11aligolei can write function to do this but it would be more convenient if + could be used to add numbers to all the nubmbers in a list
21:12aduricAnyone know what the error: "[java.lang.IllegalArgumentException] No implementation of method" usually means?
21:12islon,(map + [1 2 3 4] [3 5 6 7])
21:12clojurebot(4 7 9 11)
21:12aligole,(map + [1] [3 5 6 7])
21:12clojurebot(4)
21:12jcromartiealigole: I think that part of the rationale of Clojure is to avoid monkey-patching built-in functions
21:12aligolenot what I need
21:13jcromartieso overriding + is not a good idea
21:13jcromartieunless you wanted to make a special context for it
21:13jcromartielike a macro that replaces + with your own function
21:13jcromartiewhich is what people do to build sub-languages
21:14aligolethat sounds about right, I may need to do that, so I need to define a macro with the same name "+"
21:15aligolecool, let me try it
21:15amalloyaligole: no, just a function named + will be sufficient
21:15jcromartieno
21:15jcromartieI mean sure
21:15jcromartieyou can redefine + in a namespace
21:15amalloyjcromartie was, i think, suggesting you define a macro (replace-pluses)
21:16jcromartieI'm not really suggesting it...
21:16aligole:)
21:16jcromartiefirst I'd suggest using something other than +
21:16jcromartiebecause + means +
21:16jcromartie:)
21:16amalloyheh, yes
21:16jcromartielike vec+
21:16jcromartiethat's clearer
21:16jcromartieI mean
21:16jcromartiematrix+
21:17amalloyjcromartie: i think he actually wants something like scalar+, for adding a scalar to a matrix, but that's his problem
21:17jcromartieyeah
21:17jcromartieyeah if you were going to define a matrix math library, you'd name them in that context
21:19aligoleI like to use + for all adding purposes, I don't see why it is not a good idea. and yes I am making a limited matrix library
21:20aligoleClojure's promis is to let you modify the language to your needs, isn't it?
21:20hiredmanaligole: nope
21:20brehautaligole: thats a really imprecise statement in a lisp
21:21aligolehiredman: WHAT?! why not? isn't it a LISP? I've done this in arc before very easy it was!
21:21hiredmanclojure.core/+ is for fast adding of numbers, if you want a generic addition operator, there is one in contrib
21:21hiredmanright, and look where that got arc...
21:21jcromartieheh
21:22aligoleoh, I didn't know, where in contrib?
21:22jcromartiealigole: by all means, define + in your matrix math lib
21:22jcromartieyou can exclude + from the namespace
21:22jcromartiebut I think you'll get tired of writing clojure.core/+
21:23amalloy&(require '[clojure.core :as [c]])
21:23sexpbotjava.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to clojure.lang.Symbol
21:23amalloy&(require '[clojure.core :as c])
21:23sexpbot⟹ nil
21:23amalloy&(c/+ 1 2 3)
21:23sexpbot⟹ 6
21:23amalloyjcromartie, aligole: ^^
21:24aligolecool
21:24jcromartiewait... sexpbot maintains state for you?
21:24jcromartie&(def x 1)
21:24sexpbotjava.lang.SecurityException: You tripped the alarm! def is bad!
21:24jcromartieoh
21:24aligolebut still I am confused, why I can't have a generic +
21:25aligolehiredman: do you remember where in contrib is that generic +
21:29amalloygeneric-math?
21:30vIkSiThi all
21:30aligolethere is a generic + in generic/arithmatic.clj as well
21:30vIkSiTWhen doing a lein compile, I find that it gets stuck at the "compiling namespace" step
21:30vIkSiTis there a way to see what might be going wrong?
21:30vIkSiT(some sort of a verbose mode, perhaps)?
21:31danlarkinvIkSiT: how long have you waited?
21:31vIkSiTquite some time (ran it for almost 20 minutes)
21:32danlarkinoh gosh, okay that's certainly long enough
21:32vIkSiThehe yeah, i lein compiled and was doing something else
21:32vIkSiTlein compile works fine on another project
21:32vIkSiTtop shows 2 java processes taking 5.3 and 5.2% mem respectively
21:34vIkSiTalso the lib/ size is only 5M, whereas lein works fine for a project with 18M of libraries
21:34aligolehiredman, amalloy, jcromartie: http://clojure.org/multimethods
21:35vIkSiTdanlarkin, ideas?
21:35brehautaligole: multimethods are the exception, not the rule. (partly because dispatch is slower than static fns)
21:36danlarkinvIkSiT: nope :( could be a bug, I suggest reporting it
21:37amalloyaligole: https://github.com/clojure/clojure-contrib/blob/master/modules/generic/src/main/clojure/clojure/contrib/generic/arithmetic.clj
21:39aligolebrehaut: I agree if performance is the first priority, but in my case it is not,
21:40aligoleamalloy: thanks, just was reading that
21:40brehautaligole: sure, then it'll work fine
21:41vIkSiTdakrone, aaah. quick question - how does one compile a (future) function in a file?
21:41vIkSiTI had a variable called (def f (future (myfn params)))
21:41vIkSiTer i meant danlarkin*
21:42danlarkinwhat do you mean how do you compile it
21:42vIkSiTdanlarkin, in the sense - i've got the def within my file, and the function it wraps around basically tails a file (and waits on it).
21:43vIkSiTi'm guessing the compilation process initiated this
21:43vIkSiTmy question is - how would i lein compile code which contains a (future) fn call like this?
21:44danlarkinare you sure you need to be compiling in the first place?
21:44danlarkinI know that's not your question, but I'm obligated to ask
21:44vIkSiTdanlarkin, well, i need to create a JAR for my program so i can deploy it :)
21:45vIkSiTdanlarkin, is there another way btw? (apart from starting a REPL, not sure thats advisable in production)
21:45danlarkinyou don't need to complie clojure to deploy it in a jar
21:45vIkSiThmm
21:46vIkSiTbut lein jar had the same issue
21:46vIkSiTdoes lein jar evaluate the code, perhaps?
21:47danlarkinyeah your problem is the def
21:48danlarkinI assume
21:49vIkSiTI could ping technomancy and check as well..
21:52amalloyvIkSiT: (defs) are necessarily evaluated at compile time, otherwise (defn foo [] x), which expands to (def foo (fn [] x)), wouldn't do anything when you compile
21:52vIkSiTamalloy, indeed
21:53amalloyto prevent this from happening, you need (defn make-f [] (future (myfn params)))
21:53amalloythen when you want to do something with it, call (make-f) to get out a logger
21:55amalloyand make sure that make-f isn't called in the global scope. call it from (-main) or whatever
21:55vIkSiTamalloy, ah
21:55vIkSiTgood idea - let me try that!
21:58amalloyvIkSiT: a pretty general strategy when you don't want something evaluated is to put it into a function :P
21:58vIkSiTamalloy, is -main the only function not eval'd?
21:58amalloyvIkSiT: they're all evaled
21:58vIkSiTamalloy, hehe
21:58amalloybut they're only called if you call them
21:58vIkSiTah but a def when evald will have invoked the future fn..
21:58vIkSiTright
21:58amalloyno
21:59amalloywell yes, a def
21:59amalloywhich is why, as i said, you can't make it a top-level thing. shove it inside a function
21:59amalloy&(future (println 1))
21:59sexpbot⟹ #<core$future_call$reify__5500@3c2bdf: nil>
21:59amalloy&(fn [] (future (println 1)))
21:59sexpbot⟹ #<sandbox6366$eval8635$fn__8636 sandbox6366$eval8635$fn__8636@b579ac>
22:00amalloyonly one of those two things will have printed to the stdout on sexpbot's server
22:00vIkSiTright
22:00vIkSiTthe first one
22:00amalloyright. same is true if you'd lein jar/compile'd it
22:00vIkSiTgotcha
22:01vIkSiTwhew. it works :)
22:02amalloyhurrah. if it didn't, i'd have to re-evaluate my perspective on reality
22:02vIkSiThaha
22:04vIkSiTcouple of questions about reading params from the CLI. right now, I've just defd two global vars (def a) and (def b), and then i read the values from the CLI and (def them from within the -main function
22:04vIkSiTis this general practice in terms of keeping global state?
22:04vIkSiT(for instance, if i want to read/write to a configuration file)
22:06tomojwould be nice to be able to switch between configuration profiles easily
22:07tomojoh, just place a file and read it I guess
22:07amalloyvIkSiT: (def *args* (atom {:a 10, :b 20})) (defn -main [] (swap! *args* assoc :a (read) :b (read))) is the hacky approach i would use
22:07amalloyhaving just one var with all the args appeals to me
22:08vIkSiTah
22:08vIkSiTmakes sense
22:08brehautvIkSiT: using a (couple of) vars are fine if you dont expect them to change
22:08brehautvIkSiT: but if you can just pass the appropriate values through to the real program from -main that is nicer (IMO)
22:09vIkSiTagreed
22:09tomojI think I'll just put some clojure forms in a file and read them
22:09jcromartieis there something weird about defmulti that the dispatch function isn't updated when reloading a namespace?
22:09vIkSiTbut i'm trying to interop with an existing java program
22:11amalloyjcromartie: the old defmethods will stay attched to the original defmulti; to attach them to the new one you'll need to reload the defmethods too
22:11amalloynot sure if that's the problem you're having
22:11jcromartiethe defmulti and defmethods are all in the same ns
22:12amalloyjcromartie: actually this sounds a lot like a problem i had, now that you mention it. i never figured it out; let me know if you do
22:36scottjIs there a fn for (concat (butlast coll) (f (last coll)))?
22:37scottjthis is where a smalltalk method finder would come in useful.
22:44amalloyscottj: i don't think there is, and it would have to be pretty slow. maybe you can modify what you've done to get you to the state where you want this function?
22:58pdklittle pop quiz
22:58pdkif i'm evaling stuff with slime and i write something that would lead to an infinite loop
22:59pdkwhat would you do to kick it in the pants and make it cancel that so you can eval other stuff and get printouts again
23:00scottjyou can try C-c C-c ad infinitum but you'll probably have to kill java proc and restart it.
23:00pdknow i'd need to know how to hook emacs and slime to the new java proc i make without restarting those too :p
23:01pdkso i could keep working seamlessly like nothing happened after the inferior lisp is restarted
23:01pdkin the case of working on a file in slime mode at least
23:03scottjif you use lein swank you just have to M-x slime-connect
23:04scottjalias les='lein swank & sleep 5; emacs-client -e "(slime-connect 4005)"'