#clojure logs

2011-04-21

00:23dnolenis there a way to get a list of all currently loaded classes in Java?
00:27mecIs there a difference between equals and equiv?
00:32gjahad__(.allClasses (cdt.utils/vm))
00:33amalloygjahad__: nice
00:33amalloynot that i have any real reason to want to use that, but it's cool
00:39dnolengjahad__: when I include the version of cdt into my project, and try run the snippet, (cdt.utils/vim) -> nil
00:42amalloydnolen: vm, not vim?
00:42dnolenamalloy: oops yea.
00:48mecwithin a deftype do I have to refer to another method as (.method this args)?
00:50dnolenmec: what do you mean by another method?
00:53mec(deftype foo [s] ISeq (first [_] s) IPersistentStack (peek [this] (first this)))
00:54mecother way around might be a better example
00:54mecis the first in peek foo.first or clojure.core/first
01:00dnolenmec: it's faster to call .first directly, first will go through RT.
01:00mecok so i do have to specifically do that, thanks
01:06tomojthat there is no foo.first, is there?
01:06tomojs/that//
01:08dnolentomoj: no
01:09dnolentomoj: (.first this) or (first this) is what he meant.
01:24mecThis is weird, running this deftype twice throws an error instead of just redefining
01:25dnolenmec: what is the error?
01:26mecExpecting var, but RegeneratingCounter is mapped to class user.RegeneratingCounter
01:29mecAh never mind, missed some periods
01:35lenwhello all
01:36lenwdoes anyone have an example of using crane to deploy simply using ssh - any pointers appreciated ?
01:47dnolenLogos is a pretty fun way to explore Clojure's interfaces
01:47dnolenhttps://gist.github.com/933791
01:47clojurebotHuh?
01:57dnolenooh especially queries like only Sequential *and* Counted
03:09hoeck~ seen AWizzArd
03:09clojurebotAWizzArd was last seen in #clojure, 9652 minutes ago saying: edw: list comprehension is what for does. List comprehension can do mapping and filtering.
03:12amalloyhaha 9652 minutes
03:12amalloy$seen AWizzArd
03:12sexpbotAWizzArd was last seen talking on #clojure 6 days and 16 hours ago.
03:46ejacksonmorning
04:39ejacksonoh oh.... fliebel is following me
06:35ilyakWhat's the best way to get a readable clojure backtrace?
06:35ejacksonopen question
06:36ejacksoni believe 1.3 has good stack traces
06:36ejacksonbut haven't tried it myself
06:36ilyakSadly, eclipse's clojure repl by default swallows backtraces
06:36ilyakwhich is sad
06:37ilyakThat's the least painful way to develop in clojure?
06:40ejacksoni'd say emacs
06:40ejacksonbut its by taste, really
06:51ilyakSadly my brain is not suited to either editing config files or remembering hotkeys
06:51ilyakwhich rules out both emacs and vim
07:03cemerickilyak: what was the problem with eclipse for you?
07:05ilyakcemerick: It's fine but pretty basic
07:05ilyakFor example, it doesn't show backtraces when error occurs
07:05ilyakjust description and (usually wrong) line no
07:05ilyakMaybe I have ancient eclipse with ancient plugin
07:06cemerickilyak: mayke sure you have the latest 0.2.0 RC installed.
07:06cemerickBut yes, the default is to print only the error summary; then hit Ctrl-E if you want to see a full stack trace of *e.
07:07cemerickthat is the behaviour of the stock Clojure REPL as well, FWIW
07:08cemerickI think there's an issue open to eventually add a configuration option for that behaviour (so stacks are printed in full automatically), but it's lowish-priority…
07:09cemerickIf you care to track these sorts of thing: http://code.google.com/p/counterclockwise/issues/detail?id=187
07:59fliebel&(seque (java.util.concurrent.PriorityBlockingQueue.) [1 4 6 2])
07:59sexpbotjava.lang.ClassCastException: java.util.concurrent.PriorityBlockingQueue cannot be cast to java.lang.Comparable
07:59fliebel… why is this giving me crap? locally it returns java.lang.NullPointerException or (1 4 6 2)
08:05fliebel&(doc seque)
08:05sexpbot⟹ "([s] [n-or-q s]); Creates a queued seq on another (presumably lazy) seq s. The queued seq will produce a concrete seq in the background, and can get up to n items ahead of the consumer. n-or-q can be an integer n buffer size, or an instance of java.util.concurrent B... http://gist.github.com/934334
08:07fliebelPriorityBlockingQueue implements blockingqueue, so I can't see why this would act weird.
08:12cemerickfliebel: the NPE is coming from inside PBQ, which is odd
08:13fliebelcemerick: It sure is. Or maybe not...
08:13fliebelIf I remember correctly, seque inserts itself at the end, so maybe that trows of the comaring?
08:21fliebelThinking about it, closing a que that way, does not work, since it does not return in order.
08:21fliebel$source seque)
08:21sexpbotSource not found.
08:21fliebel$source seque
08:21sexpbotseque is http://is.gd/Ggbm1u
08:23fliebel"q itself is eos sentinel" So, what does it lok like when you hae a priority que containing [1 4 2 5 q]? q could be anywhere.
08:26fliebel&(.compareTo 1 (java.util.concurrent.PriorityBlockingQueue.))
08:26sexpbotjava.lang.ClassCastException: java.util.concurrent.PriorityBlockingQueue cannot be cast to java.lang.Integer
08:31fliebelSo can a PriorityBlockingQueue even contain items of different classes?
08:34fliebelWould this be a bug in seque(because it assumes order), or misuse of my side?
08:37fliebelejackson: Hi, have you seen my tweet? Really nice what you've done with quicksort.
08:38ejacksoni didn't see it... lemme me see
08:38ejacksonthanks for the compliment - not my code, of course, but its cool
08:40ejacksonaaah heap sorts
08:40fliebelejackson: I made this a while back, that does heapsort in a semi-lazy way: http://pepijndevos.nl/sorting-obsession
08:41fliebelI was now trying to use a PriorityBlockingQueue in seque to do the same, but seque is kind of broken when using a non-standard queue.
08:42fliebelI wonder if there are other interesting sorts that can be done lazily.
08:44ejacksoni would imagine so - but I'm trying to avoid going down rabbit holes these days
08:44ejacksonmaintaining focus
08:45fliebelejackson: focus on what?
08:46ejacksonthe projects that will keep food on my table
08:46ejacksoni'm freelance
08:47fliebelhah, dnolen! You make me wonder if Logos can do sorting. (exist [x y z] (== (llist x y z) q) (project [x y] (> x y))
08:48fliebelejackson: You work with Clojure?
08:48manutterwhat this channel needs is a good Logobot
08:48manutter:)
08:48ejacksonfliebel: whenever possible. Right now I have one client i'm doing in clojure, another in python.
08:49ejacksonmanutter: what is a Logobot
08:49fliebelWell, if ##(require 'logos.core) was allowed...
08:49sexpbotjava.io.FileNotFoundException: Could not locate logos/core__init.class or logos/core.clj on classpath:
08:51manutterejackson: logobot == clojurebot, only for Logos
08:51ejacksonok
08:52fliebelmanutter: That's easy… for sexpnot, add logos to deps, put require logos in some sort of init and run.
08:53fliebel*fork sexpbot
08:53TimMcfliebel: Security might require more changes.
08:54fliebelTimMc: Why?
08:54TimMcDoes Logos have any way of interacting with the filesystem, network, etc.?
08:55fliebelNot that I know...
09:02dmeadhi channel
09:02dmeadis there a clojure api thats callable from java?
09:02dmeadi can't get a macro to compile, so i want to just write the function body in java
09:02dmeadbut i'm not sure if the interop goes like that
09:06Chousukedmead: you can use clojure interfaces from Java, yes. It's not really documented, but google should give you some results.
09:07Chousukedmead: though it sounds like making your macro compile is probably the better solution :P
09:07fliebel~xy
09:08clojurebotxy is http://mywiki.wooledge.org/XyProblem
09:08fliebelI love doing that :P
09:10dmeadChousuke, i'm sure what it want to do won't work
09:10dmeadyet works by default in common lisp
09:11dmeadi want to return the second symbol in an unquoted s-expression
09:11dmeadwithout evaluating the first
09:11dmeadi've tried writting a macro that destrutures a single parameter
09:11dmeadwith little success
09:12dmeadso like (defmacro msecond [[x y z] `'~y)
09:12dmeadbut depending on what i do with it, i get really unclear exceptions from the RT
09:13Chousukehmh
09:13Chousuke(defmacro foo [[x y z]] `(quote ~y))
09:14Chousukethat should work
09:14dmeadis that any different?
09:14Chousukenot really, just not missing a ] :)
09:14dmead:P
09:15Chousukethough honestly that looks like a rather pointless macro. :/ Anyway, what sort of errors are you getting?
09:17dmeadi'll post
09:17dmeadsec
09:18Chousukeremember to put the macro call that causes the errors in too, and the actual macro definition. :)
09:18dmeadindeed
09:18dmeadi'm sure the call is right
09:18dmeadwell
09:18dmeadthe call works on the repl
09:18dmeadbut not in some other code
09:23dmead(= (msecond (x <- y) <-)
09:23dmeaderr
09:23dmead(= (msecond (x <- y) `<-)
09:23dmeadthat returns true in common lisp
09:23dmeadbut false in clojure
09:23Chousuke,`<-
09:23clojurebotsandbox/<-
09:24Chousukemaybe that's it :)
09:24dmeadhmm?
09:24dmeadwhats it
09:24Chousuke` namespace-qualifies symbols
09:24Chousuke,(= '<- `<-)
09:24clojurebotfalse
09:24dmeadbut that changes the equality test?
09:25Chousukeyeah
09:25dmeadthats awful.
09:25Chousukeit's a different name
09:25dmeadright
09:26dmeadso how would i test for equality to the not quoted <- symbol?
09:26Chousukenot quoted?
09:27dmeadmy macro is processing a bunch of play s-expressions
09:27Chousuke(= (msecond (x <- y)) '<-) will return true
09:27Chousukenote the quote mark is different
09:27dmeadbecause ' doesn't namespace qualify?
09:27dmeadyes
09:27Chousukeyeah
09:27Chousuke' is just quote
09:27dmeadis there a way to turn off namespace qualifiers for backquote?
09:27Chousukeno
09:28Chousukethough you can work around it whenever you need unqualified symbols inside syntax-quote forms
09:28dmeadhows that?
09:28Chousuke,`~'x like this
09:28clojurebotx
09:28dmeadah
09:28dmeadright
09:28dmeadlike we did above
09:28dmeadoh it's the reverse of what i had
09:29dmeadhmm
09:29Chousukeyeah
09:29dmeadhmm
09:29Chousukewhy do you need ` in this case?
09:29Chousukejust use '
09:29dmeadi don't, i was just porting some common lisp stuff
09:30dmeadand i wasn't away the namespace qualifier changed the equality test
09:30Chousukeyeah, be mindful of the differences :)
09:30Chousukeit's not the same name, so it can't be equal
09:30Chousukeif foo/-> and bar/-> were equal to -> then they'd have to be equal to each other :/
09:30Chousukeand that's just not good
09:30dmeadright
09:32choffsteinIs there a clojure function that says whether a variable is "blank." I would consider blank to be an empty string, vector, map, or nil.
09:32dmead, (empty? nil)
09:32clojurebottrue
09:33Chousukeseq is also idiomatic in some cases
09:34Chousukeempty? is in fact just #(not (seq %)) :P
09:34dmeadah
09:35choffsteinempty is perfect :)
09:35choffsteinI find googling for my clojure solutions so hard
09:35dmeadi sorely with clojure conformed to common lisp
09:35dmead*wish
09:35dmeadit would be so much easier
09:36TimMcdmead: Not conforming is why it is awesome.
09:36choffsteinLike ... trying to google for information on -?> is impossible
09:36choffsteinI don't know how to find it
09:36TimMcdmead: I.e., the breaking changes are fundamental.
09:36TimMcchoffstein: clojuredocs.org
09:36dmeadTimMc, i don't really agree
09:36dmeadit's not like it's breaking compatibility with pascal or some other garbage
09:37choffsteindear god. how did I not know that existed?!
09:37dmeadit's lisp. FFS
09:37choffsteinThat is a game changer.
09:37TimMc&(map empty? [() nil ""])
09:37sexpbot⟹ (true true true)
09:37dnolendmead: Clojure is influenced by a bunch of things, CL is just one. Clojure's macro system is a sweet spot between Scheme and CL, IMO.
09:37dmeaddon't know scheme really
09:37TimMcchoffstein: Yeah, just be aware that the autocomplete and the actual search behave differently. Namely, search is broken for hyphens, use spaces instead.
09:38dnolendmead: thus your bias :)
09:38dmeadmaybe
09:38choffsteinTimMc: Okay, thanks :)
09:38dmeadive just beeing porting some CL code
09:38dmeadand getting frustrated :/
09:38dnolendmead: it's learning exercise I ported cl-cont 3 years ago, wasn't that bad.
09:38sh10151is anyone familiar with Groovy? For some reason it has traction at my workplace while Clojure does not, really...
09:39TimMcsh10151: Tell your co-workers that Clojure has curly braces too! :-P
09:40TimMcdmead: Clojure's seq and coll abstractions over lists, vectors, and maps are fantastic changes that break with CL's model.
09:40TimMc(although I suppose that code using list, cons, first, and rest would be backwards compatible.)
09:40choffsteinThis is totally a strange, probably bastardized clojure question, but it tickles my curiosity: is it possible to have the user enter a function name and call that function by name? Something like (call :function-name [parameter list])?
09:41dmeadthats really just a different way of saying that clojure isn't all that far abstracted away from the jvm
09:41chouserchoffstein: sure
09:41dmeadand that fact is what makes all these things crop up
09:41dmeadi really don't see how breaking with 50 years of lisp practices is a good thing
09:41TimMcchoffstein: You could look it up in the namespace.
09:42dmeadwhen the changes are just syntactic
09:42dmeadCL is nice and uniform, clojure is not
09:42choffsteinHow can I do that?
09:43dmeadTimMc, so like clojure is weakly typed. but i get all kinds of type errors that wouldn't happen in CL
09:43chouser,(resolve (name :reduce))
09:43clojurebotjava.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.Symbol
09:43manutter,(resolve (symbol (name :reduce)))
09:43clojurebot#'clojure.core/reduce
09:44cemerickdmead: Clojure is strongly and dynamically typed.
09:44dmeadcemerick, blargh.
09:44chousermanutter: right-o
09:44choffsteinchouser: awesome, thanks!
09:44chouserchoffstein: so that gets you a var for a keyword, then you can call the var
09:45cemerickdmead: just sayin'
09:45chouser,(apply #'reduce [+ [3 4 5]])
09:45clojurebot12
09:45devnClojure is dynamically strongly typed and strongly dynamically typed
09:45TimMcchoffstein: Also see ns-resolve if you want to restrict it to a namespace.
09:45choffsteinI love this channel :D
09:45dmeaddevn, stab.
09:45devn:d
09:46cemerickMy kingdom for lazy seqs in Javascript.
09:47chouserdmead: Sorry you're frustrated, but this channel being what it is you're more likely to get defences of Clojure behavior than agreement that it should be like CL (after all, we could be using CL even on the JVM if we wanted to)
09:47chousercemerick: just got those working yesterday
09:48TimMcchouser: Oh neat, I didn't realize you could invoke a var directly. Nice shortcut.
09:49chousercemerick: so far I have lazyseq, cons, seq, first, rest, next, map, filter, concat, and flatten
09:50chouserthat's a bit over 100 short lines of uncompacted js. No other deps.
09:50cemerickThese are clojurescript refugees?
09:50chousernope, fresh hand-written code. no persistent collections.
09:50fliebel?? "(do @agt nil) ;touch agent just to propagate errors"
09:50cemerickchouser: oh, that's a little more interesting then
09:50chouserin clojurescript most of these were generated from core.clj and depended on big chunks of a clojure runtime
09:51chouserfliebel: deref'ing an agent that's got an error will throw that error
09:51cemerickHrm, lazy seqs next to mutable collections. I can imagine bugs could get *really* hairy.
09:52chousercemerick: probably. you certainly have to be careful.
09:52fliebelchouser: Great, what about futures and other derefables?
09:52fliebel*chouser
09:52chouseron the other hand, the clojurescript persistent collections are hand-written js and might not depend on that much else either. Hm...
09:53chouserfliebel: For those that can "hold errors" I think they behave the same.
09:54chouserwhich is what, just futures I think.
09:55fliebelokay, thanks
09:56fliebelI'm trying to make a sane implementation for seque
09:56chouserheh
09:57fliebelchouser: http://dev.clojure.org/jira/browse/CLJ-776
09:57chouseroh, interesting.
09:58fliebelchouser: Yea, but there is a lot of complexity in seque already I need to understand to actually improve it.
10:05fliebelIt seems an agent is used as a future that propagates errors when deref'd.
10:09chousera future can only be run once. seque sends to that agent repeatedly, doesn't it?
10:09fliebelwell, yes… let me see. Hard to tell what fill returns.
10:10fliebeloh, right, s minus all the proccessed ones.
10:11fliebelbut offer does not work anyway for a SynchronousQueue
10:12fliebelSo I want to see if I can just use put in a future. I also need to get around using the eos sentinel.
10:13chouserbecause the eos could be re-ordered?
10:13chouserby the blocking queue?
10:13fliebelyea, it is not guaranteed the eos will actually be at the end of a priority queue
10:14chouserhm. tricky.
10:14fliebeland it also breaks the heap, because it throws a npe deep down there.
10:15fliebelI'm now just writing down facts about seque and BlockingQueue to see what I need to do.
10:18fliebelWhat are tests fro Clojure written in?
10:18chouserClojure
10:18fliebelI mean, framework?
10:20fliebelah clojure.test
10:21chouser:-) sorry
10:22fliebelchouser: Do you know if there exist any tests for seque? I could not find any, in places I found logical.
10:22chouserfliebel: I don't know, sorry.
10:23fliebelnp
10:24fliebelThey're not here at least: https://github.com/clojure/clojure/blob/master/test/clojure/test_clojure/sequences.clj
10:29fliebelWould it make sense to make Exceptions be falsy? I can't find any case where I want an exception to be truthy.
10:30fliebelso it'd be like "if it's false, nothing or an error…"
10:40fliebeluh-oh, have pods landed yet? Because if I do what I'm doing now, I'm in trouble.
10:42fliebeldoing .put inside a dosync is a big screaming unretryable sideffect.
10:49fliebelIsn't there future-error?
11:31fliebelchouser: Done! https://gist.github.com/934781
11:34bpattisonDoes any one know how to :gen-class a Java class whose methods I want to override has a byte array, byte[], as arguments?
11:35fliebelbpattison: You might try type-hinting them, but I don't think Clojure has primitive support for arrays.
11:35bpattisonI've tried byte[], and bytes in the :methods specifier
11:36bpattison#^bytes doesn't work either
11:37fliebelbpattison: At least the new syntax dropped the hash
11:40dnolen_bpattison: did you try ^"[B" ?
11:40dnolen_,(class (byte-array []))
11:40clojurebot[B
11:40fliebeldnolen_: As a string?
11:40dnolen_fliebel: yup
11:41fliebeloh, cool, I thought these where not redable, period.
11:41bpattisonI'll try that
11:45bpattison"[B" compiled -- I need to test further to see if my overloaded method is actually called
11:52ejacksonoh dear, I'm busy doing pen and paper maths and just wrote (log X).... this is officially going to far now.
11:53manutterlol
11:55ejacksonyes, the don't like that either
11:58cemerickDo enlighten me :-)
12:07ejacksoncemerick: it is not the wind the moves, nor the flag that moves, but your mind that moves.
12:07ejackson:P
12:16fliebelWhat the difference between "java.lang.RuntimeException: java.lang.RuntimeException: java.lang.Exception:" and "java.lang.RuntimeException: java.lang.Exception:"?
12:17dnolenso any tips today on discovering all currently loaded classes in the JVM ?
12:19technomancydnolen: you could steal whatever swank does for tab-completion
12:19dnolentechnomancy: good idea, will look into that.
12:20fliebelSomething threw an error, and then I rethrew it, and it got all weird with java.lang.RuntimeException prepended.
12:22fliebelI was testing for Exception, but that failed. (is (thrown? Exception …))
12:25fliebelWhen I write RuntimeException instead, it works. But what kind of TDD is that? Writing the test to pass the code.
12:26fliebelAnyone know what caused this?
12:27hiredmanfliebel: depends, I think lazy-seqs wrap exceptions in runtime exceptions
12:28fliebelhiredman: Oh, I'll than lazy-seq for that then.
12:30fliebelOkay, there we go, a new seque with tests: https://gist.github.com/934781
12:49amalloy$findarg map % [() nil "" [1]] [true true true false] ; TimMc, choffstein
12:49sexpbot[clojure.core/empty?]
13:04ilyakI've caught StackOverflowError in (drop-while)
13:04ilyaknot funny at all! :(
13:04amalloyilyak: you're stacking up a bunch of lazy thunks and then realizing them all at once. let me see if i can find you a thread discussing the problem
13:05amalloyhttp://groups.google.com/group/clojure/browse_thread/thread/6f5064532546a852
13:16raekanyone know if something like this has been done for Standard ML? http://blog.wuwon.id.au/2011/01/persistent-vectors-and-hash-maps-for.html
13:16fliebelAnother not-funny-at-all problem. I have a clojure.test that checks for an exception, and fails. The exact same code does throw an error on the repl.
13:17raeklaziness?
13:17clojurebotlaziness is what will save us all
13:19ilyakamalloy: Maybe that, but what can I do about that?
13:19raek,(lazy-seq (throw (Exception. "BOOM!")))
13:19clojurebotjava.lang.Exception: BOOM!
13:19raek,(do (lazy-seq (throw (Exception. "BOOM!"))) nil)
13:19clojurebotnil
13:20raekfliebel: maybe you need to run doall on som part of the result
13:20fliebelraek: Might be… So what ahppens when I do (is (range 10) (range 10))?
13:21raekfliebel: if you do (is (= (range 10) (range 10))), then it will pass
13:22raekbut without the =, it only checks if the lazy-seq is truthy, which it is
13:22raek(and this does not force it)
13:22fliebelraek: Okay, the dorun worked. Now I have an actual bug to solve...
13:25amalloyilyak: don't create expressions that look like (drop-while (drop-while (drop-while ...))). it's hard to say how you could accomplish that when i don't know anything about your project
13:31ilyakamalloy: I didn't
13:31ilyakI can paste it to some kind of pastebin but it would make everybody cry
13:32ilyakIt's highly data-dependent so there's no much point
13:32ilyakThe problem with stack overflows - I don't even know where it happened
13:32ilyakBecause it didn't show the interesting part of backstrace
13:41dnolenhuh SpiderMonkey is starting to sound like a much cooler Clojure JS target than V8...
13:41fliebeldnolen: how so?
13:42dnolenhas yield, so it can represent lazy sequences more efficiently, isn't single-threaded, comparable speed now as far I can tell.
13:43fliebeldnolen: oh, neat
13:55fliebelWhat do you do when you need to check if someone is running by checking if his legs hit the ground?
13:57manutterwait, what?
14:00midsfliebel: might be of minor use: http://stackoverflow.com/questions/4087919/how-can-i-improve-my-paw-detection
14:19technomancyclojurebot: Bruce's first law is "If it does not do exactly what you expect with zero hours consideration or experience, it is a bug in Lisp that should be fixed.
14:19clojurebot'Sea, mhuise.
14:20technomancygold mine going on here: http://replay.web.archive.org/20070712062420/http://brucio.blogspot.com/2006/05/concisification.html
14:20cemerickclojurebot needs to get a new handle; snarkbot, perhaps
14:22technomancyare you saying you fail to recognize that concision is equivalent to powerfulness?
14:23cemerickYeah, I'll say I fail in that department. :-)
14:23technomancyinconcievable.
14:24cemerick"power" is about as meaningful as "elegance", of course
14:25technomancywhat about powerfulness, though?
14:25technomancysee, it's a lot like truthiness.
14:25oklahomabytheseaexpressiveness
14:25amalloytechnomancy: puissance is so much more elegant
14:25oklahomabythesea"ess"es are like isms
14:25bultersexpressivism?
14:25cemerickwhy bother with details when we can simply aggregate things into awesomeness?
14:28bultersare there any "nice" introductions into the java library ecosystem?
14:28bultersTrying to use jgit, but having problems to even get it "installed"
14:32cemerickbulters: No such thing, I think. It's far too large for any single "introduction".
14:33bulterscemerick: I was afraid of that...
14:33cemerickHeh. I figured that would be good news. :-P
14:33bulterscemerick: luckily, I still have the "trial-and-error" option
14:34amalloyyour plan isn't looking so good now, is it
14:35bultersamalloy: depends on what you're stabbing with
14:35edwWit?
14:35amalloyi'll use the java library ecosystem
14:35amalloyas my weapon
14:35amalloyyou won't even know it's me
14:35bultersamalloy: that's not considered stabbing under the geneva convention... it's torture
14:35amalloyheh
15:22ssiderisbulters: any specific questions?
15:28choffsteinI'm assuming "no" is the answer here, but any idea on how I could create a generic http-interface wrapper or queue wrapper for a library I have developed? So let's say I know my library takes a string and returns a string, ideally I want the ability to simply create a wrapper which will handle construction of the input form and link together the routes to call my library appropriately. It's a pattern I keep running
15:28choffsteinacross, and it seems like it would be a cool utility -- especially one that links a library to a queue
15:31dnolenchoffstein: where is difficulty?
15:32bultersssideris: Well, specifically: I would like to know how I include a 'random' java lib (jar) in a lein project
15:32bultersssideris: tried adding it as a dependency in a lein project, but it's not in any of the sources
15:33cemerickbulters: anything added as a dependency must be in a maven repository somewhere
15:34bulterscemerick: so i added org.eclipse.jgit/org.eclipse.jgit "0.10.1" as a dependency, since it's in 'their' repo
15:34edwchoffstein: Have you checked out Lamina (https://github.com/ztellman/lamina)? It provides a golang channel-like abstraction.
15:34cemerickbulters: their?
15:35bultersso I just found out how to add a repository to the project definition
15:35cemerickYou need to add any non-central repository to your project.clj.
15:35cemerickYeah, there you go.
15:35bultersthanks ;-)
15:35hiredmanI kind of doubt that is the group-id/artifact-id of jgit, but I could be wrong
15:36hiredmanhuh, I guess it is
15:36hiredmanyou could just say org.eclipse.jgit
15:36edwWhat is with people who ask a question and then immediately disappear? They're training me never to answer anyone non-regular's questions.
15:36hiredmanlein assumes they are the same if you leave off the namespace part of the symbol
15:36bultershiredman: http://eclipse.org/jgit/download/
15:37bulterslike i made implicitely clear, I'm a complete and utter newbie :P
15:38choffsteindnolen: what do you mean?
15:39choffsteinedw: Haven't seen it. I'll check it out.
15:39choffsteinedw: sorry, business partner walked in the door.
15:40choffsteinUnfortunately, those old face-to-face conversations still take precedent over my irc convos ;) Didn't mean to be rude and disappear there.
15:42edwIt'a not you, personally; but the straw is accumulating on thia x
15:42edwEr, on this camel's back. (Sorry, yogurt spoon malfunction.)
15:43choffsteinhaha. I think Lamina / Aleph may work for me...
15:44choffsteinThough, I would like the webform to be constructed automatically for me too in a perfect world :D
15:44edwIt's pretty cool. I fell in love with everything about Node.js but the fact that it's in JavaScript.
15:46choffsteinMy basic issue is that I have these libraries I build, then I need to give them an interface -- but in my opinion, the interface should be separate from the library. But in the last 3 libraries, the interfaces have all been the same general framework: a web interface with an input page hooked to the background library. After doing it 3 times -- and while it is simple enough to do -- I realized that I could probably
15:46choffsteinfigure out a way to automatically generate the routes and forms given enough information.
15:48edwI'm not following what you're getting at exactly, but it sounds like the sort of problem the duck streams module was designed in response to viz. "I don't care if it' a file or a string or a URL or a whatever."
15:53choffsteinhold on, i'll whip up a gist
15:58choffstein...as I'm writing up this gist, i'm realizing it's probably just as fast to write the base moustache / hiccup code :D
16:03choffsteinSomething insane like this: https://gist.github.com/935346
16:09edwchoffstein: If I'm interpreting your code correctly, I ran up against similar problems when I was writing my Scheme web app framework. Have you considered creating a macro that combines the function definition and interface binding?
16:09choffsteinedw: I have. But I am new to clojure, so I tried to write the macro and went hulk mode :)
16:09choffsteinBut yes, that is exactly what I am talking about!
16:11choffsteinIn my ideal world, I would have the ability to separate the actual function definition and the interface binding, only because I would like to have the opportunity to create an interface for already existing libraries I can't alter
16:12edwI wrote a macro like DEFINE-HANDLER or something that took a route definition regular expression and zero or more EXPRs and wired everything up. And then I exposed procedureal versions so I could bind existing procedures similarly without the need for an extra level of indirection.
16:12edwDude, yeah, what I just said.
16:13choffsteinyes! THAT!
16:13choffsteinDo you still have the scheme code? I'd be interested in porting it to Clojure...
16:14choffsteinIt would probably give me some great experience writing macros
16:14edwI was just off looking for it...
16:14edwThey're in syntax-rules form. Non-hygenic macros make me shudder.
16:19choffsteinI don't know what that means :-\
16:21amalloychoffstein: scheme has a different kind of macro system, more template-oriented i think, in addition to the CL-style "macro as compile-time defn" kind that clojure has
16:21choffsteinah, I see
16:21edwchoffstein: Here's the source: https://gist.github.com/935383
16:21choffsteinedw: much appreciated :)
16:23edwI recommend reading it bottom-to-top.
16:24amalloyedw: is syntax-rules much like haskell's pattern-matching, applied to macros?
16:24amalloyi'm only vaguely familiar with the haskell one, but i know ~nothing about syntax-rules
16:25edwamalloy: Not really. Someone's written a LET-MATCH for Scheme that lets you do a lot of the Haskell-y pattern matching stuff.
16:26edwBut SYNTAX-RULES does employ Haskell-like pattern matching when trying to figure out how it should expand a macro.
16:27edwRe-reading that code, it makes me feel nostalgia for that time...
16:27choffsteinYou know, utilizing hiccup, I don't actually think this would be too hard to reproduce...
16:28edwI would not recommend reinventing the wheel; I wrote this out of spite, mostly.
16:29edwIt was originally called "FuRoR" i.e. "Fuck you, Ruby on Rails."
16:29ieureHah.
16:29ieureedw, You misspelled "Rubby."
16:29edw;)
16:30edwAnd then Paul Graham was talking up Arc, so I wrote a new version showing how unimpressive Arc's framework. (The example's at the bottom of the source file.)
16:31choffsteinHaha. FuRoR ... priceless
16:32edwNever try to give a "Data Modeling for Grown-ups" talk to DHH. He really loves those plural table names. Loves his damn pluralize function.
16:37Somelauwpeople don't like clojure just because it is a lisp
16:37Somelauwwahts wrong wth lisp?
16:37markskilbecktoo many parens
16:38choffsteinedw: Yeah ... RoR has become a language of its own. It's sort of absurd
16:38edwYeah, but Clojure has brackets and brockets.
16:38ieureSomelauw, Nothing, it’s a lizard-brain reaction to that which is different than what is known.
16:38choffsteinI wrote a couple rails 2 apps, but rails 3 seems like a whole new beast.
16:38edwchoffstein: At least every other headline on Hacker News isn't a reference to some world-changing RoR-related "DSL."
16:39choffsteinSomelauw: As someone who just started Clojure and never touched lisp before, I can honestly say it took me all of 1 week to get over the whole parenthesis thing
16:39choffsteinSomelauw: At this point, I find well formatted clojure code just as easy to read as C++ or Ruby ... or any other language I have worked with.
16:40ieurePeople do have a guttural reaction to the parens in Lisp.
16:40ieureBut it’s just that, guttural.
16:40bultersieure: Lot's of people start to get that same kind of bowel-reaction to ror-rails...
16:40choffsteinSomelauw: I think, more likely, people have a hard time with the concept of immutability and using reduce / map. But I think that's why more Ruby programmers are coming to Clojure, because they are used to using functional paradigms on their arrays with the inject and map methods.
16:41choffsteinedw: is that a jab at all the clojure posts on HN?
16:41bultershmm, make that ror-ruby
16:42edwI'm not saying this as a fanboy, but... Lisp code is more like poetry than most other languages that read like prose. You need to stare at Lisp code and think about what it means, whereas e.g. C code is more straightforward. I used to really turned on by elegant C code (see Practice of Programming) but it the more time I spend in Lisp land, the less magic there is even in beautiful C.
16:44edwchoffstein: Not a reference to the Clojure posts. I wish they would go away. I like having a competitive advantage over other people. Same with Node.js. Both require people to think differently, and thus cause a lot of peeople to show up on Freenode and ask questions that make you face-palm.
16:44SomelauwOkay. Yeah, my teacher told us that there is the turing model and the lambda calculus model (he mentioned lisp and haskell) and he said that functional programming doesn't really fit one's brain.
16:44choffsteinLike me :D
16:44SomelauwAnd I didn't really like that statement.
16:45bultersif I would get a dime for every facepalm I induced..... *sigh*
16:45amalloySomelauw: you should find out if a shovel fits your teacher's brain, cause that suggestion is kinda bullshit
16:46Raynesamalloy: +300.3
16:48SomelauwBut it might be hard to find a company that allows you to program in clojure, because your fellows would probably complain that it is unreadable.
16:48choffsteinIs there a resque like library for clojure? It seems like it could be built pretty easily using Aleph...
16:49edwHere's a tip: work for a marketing company or ad agency. I'm sort of a lone wolf here, and no one gives a shit what I use as long as I produce insights and help them make money.
16:50choffsteinSorry -- resque is a ruby library for pushing tasks to redis that can then be polled by background workers
16:50bultersSomelauw: I'm learning Clojure together with a co-worker; hope to do some proof of concepts with him.
16:50bultersSomelauw: The company is open to any language, as longs as it produces results.
16:51edwbulters: What industry?
16:51SomelauwIt would probably mean you need to work alone as a freelancer or something.
16:52chouserThere are several companies using Clojure either exclusively or as a significant component
16:52edwSomelauw: No, because oftentimes clients want assurances that any monkey can pick up where you left off. Thus thus the popularity of Drupal.
16:53mreynoldsedw: Nooooo! Don't do it! Actually, it is a ton of fun, and there's neat problems to solve. But your soooouuullllll!
16:53dnolen_Somelauw: are you studying CS? Seems like an odd thing for a prof to say.
16:54edwmreynolds: I store my soul in a padded box under my feet while I'm at the office.
16:54mreynoldsedw: hehe
16:54mreynoldsedw: As an ex-marketing employee twice over, it's not bad, but I'm glad to now be doing it anymore
16:54bultersedw: web development, we're a ruby shop; mostly
16:54SomelauwYes. I study CS.
16:55bultersedw: but there are a lot of processing tasks that we would like to try in clojure.
16:56edwbulters: Cascalog is the shit. I slurp tons of data from Google Analytics and use Cascalog to do ad targeting.
16:56SomelauwThat prof doesn't teach functional programming. I don't know if he is very good in functional programming himself. Maybe he was just talking about what most people think of FP. Nobody protested, so I think most of the people in the room agreed with him.
16:56bultersedw: I was thinking of porting one of our language processing tasks to clojure
16:56choffsteinbulters: Do background tasks get queued up?
16:57bulterschoffstein: hell yeah ;-)
16:57bulterschoffstein: and it's a long queue... most of the time
16:57bultersusually gets depleted after the weekend...
16:57choffsteinSomelauw: Most people aren't introduced to FP except in school. I didn't know about it until my sophomore year and I had been a self-taught programmer for 7 years before that
16:57choffsteinbulters: So it shouldn't be so hard to just get a clojure background worker going, right? What queue system do you use, if you don't mind me asking?
16:58bultersSomelauw: I got absolutely NO FP in my BSc. programme; only some prolog
16:58choffsteinI'm trying to figure out the math behind a redis based queue (resque), but I don't understand how workers know what keys to use...
16:58bulterschoffstein: everything ruby, so it's all resque now.
16:58choffsteinDo you understand the backend of it? How in the world do workers know how to pull jobs without the keys?
16:59choffsteinWell, CMU just introduced their first FP class recently, right? CMU is arguably one of the best CS programs in the US...
16:59choffsteinMy FP class at Cornell was actually pretty cool. It was in SML/NJ, but I think they switched to O'Caml a year or two after...
16:59fliebelCould anyone look over my shoulder on this one? https://gist.github.com/934781 On line 45 I check if the future is still busy consuming the seq, and if so, wait for a value. The thing is that there seems to be a tiny timeframe where the last item has been consumed but the future has not finished yet. This causes the .take to wait forever.
17:01bulterschoffstein: drop me a line tomorrow, really have to go to bed now; sorry. But would like to answer your questions on resque if not answered by then.
17:01choffsteinwill do
17:01bulterscool.
17:01choffsteinmaybe i'll drop into #ruby *shudder*
17:02bultersyou intro extreme sports? ;-)
17:02bultersanyway... g'night everyone.
17:03choffsteinfliebel: That code is above me. Sorry :(
17:04hiredmanfliebel: you should use a sentinal (Object.)
17:05hiredmanif you take, and the object you took = the sentinal then you are done
17:05hiredman,(= (Object.) (Object.))
17:05clojurebotfalse
17:05fliebelhiredman: that is what clojojure.core is doing. Sentinels don't go well with priority queues.
17:06hiredmanfliebel: well, then live with your race condition
17:06fliebelwhich is more, 5 or (Object.)?
17:08fliebelhiredman: Hm, well, neither are very acceptable for me. So I'll have to rethink the whole idea.
17:08hiredmanfliebel: give that 5 is some number of bits sitting in memory, and (Object.) is some number of bits as well, and they don't mean anything until I choose to interpret them, I can say whichever I want is greater
17:08hiredmangiven
17:08fliebelhiredman: well, depending of what you choose, the sentinal might get out of the queue before the last value.
17:09hiredmanfliebel: then you aren't doing it right
17:09dnolen_fliebel: PriorityBlockingQueue takes comparator, how come you can't just pass a comparator that guarantees the sentinel is always last? (I don't know much about this stuff)
17:10fliebeldnolen_: I could, but seque allows any BlockingQueue to be passed in, so I want to make it work for any of them.
17:11fliebelIt's just that I have to find a way to correctly synchronize the end of the seq with the consumer, without involving the queue.
17:15fliebelanyway, I need sleep. I'll think about it tomorrow.
17:36choffsteinAnyone know of an available background worker queue library for clojure along the lines of github's resque for ruby?
17:36choffsteinI know bandalore is one that uses amazon SQS
17:37hiredmanthere are a lot of queue libraries for clojure
17:45choffsteinmmm, spine seems like a good one with beanstalk
17:46seancorfieldQ about promise... is there any way to inspect a promise to find out whether it has been delivered?
17:48seancorfieldhmm, looks like realized? in 1.3.0 will do that
17:48seancorfieldnm
17:53mreynoldsMan, I totally missed the yegge kerflufle. I now also feel strange for not caring about ordering functions in clojure code. As a Java convert, I guess I don't care? I just moved them and kept going. I don't get why people care so intensely.
18:01nickikmreynols, i think everybody blow it out of proportion. If you read the hole hackernews debate most people acually argue that "pro rich".
18:02seancorfield,(clojure-version)
18:02clojurebot"1.2.0"
18:02seancorfieldnot helpful :)
18:02seancorfield##(clojure-version)
18:02sexpbot⟹ "1.2.0"
18:02seancorfieldbah...
18:02mreynoldsnickik: Yeah, I'm just finishing it up now. I don't even get a "pro rich" more just a "WTF dude" vibe towards people complaining about the language and culture.
18:02seancorfieldso i looked in the 1.3.0 source code and there's realized? at the bottom of core... but it doesn't seem to be in the latest master SNAPSHOT
18:04dnolen_hmm so swank-clojure 1.3.0 doesn't work with clojure 1.3.0-alpha6 ?
18:04dnolen_seancorfield: I think you might need to build from source.
18:05technomancydnolen_: correct
18:06dnolen_technomancy: huh, but I see that it works fine with HEAD
18:06technomancyoh cool
18:06seancorfielddnolen_: doesn't hudson build the snapshot every time it changes?
18:07seancorfieldrealized? was committed march 18th and the snapshot should be april 19th if i'm reading things right
18:08dnolen_technomancy: well, looks like the cyclic dependency checking code is effed.
18:09technomancydnolen_: swank's or clojure's?
18:09dnolen_oh, take that back, it's does the right thing.
18:10dnolen_clojure's
18:20dnolen_false alarm, clojure 1.3.0 master and swank-clojure 1.3.0 work beautifully together.
18:27technomancypleasant news
18:27Apage43i feel like i should learn emacs one day
18:29carllercheIt seems strange to me that there isn't a lazy map that comes w/ clojure (I found a couple libs out there for it). Is it not idiomatic to a lazy map?
18:32technomancycarllerche: what's the difference between a lazy map and a memoized function?
18:33hiredmancarllerche: I would recommend just using a map of keys=>delays
18:33carllerchei don't know... I guess I should look at memoized functions :P
18:33carllerchewell, i guess I have my answer :)
18:35currentBI'm trying to read a file but spaces keep being read as "^@" and causing parse errors. I'm guessing this is an encoding issue but does anyone know a good way to solve it?
18:36currentBI've been messing with java Charset stuff for awhile but to no avail
18:41carllerchetechnomancy: so, i guess the difference would be you could do (:foo lazy-map) instead of ((:foo lazy-map)) ?
18:41carllercheprobably doesn't matter
18:41amalloycarllerche: ((:foo lazy-map)) is not what i think he meant
18:42carllerchei understood it as putting memoized functions in a map?
18:42amalloycarllerche: a memoized function *is* a lazy map
18:43amalloy&(let [lazy-map (memoize println)] (take 3 (repeatedly #(lazy-map 5))))
18:43sexpbot⟹ (5nil nil nil)
18:43amalloyit calls (println 5) exactly once, caches the nil, and returns that on later lookups
18:43technomancywell, you can't call keys/vals or keywords on it. but it's the same thing otherwise.
18:45carllercheIt's not a collection though
18:46technomancyright, but that has more to do with clojure's built-in memoization than anything else.
18:46technomancywith a smarter cache it could be
18:47carllerchei guess my goal is that I want a map (can look up by key and is a collection), but populating it up front is expensive and all the keys are not always accessed
18:47carllercheI'm probably thinking about the problem wrong
18:49technomancynot necessarily. it shouldn't be hard to reify a lazy map around a smarter memoization cache like http://kotka.de/blog/2010/03/memoize_done_right.html
18:51carllerchei'll read the article
19:15seancorfieldtechnomancy: is it a known issue that leiningen doesn't search the sonatype repo by default? (and thus 1.3.0-master-SNAPSHOT pulls an outdated snapshot from build.clojure.org)
19:17seancorfieldi guess i should phrase that as "is it a deliberate decision or just an artifact of leiningen not having caught up with recent changes in clojure build processes?"
19:18technomancyis build.clojure.org retired?
19:21technomancyclojars transparently proxies to build.clojure.org, so it should be removed from the list anyway.
19:21technomancyI really want to move away from including snapshot repos by default in lein
19:22technomancyI've been waiting for 2.0 since with Clojars it will be a breaking change. but if clojure/core is doing the breaking for me with b.c.o then I'll just go ahead and drop it now.
19:23technomancyjust gotta slap a big ol' FAQ on that, because people are going to wonder.
19:32micahmartinAnyone know why (compile 'clojure.contrib.def) doesn't generate any .class files?
19:33micahmartinWhen I try to run my precompile project, I get: java.io.FileNotFoundException: Could not locate clojure/contrib/def__init.class or clojure/contrib/def.clj on classpath
19:34seancorfieldtechnomancy: 'kthx .. i guess it wouldn't have saved me any time or frustration if clojars still let me pull an old snapshot .. but if you disable snapshots by default (and perhaps require people to specify a snapshots repo?) then i could only have gotten a snapshot from the right place
19:35micahmartincompojure.core uses clojure.contrib.def
19:35technomancyseancorfield: well clojars still needs some work to separate out snapshots and releases into their own repos
19:35technomancyright now everything goes into the mosh pit.
19:35seancorfieldah, the mosh pit... happy days...
19:36technomancyincidentally, if anyone's looking for a good web-centric high-profile getting-started project ...
19:36seancorfieldmust admit, i'm not wild about depending on snapshot for clojure core since this code will go to production "soon" but they keep adding useful stuff :)
19:36technomancy^^^
19:38technomancyhuh; most of the goodies I was interested in made it into 1.2.1
19:42TimMcamalloy: botsnack!
19:43amalloywzt? *looks around, confused*
19:43TimMc$findarg map % ["botsnack" "amalloy"] [8 7]
19:43sexpbot[clojure.core/count]
19:44TimMc:-)
19:48devnso im using a library where the macro lets unbound vars leak in -- what im trying to do is find a way around it by determining what is unbound ahead of time to generate a function that takes named arguments for unbound symbols in the macro's output
19:48devnanyone have any suggestions on where to look/start?
19:49hiredmanis there a good reason to use the library? if it's not any good, why use it?
19:49devnplanning on fixing it, but am more interested in the idea of making this work
19:50hiredmanbound as in has a root value, or bound as in binding?
19:50devnbinding
19:51hiredmanbasically, the answer is, read Var.java
19:52pjstadig(bound? #'some-var)
19:53hiredmanpjstadig: that depends on waht version of clojure you are on
19:53hiredmanbut it might be in 1.2, which should be everywhere
19:53pjstadigworks in 1.2 what version are you expecting?
19:54hiredmandunno, it wasn't always there and didn't know when it was added
19:54pjstadigbut bound? returns true when a var has a root binding
19:55pjstadigif you want to know if it is a binding binding, then maybe a different story
19:56pjstadig(doc binding?)
19:56clojurebotHuh?
19:56pjstadighehe uh
19:56pjstadig,(doc binding?)
19:56clojurebotNo entiendo
19:56hiredman,*clojure-version*
19:56clojurebot{:major 1, :minor 2, :incremental 0, :qualifier ""}
19:57hiredman,(doc thread-bound?)
19:57clojurebot"([& vars]); Returns true if all of the vars provided as arguments have thread-local bindings. Implies that set!'ing the provided vars will succeed. Returns true if no vars are provided."
19:57pjstadigduh right
19:57pjstadig,(doc bound?)
19:57clojurebot"([& vars]); Returns true if all of the vars provided as arguments have any bound value, root or thread-local. Implies that deref'ing the provided vars will succeed. Returns true if no vars are provided."
21:52znutar_I'm kinda confused as to why (defrecord foo [x]) (foo. 4) works but (apply foo. (4)) doesn't
21:53znutar_I mean other than just it being somehow special because it's a ctor
21:56dnolenznutar_: defrecord creates Java classes, ctors are not first class, you need to create your own ctor fn. There's some work being done one figuring out how this will be done automatically for you.
22:03znutar_ah, I was assuming they were magically promoted to first classiness. Thanks!
22:04ieureWe try to keep classiness to a minimum.
22:12devnheh
22:12devnI've admirably succeeded at that very task for years!