#clojure logs

2010-12-01

00:37KirinDaveHuh, that's surprsing to me
00:38KirinDaveIf you say (map str (my-defrecord-thing. 1 2 3)), it says ([:a 1] [:b 2] [:c 3])
00:38KirinDaveBut
00:39KirinDaveIf you str that, it doesn't force it.
00:39KirinDaveI guess because it's a lazy seq, but for some reason I had it in my head that if you str'd it'd force.
02:03Raynes&(str (lazy-seq [1 2 3]))
02:03sexpbot⟹ "clojure.lang.LazySeq@7861"
02:06LicenserRaynes: yes that is annoying
02:06RaynesNot really.
02:06Licenseryes really :P
02:06Raynes&(pr-str (lazy-seq [1 2 3]))
02:06sexpbot⟹ "(1 2 3)"
02:07RaynesIt's only annoying if you don't know that it will happen :p
02:07Licenserno that just makes it barable
02:07Licenserstr of a lazy seq sgould not return some crazy object stuff
02:07Licenser&(str '(1 2 3))
02:07sexpbot⟹ "(1 2 3)"
02:08Raynes&(str #'str)
02:08sexpbot⟹ "#'clojure.core/str"
02:08Raynes&(str (fn []))
02:08sexpbot⟹ "sandbox4199$eval6337$fn__6338@1bcaa83"
02:08Licenserwell worky worky time
02:09RaynesYou work too much.
02:09cpfris this good form for defining local functions? (defn foo [x] (defn bar [y] (+ y y)) (bar x))
02:09Licensercpfr: look into letfn
02:09LicenserRaynes: yes I got promoted :P
02:10cpfrLicenser, so always use let forms for local values?
02:10cpfrnever use def
02:10Licenser*nods*
02:10Licenserthat is the essence yes
02:10Raynescpfr: (let [bar (fn [y] (+ y y))])
02:11Raynescpfr: let names values within the scope of the let. def defines a global var.
02:11Licenser(letfn [(bar [y] (+ y y)] (bar x))
02:11cpfrRaynes, bar doesn't seem to be leaking into the global context in my repl
02:12Licenser&(letfn [(bar [y] (+ y y)] (bar 2))
02:12sexpbotjava.lang.Exception: Unmatched delimiter: ]
02:12Licenser&(letfn [(bar [y] (+ y y))] (bar 2))
02:12sexpbot⟹ 4
02:12Licenserthere we go
02:12Licenseranyway I'm off see you later
02:12clojurebotIt's greek to me.
02:13koning_robothas compojure.http.helpers been taken out? or do I need some other package than just compojure?
02:16Raynescpfr: https://gist.github.com/723101
02:17cpfrRaynes, odd but alright let for local
02:18cpfrtoo much scheming I suppose
02:18Raynesletfn works fine as well, as Licenser alluded to.
02:18cpfrwell I want use letfn only for letrec situations
02:18Raynesletfn is actually your only option for mutually recursive local functions, IIRC.
02:20hiredmantrampoline is the clenched fist in the gauntlet of letfn
03:34lenwhi all
03:35lenwhow do i return the first match of one of the values in a vector with the values in another vector
03:36lenwie (some-func ["t" "r"] ["x" "r") should give back "r"
03:36lenw(some-func ["t" "r"] ["x" "r"])
03:36Rayneslenw: Do they have to be at the same index?
03:37lenwcant seem to think about that in a functinal way and keep getting confused
03:37lenwno any match is good
03:37lenwlike contains? but with values
03:38lenw(some-func ["r" "t"] ["x" "r") => "r"
03:41Rayneslenw: Will either one of these vectors ever contain duplicate elements?
03:42lenwits possible - they are lists of email adresses and users can do the most interesting things
03:46Rayneslenw: I came up with: (defn matches [v1 v2] (some #(some #{%} v2) v1))
03:47Raynesuser=> (matches ["r" "t" "y"] ["x" "y" "r" "e"])
03:47Raynes"r"
03:47lenwRaynes: cool that looks neat - i had not got to nested some !
03:47hoecklenw: sounds like you want a union of those two vectors
03:48lenwhoeck: yes !
03:48RaynesI was thinking that you could just turn the vectors into sets and union them.
03:48hoeck,(clojure.set/union (set [:r :t]) (set [:x :y :r]) )
03:48clojurebot#{:r :y :x :t}
03:48hoeckdamn, I meant a difference :P
03:49hoeck,(clojure.set/intersection (set [:r :t]) (set [:x :y :r]) )
03:49clojurebot#{:r}
03:49hoeckintersection, always getting those wrong
03:49Rayneshoeck: I forget those things all the time. :<
03:49hoeckat least I know the concepts :)
03:49RaynesIndeed.
03:49lenwthank hoeck thats goos stuff to know
03:50Raynes&(set ["a" "a"])
03:50sexpbot⟹ #{"a"}
03:50RaynesThat is why I tried to avoid sets in this case.
03:50bartjI get a wrong number of arguments to concat in the code
03:50RaynesBut it doesn't really matter just to check for matches.
03:51hoeckRaynes: I can't count the times where I have read some complicated code that in fact does just some sort of set operations
03:51bartjbut, no matter what I try during tests, it shouldn't happen because concat works without any arguments too!
03:51bartj, (concat)
03:51clojurebot()
03:51Rayneshoeck: Yeah, I've been making tons of use of the set namespace lately.
03:54raek,(some (set ["t" "r"]) ["x" "r"])
03:54clojurebot"r"
03:54bartjanyone?
03:54clojurebotPlease do not ask if anyone uses, knows, is good with, can help you with <some program or library>. Instead, ask your real question and someone will answer if they can help.
03:55bartjclojurebot is your comment directed at me?
03:55hoeckbartj: can you gist the offending code?
03:55RaynesIt's an automated response. Ignore him.
03:55raekignore clojurebot in this case. you already asked a concrete question.
03:56raekbartj: do you have a gist of the stacktrace?
03:56bartjWrong number of args (2) passed to concat
03:56raek...or a paste of the code?
03:59bartjI am afraid I can't paste the code
03:59bartj(concat list sorted-set)
03:59raek,(concat (list 1 2 3) (sorted-set 1 2 3))
03:59clojurebot(1 2 3 1 2 3)
04:00bartjraek, yes, it works in test
04:00raekbartj: what does (resolve 'concat) return?
04:01RaynesSounds like concat isn't what it should be.
04:01bartjwhoops!
04:01bartjI have a user-defined function called concat
04:01RaynesIndeed. That'll do it!
05:09Raynes$seen fliebel
05:09sexpbotfliebel was last seen quitting 11 hours and 10 minutes ago.
05:09Raynes'bout due for some fliebel action.
05:15fliebelmorning
05:16RaynesHah!
05:16Raynes<Raynes> $seen fliebel
05:16Raynes<sexpbot> fliebel was last seen quitting 11 hours and 10 minutes ago.
05:16Raynes<Raynes> 'bout due for some fliebel action.
05:16RaynesThat 5 minutes ago.
05:16Raynes:)
05:17fliebelI just saw your pull request
05:17fliebelI'm reading now
05:32fliebelRaynes: I'm all for it :) Though it seems it's harder now, or I'm just sleepy :(
05:32Raynesfliebel: It's much harder now. :p
05:33RaynesThe confusing parts are related to avoiding duplicates and removing questions once they've been answered so that the quizes aren't infinite.
05:33fliebeloh, the multiple choice ones are indeed harder, but I was doing name-quiz
05:34RaynesOh, you mean the quizes.
05:34RaynesD'oh.
05:34fliebelyea :P Last time I tried I had like 70%, now I got 50%
05:34RaynesI haven't gone through an entire name-quiz yet.
05:34RaynesI'm scared. :p
05:34fliebelBut yea, the code is also somewhat more complicated.
05:35fliebelRaynes: I didn;t do 100 of them either
05:35RaynesWell, you couldn't before. The quizes never ended!
05:35Raynes:p
05:35fliebelRaynes: Last time I discovered another gem, just as beautiful as the subs thing.
05:35RaynesOooh, do tell!
05:37fliebel&(doc memfn)
05:37sexpbot⟹ "Macro ([name & args]); Expands into code that creates a fn that expects to be passed an object and any args and calls the named instance method on the object passing the args. Use when you want to treat a Java method as a first-class fn."
05:37RaynesOh. That has been deprecated for quite a while.
05:37RaynesIt predates anonymous functions, and they are generally what should be used these days.
05:38fliebelOh :( I quite liked the idea of creating first class functions out of java methods.
05:38Raynes&(meta #'memfn)
05:38sexpbot⟹ {:macro true, :ns #<Namespace clojure.core>, :name memfn, :file "clojure/core.clj", :line 2949, :arglists ([name & args]), :added "1.0", :doc "Expands into code that creates a fn that expects to be passed an\n object and any args and calls the named instance method ... http://gist.github.com/723312
05:40RaynesOdd. I guess it isn't officially deprecated. People have been telling other people that it was and to not use it since I started with Clojure, nearly two years ago.
05:41fliebelSo what would you do instead?
05:42RaynesYou'd use a lambda. #(.toLowerCase %)
05:43harishtellaDoes anyone have tips on debugging clojure? Its hard to debug when i get a single line error with just "cant cast sequence to Ifn" or something like that. I wish clojure could give me a stack trace always. Is the best way to just test each function individually?
05:44fliebelTrue… Though I don't like the idea, and use real functions when possible. memfn would go nicely with partial, comp and juxt.
05:45Raynesharishtella: In an REPL, when it only prints a single line you can do (.printStackTrace *e) to see the stacktrace.
05:45fliebelharishtella: (.printStackTrace *e) on the repl will give you one
05:45fliebeloh to slow :(
05:45Raynes*e is always bound to the last stacktrace.
05:46fliebel$sed Raynes s/stacktrace/exception/
05:46sexpbot<> $sed Raynes s/exception/exception/
05:46fliebelhrm
05:46harishtellaon snap, so much time wasted, lol, thanks
05:46Raynesfliebel: $sed -Raynes ...
05:46Raynesharishtella: You're welcome. :(
05:46Raynes:)*
05:47Raynesfliebel: $sed is a weird command that takes weird options. I've been meaning to make improve it's weirdness.
05:51fliebelRaynes: What do you think about sexpbot + qlojure-quiz? For some competitive multiplayer goodness :) I could probably make that somewhere in the next 10 years… :(
05:52Raynesfliebel: That could be interesting. We could even make a special channel for it.
06:04Raynesfliebel: *number* could possibly be *answers*.
06:04Raynes*target* could maybe be *namespace*, but I haven't given it much thought. *number* is pretty unintuitive now though.
06:04RaynesSince it can be rebound.
06:05Raynescemerick: Morning Mr. Emerick.
06:09cemerickMorning.
06:09cemerickGrump. :-P
06:10Raynesfliebel: One thing I'll note: This application, however simple, will be a very, very useful tool for people in the future. I can't think of a funner way to familiarize oneself with APIs than with clojure-quiz.
06:10RaynesThanks for writing it. <3
06:11Raynescemerick: Have you ever used posterous?
06:12RaynesI've been considering migrating my blog to either it, wordpress.com, tumblr, or something similar.
06:12RaynesJust for the sake of not having to host it myself. I can't think of any good reason to.
06:17cemerickRaynes: I used it for a week or so. wordpress.com is superior in every way AFAICT.
06:18Raynescemerick: I figured that. Is it relatively easy to migrate a self-hosted blog to wordpress.com?
06:18cemerickWP.com has supported Clojure highlighting, which is a pretty big deal, but there's lots of other advantages too
06:19cemerickRaynes: looks like there's an import function in the admin console; sucks in wordpress .wxr files?
06:19cemerickpresumably something that you can generate from a local install.
06:20RaynesNeat. I'll check that out.
06:27cemerickRaynes: if you do join up, you can plug a bug for me :-P
06:27Raynescemerick: ? :o
06:29cemerickRaynes: Their smiley replacement is unfortunately affecting code blocks: http://cemerick.com/2010/05/12/provisioning-administration-and-deployment-of-couchdb-java-tomcat/
06:30RaynesI turned off smiley replacement in my local install. You can't do that in a hosted wordpress? O.o
06:30cemerickThey've fixed other issues I've raised in short order, but that's persisted. I presume it's just a rare enough case as far as they're concerned.
06:30cemerickYeah, you can.
06:31cemerickI guess I hate compromising.
06:31cemerickEspecially when I'm not paying any money for something. :-P
06:31Raynes:P
06:32cemerickoh, actually, I guess I do pay them some small amount for the top-level domain mapping.
06:32RaynesEw. They charge for that?
06:33cemerickYeah. One of the few things they do charge for.
06:33cemerickPosterous is the same IIRC.
06:33RaynesI haven't really looked into either yet.
06:33RaynesI'll probably just continue to self-host in that case.
06:33RaynesI've moved everything to a Linode, so stability shouldn't be a problem anymore.
06:34Raynes$shell uptime
06:34sexpbot 03:34:37 up 2 days, 13:23, 1 user, load average: 0.02, 0.02, 0.00
06:34RaynesTwo whole days so far!
06:34cemerickI'm so done with any kind of sysadmin.
06:35Rayneshttp://blog.selflanguage.org/2010/12/01/first-introspection-2010-12/ This post is very well written.
06:35cemerickI still have one box that isn't under proper automated admin.
06:35cemerickEvery time I log in there, the pain is tangible.
06:36RaynesThe only thing that I've yet to automate on crisis is the startup of znc and sexpbot.
06:52accelIs there any clojure library / app that can do WYSIWYG math editing? (Like Realtime TeX)
07:12bsteuberaccel: some java stuff is listed on http://en.wikipedia.org/wiki/Formula_editor, but I don't think anyone did it in clojure itself
07:17accelya, was looking at that, pity the only really nice one is TeXmacs, which is C++ + guile
07:17accelsomeone ought replae the C++ part with Java and the Guile part with Clojure
07:18RaynesOr replace the C++ part with Clojure and the Guile part with Clojure.
08:37chouserugh, race condition leading to deadlock
08:38@rhickeywhere?
08:38clojurebotwhere is log
08:39chouserrhickey: in my own code. Needed to add a feature to a BlockingQueue, did it with an atom, got burned. :-P
08:39@rhickeyah
08:39chouseris there an existing blocking queue that has the concept of reaching the end of the input and becoming "closed"?
08:42raekchouser: http://clj-me.cgrand.net/2010/04/02/pipe-dreams-are-not-necessarily-made-of-promises/ and https://github.com/raek/stream-seq/blob/master/src/se/raek/stream_seq.clj#L123
08:43raekthe latter is my own rather hackish try to get a closable LinkedBlockingQueue
08:44raekI wrote it during the summer and I would probably not implement it exactly like that if I would write it today
08:45IslonI just learnt that you have to :import and not :use a defrecord...
08:45raekcgrand's blog post basically obsoletes my whole lib...
08:49chouseryeah, I knew of his post, as well as fill-queue in contrib and seque in core
08:49chouserbut none of them are sufficient, at least as they are.
08:50chouserI need to be able to poll the queue without blocking and know whether or not I reached the end
08:53RaynesAw man. I can't find my key. :<
08:54RaynesIslon: That's because a defrecord is just a Java class.
08:55Raynes&(find-my-keys)
08:55sexpbotjava.lang.Exception: Unable to resolve symbol: find-my-keys in this context
08:55RaynesThe one thing that Clojure can't do for me. :<
08:57@rhickeychouser: terminable queues are almost always done with 'poison' messages
08:58chouserrhickey: yeah. for good reason, as I see here staring at the inevitably complex coordination of two separate mutable things
08:59@rhickeyright
08:59chouserMaybe more careful use of a final non-blocking poll will be sufficient.
09:01Rayneschouser: Do you happen to know when the last time you somehow dropped from IRC was?
09:01RaynesDon't think I've ever seen you not here at any given time.
09:03RaynesI remember you asking me if sexpbot's logging would more stable than your irssi a while back, and I told you no. I've moved it to a lovely Linode, so, server Gods willing, I should have pleasant uptime from here on out.
09:05chouserLooks like I rejoined 2010-11-27.log:14:02, 2010-11-20.log:08:14, 2010-11-17.log:00:36, 2010-11-16.log:04:22, etc...
09:07RaynesI hereby declare War of the Logs.
09:07chouserI concede
09:07Raynes:p
10:05fliebelMorning! Thanks to UGT I can now have as many mornings as I want.
10:05hoeckfliebel: Morning, me too :)
10:07RaynesThat's all folks! Final score: Right: 65, Wrong: 35, Percentage: 65
10:07Raynesfliebel: ^ I'm so ashamed. x_x
10:07RaynesThose damned atom questions got me.
10:08fliebelRaynes: I usually lose points on interop. proxy and such.
10:08fliebelAnd of course silly typos and a missing !
10:09fliebelI will try a full run and report...
10:09RaynesThat 100 run took a while.
10:09RaynesYou can do 50 if you bind *number* to 50.
10:09fliebelI know, but that is cheating.
10:10RaynesHehe
10:12fliebelCan I peak at the docs? :D
10:14raekis this some kind of clojure quiz?
10:14fliebelyea
10:14raekis it oline?
10:14fliebelhttp://github.com/pepijndevos/clojure-quiz
10:16fliebelOh, these kill me… rest or next returns nil, can't remeber which one
10:16fliebelwrong :(
10:17raekwhich one of the quizes are you doing? :)
10:18fliebelname-wuiz
10:18fliebel*quiz
10:21raekthe answer to the first question was replicate. I answered repeat....
10:22fliebelHrm, Are those * fns public? It asked for with-bindings*
10:24fliebelThese also feel unfair: find-namespace Incorrect! Was: find-ns
10:27fliebelouch, I'm falling below 50%, due to a lot of small differences, like select vs select-keys and => vs <
10:28fliebels/50/60/
10:28sexpbot<fliebel> ouch, I'm falling below 60%, due to a lot of small differences, like select vs select-keys and => vs <
10:40raekheh, this is fun :)
10:40fliebelwhat's your score?
10:40raekit would be very nice to have a web-based version of this
10:40Raynesraek: Are you running the latest checkout?
10:40raekI haven't played a whole round yet
10:41fliebelraek: I'm thinking of adding it to sexpbot or tryclojure
10:41raekI just looked at it while my code was compiling
10:41raeksince it was C++, I had plenty of time
10:42Raynesfliebel: You could do that. If you wanted, you could even make it into a standalone web application and I'd be happy to host it for you at clojure-quiz.raynes.me or similar. <3
10:43fliebelWhatever is best. I could easily take moustache and ring and make you some, btu tryclojure is already a place to play and leanr clojure.
10:44Raynestryclojure would be an excellent place for it if you can figure it out. I'm cool with it either way.
10:44fliebelI never looked at it.
10:45fliebelDamn, telling reverse/rseq, rest/next, etc is hard :(
10:46RaynesI knew next over rest because next can return nil while rest always returns a seq.
10:46fliebelI knew one of them did this...
10:47fliebeland reverse/rseq has something in constant time.
10:47fliebelbtu which one...
10:48fliebelRight: 64, Wrong: 36, Percentage: 64
10:48fliebelRaynes: Quite close to yours
10:48Raynes"?
10:48Raynes:>*
10:50fliebelI wonder how raek is doing… We really need a score board.
10:52raekI'm compiling again, so I guess I could give it a try... :-)
11:03Chousukehmm, doc-quiz is too easy :P
11:03jaleyhi guys, question on persistent structures and memory usage: when are copies or new instances created? will the hash-map, sorted-map, function always create a full copy of the original data?
11:06Chousukejaley: hash-map and sorted-map are constructors so they can't make use of structural sharing, but remember that all objects are stored by reference, not by value.
11:07Chousukejaley: the "modifying" operators however do share structure with the original object
11:07Chousukeoriginal data structure, rather
11:08jaleyChousuke: cool. so the size of (apply hash-map (map some-fn other-collection)) is going to be size-of-ref * size-of-collection, probably?
11:09Chousukenot sure what you mean by that.
11:09jaleyChousuke: well I just mean create a map from a collection of strings, for example, there will be no more copies of the strings, just references to them
11:09Chousukethere's also some overhead from the actual data structure
11:09ChousukeThat's correct.
11:10jaleyChousuke: awesome, thanks. bang goes that theory on why my app is using >100mb of heap then
11:10Chousukejaley: you might be holding onto a lazy seq somewhere
11:10Chousukepreventing it from being gc'd
11:11Chousukealso any substrings you might use prevent the parent string from being gc'd IIRC
11:11jaleyChousuke: oh that's interesting. I'm using a webservice that returns a massive mangled string that i have to split up
11:12Chousukehmm
11:12Chousukesounds like you might be holding onto the entire string if you're using substrings.
11:15jaleyperhaps... i'll use a profiler and see what object types are occupying the heap, if i can do that somehow.
11:15ChousukeClojure should work just fine with Java profilers
11:16raekfliebel: Raynes: "That's all folks! Final score: Right: 72, Wrong: 28, Percentage: 72"
11:16jaleyChousuke: cool. thanks for your advice, I'll have a look around for a profiler
11:17_na_ka_na_hey guys any idea how to avoid reflection on this piece of code
11:17_na_ka_na_(defn d [coll] (java.util.Arrays/sort (into-array Object coll)))
11:17_na_ka_na_(defn d [coll] (java.util.Arrays/sort (with-meta {:tag "[Object;"} (into-array Object coll))))
11:17_na_ka_na_^ doesn't work
11:18raekwith-meta takes the args in the opposite order
11:18raekalso, you need to add metadata to the code that the complier receives
11:18raeknot to the value in runtime
11:19raek_na_ka_na_: is it the java.util.Arrays/sort call it has to use reflection for?
11:19_na_ka_na_raek: yes
11:20_na_ka_na_raek: you are right about with-meta, reversing the order didn't help either
11:22cemerick_na_ka_na_: you want: (Arrays/sort ^"[Ljava.lang.Object;" a)
11:23raekah, the "L"... that's why my test in my repl didn't work...
11:23cemerickyup, array-of :-P
11:24_na_ka_na_cemerick: thanks it works! (defn d [coll] (java.util.Arrays/sort (let [^"[Ljava.lang.Object;" arr (into-array Object coll)] arr)))
11:24_na_ka_na_any easier way to write ^
11:24Chousuke^objects ?
11:24KirinDaveYeah doesn't ^objects work?
11:25cemerickOh, sure; I figured the Object hint was just a placeholder… :-/
11:25KirinDaveEvery time I see the underlying notation I cringe. :\
11:25_na_ka_na_ya its a placeholder
11:25_na_ka_na_but I mean easier way as in w/o the let
11:26_na_ka_na_it looks ugly
11:26cemerickRight, so if you actually have an array of com.foo.Bar, then you really do need to use the string/hosty hint notation.
11:26KirinDaveI can't help but think there is syntax missing there.
11:27_na_ka_na_this also seems to work
11:27_na_ka_na_(defn d [coll] (java.util.Arrays/sort ^"[Ljava.lang.Object;" (into-array Object coll)))
11:27KirinDaveThat in meta decls, (array-of my.class.Name) sort of thing?
11:27_na_ka_na_is that syntax correct?
11:27cemerick_na_ka_na_: yes, that's fine
11:27_na_ka_na_cemerick: hmm, many thanks
11:29bsteuberdoes anyone have pointers for using clojure-1.3.0-alpha3 with swank?
11:29cemerickKirinDave: the :tag metadata slot can only be a string naming a class in full or a symbol naming a class imported in the current ns, IIRC.
11:29KirinDavecemerick: Right, but that could always be generated.
11:30KirinDavecemerick: I think the bigger problem with that oh-so-reasonable suggestion is that clojure is not a world where lexically scoped syntax extensions are the norm, or popular.
11:30KirinDavecemerick: There's a library to do it, but I have only seen that in use in the wild a half-handfull of times
11:33cemerickTrue enough…though I think we're better off for it.
11:33KirinDaveThe common lisp guys would disagree with you.
11:34cemerickheh, on larger things than this! :-P
11:34cemerickThe case here is an odd one, insofar as nonprimitive and non-Object arrays are relatively rare.
11:34KirinDaveI can see the logic for not allowing symbol macros. The logic of not allowing macrolet does confuse mea little.
11:34KirinDavecemerick: Indeed.
11:35cemerickSome flavour of the latter is in the works, or so I heard rumored.
11:35KirinDaveThat's good. The real place I've seen macrolet used is inside of macros.
11:35KirinDaveSo cemerick, in line with our conversation last night, I've been thinking hard about protocols.
11:36KirinDaveAnd I remembered a question someone on hn asked me about protocols I had mentally shelved.
11:36jweissis there a recommended way to access protected fields of a java class?
11:36KirinDaveSpecifically, someone asked, "How does one go about using the current protocol system to extend existing classes? Can you?"
11:37cemerickjweiss: see the fns in clojure.reflect.java
11:37KirinDaveI think he meant to ask, for example, how one might make a case insensitive string Map or something else like that
11:37KirinDaveWhere there is only an incremental difference from a parent class.
11:39cemerickKirinDave: Protocols can't override or otherwise impact the behaviour of an existing class' implementation.
11:39KirinDavecemerick: Right.
11:39KirinDavecemerick: So youd probably start by using a has-a relationship
11:39KirinDavecemerick: Make an internal field carrying a map and try to incercept mappy calls
11:39cemerickOne can extend a protocol such that it will dispatch as you like for a given type, with an implementation of the fn/method in question.
11:39KirinDaveRight
11:40cemerickYeah, it's a job for proxy.
11:40KirinDaveOh? I didn't know proxy could operate on protocols.
11:40cemerickProtocols have no hand in the task at all.
11:41cemerickTalking about changing behaviour of some extension of a concrete class and defining abstractions that can be extended to existing types never meet.
11:41KirinDavecemerick: Oh, I'm sorry... let me clarify. This is in the hypothetical world where protocols and types rule the roost in joint benevolence with multi-methods.
11:41KirinDaveIn other words, thought-experiment land.
11:41cemerickBut, proxy can certainly participate in protocols by implementing the interfaces they generate.
11:42KirinDaveIn other words, this is thought-experiment land. )
11:43KirinDaveDo you need behavior inheritence elsewhere in addition to these tools 1.2 provides, or are they sufficient on their own.
11:44cemerickSo, if there was a Map *protocol* (rather than simply j.u.Map and c.l.IPM right now), then you could extend the get, assoc, etc fns in that protocol to your concrete existing class and get string-insensitivity on lookups, etc.
11:44KirinDaveRight
11:44KirinDaveSeems like that's a lot of work for incremental changes.
11:45KirinDaveYou couldn't really just do a little bit of it;
11:45KirinDaveYou'd have to do all of it
11:45cemerickRight.
11:45cemerickImplementing core abstractions (like maps, seqs, etc) in terms of protocols is definitely on the drawing board, and it will make a *lot* of fantastic stuff possible, including the above scenario.
11:45KirinDaveRight
11:45KirinDaveI wonder if there is another structure though.
11:45cemerickNot in the near (or even potentially medium-) term though.
11:46cemerickThat's why I mentioned proxy.
11:46KirinDaveA behavior, like scala traits. I understand that this is kinda against charter (which I read over again carefully)
11:46KirinDaveAt the very least, I've got something nearly done for clothesline that lets me write a default behavior
11:46jfields,(get-in {:a :b :c :d} nil)
11:46clojurebot{:a :b, :c :d}
11:46cemerickIf you're really just subclassing an existing impl, proxy will let you do the same sort of gruntwork that hosty subclassing allows.
11:46KirinDaveDoing so was a surprisingly big job
11:46jfieldsreally? get-in with nil returns all the elements?
11:47KirinDaveFor one, you have to make both a static and dynamic version of the behavior.
11:47cemerickjfields: as opposed to?
11:47jfields,(get {:a :b :c :d} nil)
11:47clojurebotnil
11:48jfieldsthat's what I'd expect from get-in as well.
11:48raek,(get-in {:a :b :c :d} [])
11:48clojurebot{:a :b, :c :d}
11:49raekwell, it "follows" zero keys into the structure...
11:49Islonwhere's the "join" or "str-join" function in clojure 1.2?
11:49cemerickjfields: Not sure I follow the expectation. get returns the value mapped to the given key. get-in expects a seq of keys; if you provide it with none, then it gives you what it has.
11:49raekIslon: clojure.string
11:50cemerickIslon: there's also just (apply str …) *shrug*
11:50raek(require '[clojure.string :as str]) (str/join ....)
11:50jfieldscemerick, it makes sense, but I don't think it's the most obvious result.
11:51Islonthanks, i googled it and found lots of different stuff and namespaces
11:51KirinDavecemerick: It might be because #(let [something-outside nil] (get-in {:a :b :c :d} nil ::not-found))
11:51KirinDaveOh, I thought there was a bot listening for #()
11:51KirinDave,(let [something-outside nil] (get-in {:a :b :c :d} nil ::not-found))
11:51clojurebot{:a :b, :c :d}
11:51KirinDaveThat can be a surprising result if it's nested deep in some code and client code passes you something you don't expect
11:51raek,(let [m {:a {:b {:c 0}}}] [(get-in m [:a :b :c]) (get-in m [:a :b]) (get-in m [:a]) (get-in m [])])
11:52clojurebot[0 {:c 0} {:b {:c 0}} {:a {:b {:c 0}}}]
11:52raekI think it follows a clear pattern
11:52cemerickKirinDave: the not-found value isn't involved here
11:52KirinDavecemerick: Right.
11:53KirinDavecemerick: That's the only place where I think it might be surprising, tho.
11:53cemerickoh, I see what you're saying
11:54KirinDaveThe way the docs are written suggests that not-found-val will come up.
11:54cemerickeh, only if a given key isn't present
11:54cemerickif you don't provide any keys, then…
11:54cemerickraek had the progression right
11:54jolyall (0) provided keys are present
11:55cemerickBut then, I'm mostly alone in not really having any issue with Clojure's existing docs. :-P
11:56KirinDaveNo I agree with raek. But I also have been bitten by expecting default values when they were not actually applicable.:)
12:03jaleywhat's the "same instance" equality test?
12:04jaley(i mean which function)
12:07cemerickjaley: you probably mean identical?
12:08jaleycemerick: that's the one, thanks
12:36raekfliebel: Raynes: regarding webification of clojure-quiz, I guess 'quiz' is what needs to be replaced, correct?
12:38raekor are any of you working on this now?
12:42jweissi am using leiningen checkouts directory to add a dependent project. but my classpath only includes checkouts/dep/classes, not checkouts/dep/lib/*
12:42jweissany suggestion what might be wrong
12:42technomancyjweiss: no, that's correct
12:43technomancythe checkouts dir isn't meant to replace :dependencies in project.clj; just to augment it.
12:44jweisstechnomancy: hm, so is there some other way to get the deps in my project other than listing all the dep's deps?
12:44technomancyyeah, just add it to :dependencies like usual
12:45joegallojweiss: that is, you have a dependency on a, and it also happens to be a checkout.
12:45oconnoreHow do I initialize a templated java class? All the java interoperability examples I can find are too simplistic. For example, (new ArrayList<Integer>) doesn't work.
12:45jweissi don't think i've ever added a project as a dependency before, just libs from repos
12:47technomancythere's really no difference
12:48technomancyif the project hasn't been uploaded to a public repo then you'll need to "lein install" it first; that's all
12:50jweisstechnomancy: ah ok that is the step i was missing, thanks
12:56oconnoreanyone?
12:56clojurebotPlease do not ask if anyone uses, knows, is good with, can help you with <some program or library>. Instead, ask your real question and someone will answer if they can help.
12:56oconnoreDear clojurebot, I already did that you cheeky bastard :P
12:57jfieldsoconnore, if you want an ArrayList just use (ArrayList. )
12:58jfieldsafaik, clojure doesn't really provide support for generics
12:58Chousukegenerics don't matter to clojure since it does no static checking anyway.
12:58raekoconnore: generics is checked when java code is compiled. at the JVM level, there is only ArrayList<Object>
12:59jfieldsoconnore, if you know the size and it doesn't shrink or grow you can also look at http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/int-array
13:00hiredmanoconnore: you should also do some reading so next time when you ask you can use the real name of that language feature instead of just guessing
13:00jfieldsoconnore, or you can look at http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/make-array
13:02replacahiredman: did you see that clojurebot was spewing nulls into the channel when checkins to clojure or clojure-contrib happen?
13:02oconnoreok, thanks for your help everyone
13:02hiredmanreplaca: yes, turned it off until I get time to investigate
13:05fliebelraek: Nice score. Nope, I'm not working on it.
13:05replacahiredman: cool. just wanted to make sure you knew
13:06hiredmanyep, thanks
13:15benzenhi guys
13:15benzeni've got a issue with the core template functions
13:16benzencan some one help me?
13:16chouserwhat functions in core are for templates?
13:17benzeni would like to use apply-template
13:17chouseris that in some lib? I don't see it in clojure.core
13:17benzenbut i've got this message java.lang.Exception: Unable to resolve symbol: apply-template in this context
13:18benzensorry it's in clojure.template
13:19chousertry this first: (use '[clojure.template :only [apply-template]])
13:21benzenthanks
13:21benzeneffectivelly it work
13:21benzenworks
13:22benzenan other question
13:22benzenI've red that it's better to use ":use" inside the ns macro over the use function/macro
13:23chousersure, at the top of the file.
13:23raekthat is where you usually put it
13:23benzencan you explain why it 's better please
13:25raekbenzen: if you have a (:use ...) in your ns form it expands to a (use '...)
13:25raekso they are equivalent
13:25chouserit's more declarative, gives you a tidy place to put all such declarations so that people and tools can find it easily
13:25benzenok thanks
13:27benzenI,ve some diffculty to understand the ns macro
13:27benzenDo you know a place where it's well explained
13:27benzenI've seen the official api doc, but it's still some what vague to me
13:28benzenmaybe a blog
13:28raekclojure.org/libs is a start
13:28benzenah nice
13:29benzenone more time thanks
13:29raek'require' makes sure that a namespace is loaded. 'use' does what require does + vars in that ns can be used without a namespace prefix
13:30raek(you can always refer to a var (after it has been load) with a fully qualified symbol: clojure.core/conj)
13:31raekrequire and use takes options
13:31raek(:require foo.bar) = (:require [foo.bar])
13:32raek(require [foo.bar :as fb])
13:32benzenyou gave me good reading, i'll work on that
13:44Raynesraek: I'm not doing anything with it.
13:44RaynesI'm about to pass out. I've been awake 21 hours.
13:47LauJensenRaynes: My record is wednesday morning at around 08:00, to monday late afternoon at about 18:00 :)
13:49RaynesI don't think I've ever surpassed 48 hours without being taken over by narcolepsy and hallucinations.
13:51LauJensenOdd. I was about your age actually. But get some sleep buddy, we'll code tomorrow :)
15:06joshua__How would you go about wrapping one function in a function returned by another function in clojure? Like: (create-new-function function) would be able to pass all the args to function. Really this is more about how to pass arguments than anything else.
15:08tonylyou could use & and apply like this (defn create-new-fn [f & args] (apply f args))
15:08tonylevery argument passed after f (signaled by &) would be a vector of the arguments so apply would do the rest
15:09joshua__I mean more like.. create-new-func returns a function wrapped in another function.
15:10joshua__Now how do I make sure that the wrapping function passes the aruments to the first function? Can you do something like (fn [& args] (apply func-from-closure args))
15:11dnolen(fn [f] (fn [& args] (apply f args)))
15:11tonyllike this? (defn make-fn [f & args] (fn [] (apply f args)))
15:12joshua__dnolen thank you that looks like what I'm talking about.
15:12joshua__tonyl: dnolens example seems much closer.
15:14joshua__Okay next question.. given (fn [f] (fn [& args] (if condition (apply f args) (recur args)))) would recur on the inner function right?
15:14sandGorgonare there any examples of web applications (source code I mean) written in clojure - I know of "cow-blog". It would be nice to see something using various components like Sandbar (for authentication), Enlive (for templating), etc.
15:15tonyljoshua__: yes, the inner fn takes preference
15:15joshua__alright, and its fine to pass in args? You don't need something like (apply recur args)
15:16brehautsandGorgon: laujensen's site is on github
15:16brehautsandGorgon: it uses enlive
15:16brehautsandGorgon: https://github.com/LauJensen/bestinclass.dk
15:16sandGorgonbrehaut, thanks!
15:17brehautsandGorgon: no worries
15:17LauJensensandGorgon: Check out admin.clj for most of the backend logic
15:17tonyljoshua__: no recur only needs the loop bindings or fn arguments, in this case the arguuments
15:17sandGorgonLauJensen, will do .. thanks!
15:17Rayneshttp://github.com/Raynes/tryclojure is a simpler example.
15:17brehautsandGorgon: have you seen dnolen
15:18brehauts enlive tutorial?
15:18joshua__https://github.com/jColeChanged/mysite this is written in clojure, but by me so it is going to be really really bad.
15:18sandGorgonbrehaut, yep
15:19sandGorgonjoshua__, thanks all the same ;)
15:19brehautjoshua__: have you realised you've been commiting your emacs backups?
15:19joshua__sites location is here: http://jcolessite.appspot.com/
15:20joshua__I haven't learned how to stop that yet =p
15:20joshua__if you read the current commit that is actually what I'm talking about..
15:20joshua__partially
15:20brehautjoshua__: http://www.kernel.org/pub/software/scm/git/docs/gitignore.html
15:21joshua__Might as well ask the other related question. Lets say I've deleted a file, but didn't delete it by doing git remove filename.. how do I remove it now?
15:22brehautgit rm filename
15:22Raynesjoshua__: https://gist.github.com/724148
15:22brehautgit figures out what you meant
15:23Raynesjoshua__: That'll push all future backup files to ~/.saves
15:23RaynesWhich is a much more convenient place than all over your file system.
15:23brehautRaynes: cheers :)
15:23joshua__Nice! I had something like that for vim, but didn't think to set it up for emacs.
15:24RaynesYou'll still get autosave files (ones that start with # and .#) if you don't save your files quick enough, but they're automatically deleted once you do save those files.
15:25joshua__Raynes: Thankyou!
15:37fliebelraek: ping
15:51joshua__Alright so this is going right back to my question earlier about recur, because I'm getting an error saying that recure expected 0 arguments and only got one.
15:51joshua__http://clojure.pastebin.com/sBZELFcq
15:51joshua__Is the code.
15:51joshua__Could anyone let me know why the recur call is failing?
15:52erohtarseems like ur calling recur with one argument - a list
15:52hiredmanyou cannot recur across a dosync like that
15:52fliebeland if you do it like that, I think you would at least nee something like (apply recur more)
15:53hiredmanfliebel: also not doable
15:53fliebelhiredman: I guess not, but now he's passing alist right into his vararg.
15:54hiredmanwell the way you do that is (recure [more])
15:54hiredmanwell the way you do that is (recur [more])
15:54tonylmake it a vector maybe
15:54joshua__[more] will fix the problem of passing a list?
15:55hiredmanyes
15:55joshua__Why? Doesn't that just make it a list of a list?
15:55tonyl(vec more)
15:55hiredmanno
15:55hiredmantonyl: please stop
15:55hiredmanthat is how you recur to a var args
15:56raekfliebel: pong
15:57fliebelraek: You said something about the web thing for clojure quiz, but then we missed each other.
15:57Chousukethe recur there doesn't work because of the dosync
15:57joshua__Well, now that I'm thinking about it I can see why recuring inside a dosync would be a nogo, but why is the recur saying that it expects zero arguments (regardless of whether or not it is using [more] or more). Is it trying to recur to the dosync?
15:57hiredmanjoshua__: because of the dosync
15:57Chousukebut in general, treat varargs as if they were a single list argument.
15:57hiredmanthe dosync is creating a thunk inside there
15:58Chousukejoshua__: what you can do is not have the dosync at all in the function
15:58joshua__is thunk a technical term I don't know about or just a figure of speech>
15:58brehautits a technical term
15:58opqdonuttechincal term
15:58Chousukeand just require that users do (dosync (rate-limit whatever...))
15:58opqdonutfor an unevaluated closure
15:59opqdonutgenerated by a lazy computation
15:59fliebelraek: Did you intent to make it, or where you just informing?
15:59raekfliebel: I was thinking about it
15:59hiredman~google thunk
15:59clojurebotFirst, out of 474000 results is:
15:59clojurebotThunk - Wikipedia, the free encyclopedia
15:59clojurebothttp://en.wikipedia.org/wiki/Thunk
15:59raekbut not tonight
16:00fliebelraek: Me neither, and if you want to do it, go ahead. :)
16:01fliebelraek: If you don't, it's on my somewhere-in-the-next-ten-years-but-brobably-earlyer list. ;)
16:01joshua__I'd rather hide the dosync. Could I just wrap the function that is returned in a function that calls dosync?
16:02hiredmansure
16:03joshua__Sweet. Thanks guys. This would have been so hard to figure out on my own.
16:03hiredmanyou could loop inside a dosync too
16:03hiredman(but looping in a transaction, even recuring inside one, is a bad idea)
16:03fliebelhiredman: But isn't it a good idea to keep dosyncs as small as possible?
16:03hiredman(like really bad)
16:04Chousukejoshua__: don't hide dosyncs :/
16:04Chousukeexplicit is good
16:04hiredmanhiding dosyncs is fine
16:04hiredmanthey are nestable
16:05Chousukethough honestly, that function looks complicated enough that I'm not sure of its correctness. :P
16:05joshua__It works. =) Sort of.
16:05hiredmanjoshua__: putting a thread sleep like that inside a transaction is a horrible idea
16:06brehautjoshua__: a surprising number of things work without being correct ;)
16:07joshua__hiredman: Can you explain why? I'm guessing that it has something to do with other transactions causing aborts or something like that.
16:07joshua__brehaut: ;p like internet explorer
16:08brehautie works?
16:09hiredmanjoshua__: right, your transaction will never complete, and behave oddly when retried
16:09hiredmanThread/sleep is a side effect and transactions should be side effect free
16:09joshua__hiredman: So I guess the thing to do would be to leave the recursive trying in another function outside the transaction.
16:11hiredmandepends what the function does, I try not to read code beyond the point of diagnosing the given problem, so I don't really remember anything else about your code
16:13joshua__In general: It tries to rate limit the number of times a function can be called. It gives the option of trying the function again when doing so is within capacity or of dropping the call entirely.
16:16hiredmanjoshua__: I don't see why you would need stm for that
16:17hiredmansounds like it should be implemented like memoize
16:17joshua__hiredman: I'm not sure how else to save state between function calls.
16:17hiredmanwith atom holding the last time the function was called
16:17hiredmanlook at memoize in core
16:26kotarakjoshua__: sounds like a kind of circuit breaker?
16:54mvid_is there a way i can use the key and the value in a function when i apply "map" to a hash-map?
16:55brehaut,(map + {1 2 3 4})
16:55clojurebotjava.lang.ClassCastException
16:55brehautoh right
16:55brehaut,(map (fn [[k v] (+ k v)) { 1 2 3 4})
16:55clojurebotUnmatched delimiter: )
16:55brehaut,(map (fn [[k v]] (+ k v)) { 1 2 3 4})
16:55clojurebot(3 7)
16:56brehautmvid_: like that?
16:56mvid_cool
16:56mvid_that's great
16:56mvid_plus points for brehaut
16:59chouser(inc brehaut)
16:59sexpbot⟹ 1
17:00brehauthah awesome :)
17:10brehautwhats the current state of textmate support for clojure?
17:11Makoryubrehaut: On a scale of 1 to 10: "Good luck"
17:11brehautstill? bah
17:12MakoryuI think there's third-party syntax highlighting support, if nothing else
17:12brehautyeah ive got a really old syntax highlighting mode
17:12MakoryuBut don't ever expect TextMate to understand Lisp-style indentation
17:14lrennbrehaut: https://github.com/swannodette/textmate-clojure
17:14brehautlrenn: cheers
17:14brehaut(inc lrenn)
17:14sexpbot⟹ 1
17:16arohneris there a paredit command that will turn (foo a b (bar c d)) into (bar c d (foo a b))?
17:30bhenryhow is it that merely adding a dependency can break one of my existing, otherwise working function calls?
17:31raekusing use?
17:33islonhow don't I fully qualify a name inside a macro?
17:33joshua__Alright, so I want to make a macro that will let me do something like (def var (rate-limited-function func rate)) as (defrl func rate) how do I do this?
17:33raekislon: that depends on what you want to do...
17:33joshua__(defrl var func rate) rather
17:33mvid_is there a way to pretty print a sequence or map of strings?
17:34islonraek: something like (defmethod [parameter] ...) inside the macro, parameter can't be qualified
17:34mvid_im tired of ljava.lang.String90327879438752
17:34raekyou can write parameter# in that case
17:35islonbut i want to know the name
17:35islonbecause i will get the body from outside and it will use the parameter name
17:36raekthen you can do the ~'foo trick
17:36islonexactly what i want! thanks
17:36brehautjoshua__: (defmacro defrlf [name func rate] `(def var ~name (rate-limited-function ~func ~rate))) i think ?
17:37brehautjoshua__ note the back tick rather than quote on the macro and the unquote twiddles on the args to the macro
17:38brehautjoshua__: you can test it with (macroexpand '(defrlf a b 10))
17:38joshua__kk =)
17:39brehautjoshua__: and read http://clojure.org/reader to brush up on the reader tricks those twiddles and stuff represent at http://clojure.org/reader under 'macro characters'
17:40brehautsyntax-quote in particular
17:47bhenryi had a working function, and after adding incanter to my dependencies in project.clj (never changed any of the src files), one of my function calls in myproject.core no longer works.
17:48brehautbhenry: this is a wild guess, perhaps incanter requires a different version of a dependancy that you use? i have no idea how lein/maven resolve that sort of thing
17:54joshua__yeay yeay yeay
17:54joshua__working!
17:54islondoes anyone knows why this macro only works for the last defmethod not the first? http://pastebin.com/8QRnjXYt
17:59brehautislon preumably defmacro is like any other form with an implicit do; ie only the last form is ever returned
17:59brehautislon try switching to a cond and you should be fine
18:00islonbrehaut, i'll try a cond
18:01joshua__How can I keep emacs from indenting my comments all the way across the page in cl the mojure mode?
18:01joshua__*in clojure mode?
18:01joshua__ ; how do I stop this?
18:02hiredmanuse ;;
18:02hiredman;; is for blocks
18:02hiredman(+ 1 2) ; is for comments on a line of code
18:02clojurebot3
18:03rasactiveclojurebot just evals any expression?
18:03islonbrehaut, now only the first one works... =/
18:03brehauthow are you invoking gen-skill-methods ?
18:03brehautanything truthy will trigger the first form
18:04islonboth are supposed to work at the same time
18:04brehautah right. i have no idea if thats possible sorry. you'll need someone with more macro fu than i have
18:04islonbrehaut, thanks anyway
18:05brehautah actually
18:05hiredmanrasactive: nope
18:06brehautislon: (defmacro f [] `(do (def a 1)(def b 2))) gets you part of the way there
18:06islonhmmm... lets try
18:06rasactivehiredman, how do you make "him" eval something?
18:06rasactivei'm assuming 3 came from your (+ 1 2)
18:07islonrasactive: ,(expressions) i think
18:07islon,(+ 3 3)
18:07clojurebot6
18:07rasactivecool, thanks
18:09brehautislon: (defmacro m [a b] (let [da (when a `(def my-a ~a)) db (when b `(def my-b ~b))] `(do ~da ~db)))
18:09brehautislon that might be considered horrible though
18:09brehautislon: till i get told otherwise i'd categorise that as a nasty hack
18:10isloni'll try do first
18:16joshua__,(+ 1 2)
18:16clojurebot3
18:35bhenrybrehaut: you were correct. incanter has an older version of mongo-java-driver…jar and after deleting that my original code works again. question is now… since both libs that require mongo-java-driver are third party, how do i exclude that older jar automatically? perhaps that should be directed at technomancy or another lein pro?
18:36technomancyit's in the faq
18:36brehautbhenry: lein pros
18:36technomancywait... incanter has a mongo driver‽ o_O
18:37bhenry[incanter "1.2.3"] requires incanter/incanter-mongodb 1.2.3 which i assume is what's pulling that.
18:37technomancymaybe I have no idea what incanter actually is, but that sounds crazy to me.
18:37brehautcrazy statisticians
18:39bmarthi all, i'm trying to set up swank-clojure and slime and am running into some issues
18:39bmartspecifically, i do slime-connect which succeeds with a warning
18:39bmartif i then evaluate a number, e.g., 3, it succeeds
18:39bmartbut if I enter an expression like (+ 1 2), nothing happens
18:39bmartsuggestions?
18:46islonbrehaut, the "let" version worked =D
18:48brehautislon: cool :) its a bit hacky though
18:50isloncoulnd't find a better way
18:53brehautislon maybe have a look at the extends-protocol macro? im sure there are some examples in core that might show you a better way
18:54isloni'll take a look
19:19clizzini've got a case where i want to be able to specify what java class i want to use as an argument to a function. i'm trying something like (defn foo [subclass] (new subclass)), but that says it's unable to resolve instance-type as a classname. is there any way i can achieve my desired behaviour?
19:49clizzinanyone know how to increase heap space for the jvm when using lein swank?
19:49islonclizzin, (defmacro foo [clazz] `(new ~clazz))
19:50islonor better (defmacro foo [clazz & args] `(new ~clazz ~@args))
19:51tomojclizzin: try JAVA_OPTS
19:51clizzinislon, tomoj: thanks!
19:52clizzintomoj: nothing i can set from lein swank? i don't want to allocate this much heap space every time, just for a few things i'm doing
19:53tomojif JAVA_OPTS works, it works that way
19:54tomojJAVA_OPTS=-Xmx1000m lein swank
19:54islonbrehaut, I think thats what I'm looking for https://github.com/clojure/clojure/blob/b578c69d7480f621841ebcafdfa98e33fcb765f6/src/clj/clojure/core.clj#L2309
20:04vIkSiT'lo all
20:04vIkSiThas anyone done any logfile tailing/stream processing?
20:04clizzintomoj: wouldn't JAVA_OPTS=-Xmx1000m lein swank cause any java process to attempt to run lein swank?
20:09clizzinhmmm the JAVA_OPTS attempt doesn't seem to have worked
20:11brehautislon: cool thanks
20:11islonbrehaut, worked as a charm =)
20:21tomojclizzin: I meant run that command
20:22tomojdon't set JAVA_OPTS to "-Xmx1000m lein swank", just type `JAVA_OPTS=-Xmx1000m lein swank` into the shell
20:25clizzintomoj: i see. so forgive my ignorance, but lein swank seems to actually start two processes, and i'm not sure what each is for. the first has the JAVA_OPTS amount of heap space, but the second one is the actual jvm that my repl commands run on, and that one still has the default amount of heap space.
20:27tomojweird
20:27tomojfor me they both have my custom heap space
20:29clizzinhm that is odd indeed
20:30tomojlein -v ?
20:31clizzin1.3.1
20:31clizzinfull version string: Leiningen 1.3.1 on Java 1.6.0_22 Java HotSpot(TM) 64-Bit Server VM
20:31clizzinswank clojure 1.2.1
20:32clizzinoh wait, no, swank-clojure 1.3.0-snapshot. interesting, i wonder when someone on my team updated that.
20:35technomancyclizzin: you can set :jvm-opts in project.clj if you only want it applied to the project's JVM
20:36tomojtechnomancy: but the project JVM should inherit JAVA_OPTS, right?
20:37technomancytomoj: yeah, but lein's JVM doesn't need a gig
20:37tomojright
20:37technomancyoh, I see; it's not propagating
20:37technomancythat is strange
20:37technomancy:jvm-opts is preferrable; does it work?
20:39clizzintechnomancy: ah, thanks for the tip. just looked, and someone already set jvm-opts to a different heap size, hence the lack of propagation. so that solves that problem.
20:39technomancydun dun dun!
20:39clizzinsorry tomoj and technomancy, still getting used to all the details of this stuff ;)
20:40technomancythwarted by a so-called team-mate.
20:40technomancyit happens; there's a lot to take it. I recommend a perusal of sample.project.clj.
20:40islonis there a way on cake to kill only the swank server?
20:41joshua__Question: How do you abort a command running on your emacs slime swank repl?
20:41joshua__Like C-z in python?
20:42tomojC-c C-c
20:43joshua__Didn't work =(
20:44tomojare you waiting for a bunch of output?
20:44joshua__More like trying to prevent it.
20:44technomancynot all operations are cancellable in the JVM
20:44tomojyeah
20:44joshua__=( awhh
20:44joshua__so a loop that is spamming print can't be cancelled?
20:45joshua__Guess I
20:45joshua__Guess I will keep up my current dash to the exit button when things go south.
20:46clizzinyeah, i typically just restart the jvm in situations like that. =/
20:47tomojI wonder if the unicode problems are slime's or swank-clojure's, or who..
20:47pdk`ctrl D
20:49joshua__I'm just really hoping that my rate limiting function worked right and that I was caught in a print loop like I think I was.... going to really suck if I just sent out a few thousand http requests =(
21:30hiredmanI never actually done any profiling with type hints and without, seeing your runtime dominated by invokeMatchingMethod is disconcerting
21:30hiredmanI've
22:13bortrebwhy can't I call my record types as a function on their keys like I can with normal maps?
22:13bortreblike ({:hi 1} :hi) == 1
22:14bortrebbut (defrecord whatev [hi]) ((whatev. 1) :hi) gives an error
22:16arohnerbortreb: (whatev :hi) uses the IFn interface, i.e. clojure functions
22:16arohner(:hi whatev) uses the IPersistentMap inteface
22:16arohnerdefrecord implements IPersistentMap, but not IFn
22:17bortrebI'm wondering why it doesn't implement IFn?
22:17arohnerbortreb: because (:hi whatev) has a different performance profile
22:17arohneron a defrecord, (:hi whatev) has the same speed as a java field lookup, i.e. whatev.hi in java
22:17arohner(whatev :hi) is a lot slower
22:18bortrebbut treating it as a function is slower I guess?
22:18arohnerright
22:18bortrebhmmmmm..... but you can't just plop your record into any code that worked with clojure maps and expect it to work then?
22:19bortrebbut that behaviour can be added, right
22:19arohneryeah, it's a problem. But I've started doing (:hi whaev) in all my other map code now
22:19arohner(:hi whatev) works on normal maps, and (get whatev :hi) works on both kinds as well
22:20bortrebcan you define the record to implement IFn and give it a method that looks up on clojure keywords?
22:20arohneryes
22:20bortrebI just started learning about defrecord, how would you implement IFn?
22:23tomojyou need to implement the invoke functions of the appropriate arities
22:25tomojbortreb: https://gist.github.com/0e196e1b27ec25256d2e
22:26bortrebyay I got it
22:27bortreb(defrecord whatev [hi] clojure.lang.IFn (invoke [this k] (get this k)))
22:27bortrebthat seems to work
22:27bortrebbut! am I missing something crucial here that makes this actually incorrect?
22:27tomojyou should probably also implement the 2 arity invoke
22:28bortrebwhy's that?
22:28tomoj(invoke [this key not-found] (get this key not-found))
22:28tomoj,({:foo 3} :bar 10)
22:28clojurebot10
22:28bortrebho!
22:28bortrebthanks tomoj!
22:29bortreb(defrecord whatev [hi] clojure.lang.IFn (invoke [this k] (get this k)) (invoke [this k not-found] (get this k not-found)))
22:30bortrebso then, is that totally right, or am I still missing something?
22:33tomojdunno
22:33tomojcompare the interfaces that maps implement to the ones your records implement
22:34tomojif you have everything covered you should be good, I think
22:34bortrebindeed. thanks
22:35tomoj,(require 'clojure.set)
22:35clojurebotnil
22:36tomojerr.. nevermind. can't defrecord
22:36tomoj(clojure.set/difference (supers (class {})) (supers Foo)) -> #{clojure.lang.APersistentMap clojure.lang.AFn clojure.lang.IEditableCollection clojure.lang.MapEquivalence}
22:36tomojso you can't call transient on it
22:37tomoja transient record would be a strange thing