#clojure logs

2009-09-06

00:02prospero_forget anything you've imported
00:02prospero_start with a clean slate
00:43poet(doto (JFrame.) (add (JLabel. "Hello World")) pack show) gives "Unable to resolve class JFrame" Any idea why?
00:45hiredmanhave you imported the class?
00:46hiredmanyou are going to have other issues with the method calls in the doto
00:46hiredmanthe method names need to be prefixed with a .
00:46hiredman.pack .add .show
00:46arbschtthat's from an old example
00:47poetahhh gotcha
00:47poetyeah it's from one of the clojure vidoes on blip.tv from 2009
00:47poet*2008
00:48arbschtpoet: try this for a somewhat idiomatic, current and substantial example http://gist.github.com/164652
00:49poetarbscht: nice, thanks
01:08prospero_I'm walking an expression tree, and trying to pretty print each node
01:08prospero_it's coming out garbled
01:08prospero_<-
01:08prospero_(<-a
01:08prospero_ a+(+vec2
01:08prospero_(vec2 1 1) (vec2 1 1)vec2
01:08prospero_(vec2 1 1) (vec2 1 1))
01:08prospero_ (+ (vec2 1 1) (vec2 1 1)))((<- a (+ (vec2 1 1) (vec2 1 1))))
01:08prospero_it's all interleaved, for reasons that I don't really understand
01:09prospero_has anyone seen this before?
01:09prospero_if I replace the expression with a constant list, like [1 2 3], it comes out perfectly fine
01:10prospero_that is, if I just call (pprint [1 2 3]) instead of (pprint expr), it comes out fine
01:19prospero_ok, so I guess it's a bit much to assume someone's seen something exactly like this before
01:19prospero_I don't think there's any concurrency at work here, but would that cause this behavior?
01:20prospero_are writes to *out* atomic?
01:35LauJensenTop of the morning gents
03:26LauJensen1For the DZoners among you: http://www.dzone.com/links/best_in_class_the_blog.html
03:33wavistergoing to start using refs, and i'm a little shaky on one concept. if I'm just reading a set of refs, should I open a dosync and then call ensure on all the refs I'm reading to be sure that between the beginning of the function and the end of the function a transaction isn't committed that changes all my data?
03:34tomojwavister: I don't think that matters
03:34tomojyou get a snapshot in the transaction
03:34LauJensen1~ensure
03:34clojurebotI don't understand.
03:34wavisterso just open a dosync and deref with @?
03:34tomojeven if some commit happens in the middle of your dosync, you still see the old values
03:34LauJensen1Rich offered a really good explanation on ensure vs write-skew, lemme see if I can find it
03:35tomojbut there is some reason for ensure, I just don't understand it yet
03:35LauJensen1wavister: You can read outside of a dosync, there are no reader locks
03:35hiredmanerm
03:35hiredmanif you want a consistant snapshot between all the refs, I am pretty sure you need ensure
03:35tomojoh?
03:36hiredmanyes
03:36tomojants.clj doesn't have any ensure
03:36LauJensen1ensure basically locks the ref from modifications coming from outside your own transaction and gives you the in-transaction value of that ref
03:36hiredmanI could be wrong
03:37wavisteri understood the primary reason for ensure being that if you're not modifying a value, but it's dependent on what you are modifying, you should just put a token ensure in there to keep it part of the same data set
03:37wavisterbut i'm just reading
03:38wavisterso maybe a doseq is all i need
03:38hiredmandependent?
03:38wavisteri mean dosync
03:38tomojif you're just reading I think ensure is unnecessary, but I am more likely to be wrong than hiredman
03:39tomojI mean, the problem ensure solves is _write_ skew, huh?
03:39LauJensen1If you are using a reference in a transaction, and the output of that transaction affects something else. Then you need to ensure that your ref maintains its value throughout your transaction right? Thats what its there for. yes to solve write_skew
03:40tomojthat's if you're only reading one ref and then writing some other ref based on the read value?
03:40wavisterok i think we're saying the same thing i just said it funny
03:40hiredmanI withdraw my earlier statement, I now believe tomoj is correct
03:40tomojyou do need a dosync though if you want a snapshot, right?
03:40LauJensen1Yep
03:41wavisteri do want a snapshot. ok I'm good. thankies.
03:44wavisteranyone interested in neural nets around here? i'm writing a basic feed-forward neural net function which i could share if the first round of testing goes ok.
03:56tomojwavister: yep
03:56tomojI actually started working on some nnet stuff in clojure
03:57tomojspecifically I'm interested in writing an implementation of ken stanley's neat and hyperneat
03:57tomojthe current implementations are all in languages I hate and the code is _nasty_
03:58wavisternot neat, huh?
03:58tomojI tried digging into one of them and every other line was like `if DEBUG_FOO_FEATURE`
03:58wavisteri'm not familiar with them
03:58tomojit's pretty cool
03:58tomojhttp://www.cs.ucf.edu/~kstanley/neat.html
03:58tomojor perhaps http://en.wikipedia.org/wiki/NeuroEvolution_of_Augmenting_Topologies
03:59tomojwith neat you evolve neural networks with arbitrary topologies using a genetic algorithm
03:59tomojwith hyperneat you evolve these networks which describe a different network's connections in a multi-dimensional vector space... mind-bending stuff
04:00tomojvery cool thing about hyperneat is you've got this network (they call them CPPNs - compositional pattern producing networks) which describes the connection weights for another network, but the CPPN has infinite resolution
04:01tomojso if you're, say, doing image processing, and you start out with a 20x20 input layer, you can use the evolved CPPN to give weights for a network with a 100x100 input layer, or a 1000x1000 input layer
04:02wavisterinfinite... so it's continuous, or lazy?
04:02tomojthe CPPN is continuous
04:02wavisterah nice. analog is back.
04:02wavisterthat is sexy
04:02tomojbasically the CPPN is a network that takes pairs of node coordinates as input and outputs a connection weight
04:03tomojso you've got a structure laid out for your neural network, and to get the weights between each pair of nodes, you ask the CPPN, which is a network of compositions of continuous functions
04:04tomojso you can increase the resolution of your network and the CPPN will give the higher-res network a similar overall structure as the previous low-res version
04:05wavistermakes sense intuitively, but the "network of compositions" part is fuzzy
04:05wavisteri will definitely do some looking into this
04:06tomojhttp://eplex.cs.ucf.edu/hyperNEATpage/HyperNEAT.html
04:06wavisteryes, i found that one
04:06wavisteri'll need to do some reading
04:06tomojunfortunately the papers seem to underspecify the algorithms :(
04:07tomojand it's really hard for me to understand the code that's been written, especially since even if I could understand what it was doing, I'd still have to figure out a totally different way to do it since this is clojure
04:08tomojanyway I'd love to take a look at your code sometime
04:08wavisterwell i don't pretend to be immersed in the field, but we could powow on this if you like. i'm semi-active in an AI community
04:09tomojyeah, that'd be awesome
04:09tomojhow long have you clojured?
04:10tomojhere's what I've done so far: https://gist.github.com/8d58e8f912dcaa24e7d1
04:10tomojit's gross.
04:11wavisteri haven't been clojuring for long... either that or i learn slow. i feel like a noob still. maybe a month or two
04:11tomojI think that's about how long I've been doing it
04:11tomojI still feel like a noob as well
05:44Fossihi
05:55winterstreamIs there a multimethod I can override in order to get the str function to return a string representation of my object?
06:03tomoj~def str
06:04tomojdoesn't look like it
06:04hiredman,(doc print-method)
06:04clojurebot"; "
06:04hiredmanclojurebot: bah!
06:04clojurebotExcuse me?
06:05hiredmanstr calls .toString
06:07tomojso you can dispatch printing to a writer on type
06:07tomoj?
06:07clojurebottrampoline is http://groups.google.com/group/clojure/browse_thread/thread/6257cbc4454bcb85/3addf875319c5c10?#3addf875319c5c10
06:07tomojwat
06:08hiredmanpardon?
06:10hiredman,(doc *print-dup*)
06:10clojurebot"; When set to logical true, objects will be printed in a way that preserves their type when read in later. Defaults to false."
06:11hiredmanwhen using print dup there is a multimethod print-method you can hook into
06:29winterstreamhiredman: Thanks; I'll look into that.
08:11ambientis there any better way to express "(if (not (seq foo)) foo (recur (rest foo)))"?
08:11ambientshorter, more compact
08:11ambientinside loop/recur
08:11LauJensen(if-not (seq foo)) ?
08:12ambientthere's no (empty foo)? for sequences
08:12LauJensen,(empty? [])
08:12clojurebottrue
08:12ambientcool :p
08:12ambientnow i feel i should've rtfm:d more
08:13LauJensenNo no thats what we're here for
08:13ambient:D nice
08:13LauJensenThe documentation is where we go, if Chouser fails :)
08:14hiredmanthat looks like last
08:14hiredmanor empty
08:15hiredman,(empty '(1 2 3 4))
08:15clojurebot()
08:15hiredman,(last '(1 2 3 4))
08:15clojurebot4
08:15Fossihow do distinct and set compare performancewise?
08:16ambienttry it with (time)
08:16hiredman~def distinct
08:16ericthorsenIs it possible to get a macro to output a def with meta data? (def #^{:private true} fred)
08:17hiredmannot like that
08:17Fossinot with the reader macro
08:17hiredman#^{} is reader syntax
08:17Fossiat least not if you don't want to read it runtime :)
08:17ericthorsenunderstood
08:17Chousuke~def defn-
08:18Chousukesee there for an example :P
08:18Chousukethough hm, I guess that's not so good.
08:19Chousukebecause it doesn't use `
08:20Chousukeyou can also do `(defn ~(with-meta name (merge (meta name) {:private true})) ...)
08:20ericthorsenthat is where i was looking
08:20ericthorsenthat is where i got to
08:21Fossihmmm. the repl does not like printing (range 100k) :D
08:21ericthorsenChouser: my problem must be elsewhere...let me take another look. thx!
08:23Fossiseems distinct is faster on smaller sets
08:23Fossiwhich makes sense :)
08:25Chousukedistinct is also lazy :p
08:26LauJensen~def distinct
08:29LauJensenGents, I posed this on DZone this morning and for some reason I dont see it in 'new links', why? http://www.dzone.com/links/best_in_class_the_blog.html
08:34mikem`~def println
09:18icemazeHi, I'm thinking about opening a ticket but I'd like some clarification. Is there anyone who can help?
09:22hiredmanticket for what?
09:23icemazeI have a performance problem where clojure code is MUCH slower than equivalent Java. I read some performance-related articles and applied type coercions but my code is still 250x slower than Java. I was wondering if there might be a problem with my code.
09:24hiredmansounds believable
09:24icemazeAlso, is this a valid reason to open a ticket. I believe it is since on clojure.org it is implied that clojure should have good performance.
09:24hiredmanhave you brought it up on the mailing list?
09:24hiredman(google group)
09:24icemazenope, I tried sending an email but it was rejected. You think I should subscribe?
09:25hiredmanrejected? are you sure?
09:25icemazeBecause I wasn't subscribed
09:25hiredmanthe first email snet to the group is modereated so sometimes there is a delay
09:26icemazequote:
09:26icemazeWe're writing to let you know that the group that you tried to contact
09:26icemaze(clojure-dev) either doesn't exist, or you don't have permission to post to it.
09:26hiredmanoh
09:26hiredmanwrong group
09:26hiredman~group
09:26clojurebotgroup is http://groups.google.com/group/clojure/
09:26icemazeoh, ok thanks.
09:30hiredman~performance
09:30clojurebothttp://clojure.org/java_interop#toc46
09:32icemazeThank you again. I'll try a couple of things before posting.
11:25hchbawHi, I just wrote swank_fuzzy.clj for Emacs/SLIME!
11:28hchbawPlease get it from http://gist.github.com/179737 if you like. Thanks.
11:40Chousukehchbaw: neat. did you send it to the swank-clojure maintainer already?
11:40hchbawChousuke: Yes, I did.
11:52hchbawChousuke: Are you using SLIME?
11:55Chousukehchbaw: yeah.
11:55hchbawChousuke: If you using anything.el also, please take a look this,
11:56hchbawChousuke: http://wiki.github.com/hchbaw/anything-slime.el/commandlistinaction
11:57hchbawChousuke: That is SLIME + anything.el combination :)
12:00Chousukehmm, I can't seem to get that fuzzy completion to work
12:01ChousukeI just get a beep and "insert: Format specifier doesn't match argument type" in *messages*
12:01Chousukeis there something I need to do besides applying your patch to swank-clojure?
12:01hchbawOh sorry.
12:02hchbawI take a look.
12:04hchbawChousuke: Sorry, SLIME version please?
12:05Chousukehmm, I'm not sure, actually. apparently rather old :/
12:05Chousukeit's a git checkout, and the latest commit date seems to be "Sun May 17"
12:07hchbawSorry, mine is "Thu Sep 3". Using this git://github.com/nablaone/slime.git
12:08hchbawPlease upgrade?
12:10ChousukeI will, a moment.
12:15Chousukeit works now.
12:16hchbawyey!
12:18angermanhow would we setup a performance meter? To get an idea on how fast clojure is on a given host?
12:21hiredmanfunction calls per second
12:24angermanhiredman: do we have a benchmark toolbox?
12:24Chousuke:P
12:24hiredmannot that I am aware of
12:25hiredmanwe could steal some badly written inefficent project euler solution
12:26hiredmancall it "one standard clojure" and then on fast machines could say "this machine gets *two* standard clojures!"
12:26angermanhmm... maybe some map/reduce flops thing.
12:27hiredmanit would looks similar to a test
12:27hiredmana set of functions, a set of input, how long does it take the functions to run
12:29angermanok, so we don't have any default solution for that yet.
12:41duck1123Can anyone think of any possible reason why I would be getting a no such var exception when that the fn I'm calling is in a ns that's being used?
12:42duck1123I can't understand why it's not seeing it, this was a simple refactor
12:42hiredmanhow are you calling it?
12:42Lau_of_DKpaste it?
12:43duck1123hold on
12:49duck1123http://gist.github.com/181867
12:49duck1123sorry, there's a lot to this, and I tried to cut it down
12:49duck1123I'm almost ready to just publish this thing openly, but I don't want to publish all the history
12:50duck1123I have tried with and without fully qualifying the call to redirect
12:51hiredmanwhat happens if you declare redirect?
12:51duck1123in model.auth?
12:52duck1123it's declared in view
12:54duck1123I'm in the process of factoring out all the calls to redirect and moving them to view.auth, but I just can't understand why it's not seeing it
12:54duck1123and as my build is failing, I can't get into slime
12:55LauJensenIts when you load the namespace that it fails ?
12:55hiredmancan you put a (use 'net.mycyclopedia.view) right after (ns …) in auth
12:56duck1123This is during AOT compile
12:57duck1123the auth module gets compiled early on in the build process
12:57hiredmanyou know
12:57hiredmanyou have a circular dependency there
12:58hiredmanI wonder if that is the problem
12:58duck1123you're right
12:59duck1123I just added the dependency on view in model.auth to support the refactor of redirect
12:59duck1123my models shouldn't have a dependency on anything in view
13:00duck1123I guess I'm just going to have to take this refactor a bit deeper
13:02LauJensen1duck1123: the paste was a little confusing to me, but one time I felt like Clojure was running around corners with me, I had a 'used' or 'required' a namespace before one of its dependencies, and it took a while to track down :)
13:04duck1123yeah that's definitely what's going on here. It's a design flaw on my part really, but I only uncovered it when I went to go correct it.
13:05duck1123This auth module is the tricky one because it's the only one that doesn't correspond to a table in my database.
13:05LauJensen1Ok, you sorted it out now ?
13:06duck1123not yet, but I'm confident that when I remove any reference to redirect from model.auth, the problem will go away :)
13:07LauJensen1Alright - If not, put it on Gitorious (next to ClojureQL), and we'll have a look :)
13:09duck1123I'm a clj-record guy myself
13:09duck1123I forked clj-record to give it some very nice features
13:10duck1123I've been toying with the idea of re-writing clj-record so that it uses clojureql internally
13:10LauJensen1I didnt know about clj-record, whats it do ?
13:11duck1123it's an orm for clojure
13:11duck1123let me paste some code so you can see it in action
13:11LauJensen1~clj-record
13:11clojurebotExcuse me?
13:11LauJensen1Great, thanks
13:12duck1123http://gist.github.com/181873
13:12duck1123model.statement from my code
13:13duck1123look at find-records
13:13LauJensen1I see, interesting
13:14duck1123I think one of the simpler files may have been netter
13:14duck1123but i add metadata of the model on every element returned
13:14duck1123that allowed me to write multimethods that dispatched on the type of record
13:15LauJensen1Yea, thats what we do in the backend actually
13:17duck1123see, I had to hobble together my own sql generation for my branch, I know I could use clojureql and benefit from it
13:17duck1123but if i recall correctly, there was something that i was doing in mine that couldn't be done in yours
13:18duck1123do you limit?
13:19LauJensen1I think kota just implemented it, its on our task list at least
13:19LauJensen1And in some sense, you get take for free, because resultsetseq is lazy :)
13:23duck1123John and I have some differences of opinions on names and whatnot, that's why my branch wasn't fully merged, but it's been working great for my purposes
13:23duck1123I swear, I deleted so much code, it was sad yet great
13:23angermanis there some pretty-printer for clojure that does backet indentation?
13:24duck1123I think pprint is the best you get
13:25duck1123I've been wanting to make generators for models for my project, but I couldn't find anything I liked, so I did something else
13:29Fossihchbaw: looks cool. will try
13:31hchbawFossi: Good luck :)
15:08cemerickhas anyone taken the time to implementing RB trees (or some other balanced tree construction) using zip?
15:08cemerickimplement*
16:13rhickeycemerick: vs sorted-set/map?
16:13cemerickrhickey: yeah, something that could be extensible / easily augmented
16:14rhickeyextended in what way?
16:15cemericke.g. for interval trees
16:16cemerickaggregate data, more generally
16:17rhickeydoesn't a user-supplied comparator let you do what you want?
16:18cemerickno, because efficient window queries given overlapping intervals requires maintaining a :max entry on each node
16:21rhickeydo you have an example of a RB tree that would let you extend it in this way?
16:22danlarkintechnomancy joins to roll some heads
16:22technomancythat's right... heads: watch out
16:22cemerickScala has a generalized RB tree framework that I used back in the day (e.g. 1.5 yrs ago, maybe more) to decorate nodes as necessary with aggregate data. They just went through a big refurb in their data structures though, so I've no idea whether that's there anymore.
16:23cemericktree-balancing is just a painful thing to keep dealing with...seems like a problem worth solving once (and for all?) well, in a way that others can just focus on the data model.
16:24rhickeyit's not just a decoration though, you need to maintain it during rotations etc, right?
16:25cemerickyeah; if I remember right, the scala framework had an interface one implemented where you could plug in implementations for adjusting nodes on a right rotation, left rotation, etc.
16:25cemerickThe pattern-matching folks are just laughing at me now. :-)
16:25technomancydanlarkin: how goes?
16:26danlarkintechnomancy: good... I'm finishing my re-setup after reformatting. *grubmles*
16:26technomancydanlarkin: ah, that can be a pain if you haven't automated it.
16:26technomancyat least now your filesystem is case-sensitive! =)
16:28danlarkinyes! I'm a grown up now
16:50dthomasHi. Is there a good way to get the value associated with all the base keys, in order, from a struct "instance"?
16:52dthomasOr, alternatively, is there a way to get all the base keys of a struct [in order]?
17:01jenslidthomas, just to create one and call (keys ...) on it should work i think.
17:02jensliOh, you said values...
17:02Fossihmmm. seems send-body of http.client only supports strings, maps and InputStreams. what is the prefered way of converting a byte-seq into one of them?
17:02FossiByteArrayInputStream?
17:03dthomasjensli: (keys some-struct) would return all the keys, not just the base keys, right?
17:03technomancyFossi: that would be my guess
17:03Fossido i need to call anything on the seq?
17:03dthomasjensli: My goal is to get the value of all base keys in the struct instance, but I could easily accomplish that if I had a way to get all the base keys in the struct "type."
17:03jensliThen create a new struct, call (keys ...) use those keys to extraxt the right values of your struct, with select-keys?
17:04Fossito-array or such?
17:04jensliShould be a cleaner way maybe.
17:05dthomasjensli: Good point, but agreed that seems ugly.
17:05jensliNo, not select-keys, but something else.
17:06jensliYou could make a global list *your-struct-keys* so you dont have to do that every time.
17:06dthomasMaybe there's an exposed but undocumented way to get the struct keys off a PersistentStructMap.Def, I haven't look at its source.
17:06dthomasjensli: Yeah, that's what I'm doing right now.
17:06Fossi"[Ljava.lang.Byte; cannot be cast to [B" hmmmm
17:08Fossiand there's no "byte-array" either
17:09Chousuke(into-array Byte/TYPE ...)?
17:10Fossii was about to ask that
17:10Chousukestill, that'll make a full copy of the seq :/
17:10Chousukebest would be a seq -> InputStream adapter I guess.
17:11Fossiwell, it's not used often, so i don't care for now
17:11Fossii'm just uploading user images :)
17:11Fossiway to the server works
17:11Fossinow, i just need to fix the other way around
17:15technomancydanlarkin: merging a few patches from various contributors
17:15technomancyor clojure-http-client
17:16danlarkintechnomancy: oof, haven't looked at that in a while
17:22technomancyyeah, me neither
17:23technomancysome of these patches are 2 months old
17:23technomancycourse, one of these starter kit patches was from February... /me hides in shame
17:23Fossireminds me to finally commit the couchdb patches
17:24Fossijust added multi-key POST today
17:27technomancynice!
17:31Fossihmmm. damn. somehow i get a String array back from attachment-get
17:34Fossiok. seems to be on purpose
17:34Fossikinda defies my try of saving the user images in couchdb
17:34Fossibut that's for tomorrow then
17:34Fossig'n8
18:03dthomasIs there any kind of consensus about the wisdom of using 1.0 for development? Should I be using Clojure (and contrib) from Git master instead? Are they typically usable?
18:04ambientbeen wondering the same thing, if i should use 1.0 instead of git master
18:04dthomasFor example I think I've found that contrib.http.agent has changed significant post-1.0, so the docs on the web are unhelpful. (I can get past that issue; but I'm wondering if it's an indication that I'll be fighting an uphill battle by using 1.0.)
18:07technomancydthomas: using the clojure-1.0-compat branch of contrib is recommended in that case
18:07technomancysticking with 1.0 is definitely the safer route
18:07dthomasPre-1.0 I was used to updating every so often, and updating contrib and all the Emacs stuff along with it, including the occasional breakage or out-of-sync components. It wasn't a huge problem, but I figured I could avoid it by using 1.0. I'm wondering if the majority of the community is working off of master, though, not the release.
18:08dthomastechnomancy: Yeah, I found the 1.0 contrib branch.
18:08clojurebottechnomancy is to blame for all failures
18:13technomancyclojurebot: botsmack!
18:13clojurebotGabh mo leithscéal?
18:14technomancydthomas: clojure-mode now only syncs against last-known-good revisions to avoid that problem
18:15technomancyI suspect the majority of clojure devs stick with 1.0. I generally only check out master if I'm working on patches.
18:17dthomastechnomancy: Good point of data, thanks.
18:22technomancycalling it "data" might be a little generous... it's a guess. =)
18:25dthomastechnomancy: Well, it's a data point nonetheless, and from someone who seems to have a lot more Clojure experience than I do, so your guess is probably much better than any I'd make. :)
20:56triddellso where on assembla should I submit a patch against an issue?
20:57triddellissue #104 requires a simple patch
20:57triddellbut I don't see where I create a new activity with an attachment
20:58triddellif that is the right way to submit a patch
21:23Chousertriddell: if you're a member you should be able to attach a file to the ticket
23:09poetAny pointers to some resources about packing an application for distribution?