#clojure logs

2010-02-18

00:06chouserlancepantz: your probably can just say data instead of (into {} date)
00:07lancepantzi'll give it a shot
00:07chouserif data is a seq of k/v pairs, like '((k1 v1) (k2 v2) ...) then that inner into is not needed
00:27TheBusbyhmm, any idea clojure might say that a method doesn't exist in java interop when it should?
00:27TheBusbyspecifically,
00:27TheBusbyspecifically, $ cd projects/robot/
00:27TheBusby$ ls
00:27TheBusbyfindbug robot.clj
00:27TheBusbyer, sorry
00:27TheBusbyI mean, specifically, "No matching method found: getPixels for class sun.awt.image.ByteInterleavedRaster"
00:30chouserthat may mean the arguments you're trying to pass in are of the wrong type
00:30TheBusbyahh, found it, an arity issue
00:31TheBusbytoo many things called getPixels inheriting from one another...
01:12slyphonif i have a map, is it possible to call struct-map with the k/v pairs in that map as arguments?
01:13slyphonwithout using a macro?
01:31dnolenslyphon: (apply struct-map foo (flatten (vec {:bar 1 :baz 2})))
01:32dnolenflatten is from clojure.contrib.seq-utils
01:32slyphonahhh
01:32slyphoni was looking for that
01:35slyphoni wound up doing ( let [m {:foo 1 :bar 2}] (apply struct-map blah (interleave (keys m) (vals m)))
01:36nteonhi folks
01:37nteonI was hoping someone could tell me why line 25 works, but 26 throws an exception in this: http://fpaste.org/w62B/
01:48hiredmannteon: "an exception" surely it is a certain type of exception
01:49hiredmanand the exception comes with a helpful message
01:49nteonhiredman: yes sir: http://fpaste.org/U7dA/
01:51hiredmanthere is no var var-string
01:52hiredman,(read-string "#'foo")
01:52clojurebot(var foo)
01:52hiredman,(read-string "#'my-var-string")
01:52clojurebot(var my-var-string)
01:53hiredmanvar does not eval it's arguments, it is a special form
01:53hiredman,(doc resolve)
01:53clojurebot"([sym]); same as (ns-resolve *ns* symbol)"
01:53hiredman,(let [x '+] (resolve x))
01:53clojurebot#'clojure.core/+
01:55slyphonhiredman: hey, if i have (:foo "bar" :baz "spam") how can i turn that into a map?
01:56hiredman,(apply hash-map '(:foo "bar" :baz "spam"))
01:56clojurebot{:foo "bar", :baz "spam"}
01:56slyphonOHHH
01:56hiredman,partition
01:56clojurebot#<core$partition__5241 clojure.core$partition__5241@1ed0577>
01:56slyphonty
01:56hiredman,(map vec (partition 2 '(:foo "bar" :baz "spam")))
01:56clojurebot([:foo "bar"] [:baz "spam"])
01:56slyphoni'm not sure how i missed that
01:56hiredman,(into {} (map vec (partition 2 '(:foo "bar" :baz "spam"))))
01:56clojurebot{:foo "bar", :baz "spam"}
01:56slyphonhahahaha
01:57hiredman,(doc zipmap)
01:57clojurebot"([keys vals]); Returns a map with the keys mapped to the corresponding vals."
01:57slyphonyeah, i don't have the keys & vals in separate lists though
01:58slyphonthough, wouldn't be too hard to do that
01:58hiredman,(let [x '(:foo "bar" :baz "spam")] (zipmap (take-nth 2 x) (take-nth 2 (rest x))))
01:58clojurebot{:baz "spam", :foo "bar"}
01:58slyphonare hash-maps ordered?
01:58nteonhiredman: I might partly be having a trouble with the new vocabulary. I don't understand why the initial binding *aux-xml-1* can be used with var, but not var-string
01:59hiredmannope
01:59slyphonok
02:00slyphonjust checking
02:00hiredmannteon: *aux-xml-1* is the name of a var
02:00hiredmanthere is a sorted map
02:00hiredmansorted-map
02:00slyphonhow about structs?
02:00hiredmannteon: var-string is not
02:01hiredmanslyphon: structs area slight omptimization (under certain circumstances) of maps
02:01slyphoni'm only asking because in the REPL it seems to display things in the order i defined the struct in
02:02hiredmanthe implementation might have some ordering, but not guaranteed
02:02slyphonok, that's what i expected
02:02slyphonthanks
02:05nteonhiredman: so what is var-string, a binding? how would I get the var for a binding? (you suggested resolve before, but I can't seem to use that right)
02:05nteonah, a symbol not a binding
02:07hiredmanlocals don't have vars
02:07hiredmanvars only exist in the global scope
02:07nteonhiredman: so there is no way to use a local with meta?
02:08hiredmannot a locla name
02:08hiredmanyou can attach readtime metadata to the symbol that is the name
02:09hiredmanbut it is not accessable at runtime
02:10nteonmaybe I'm missing something, but this seems to make metadata less attractive to me (I'm probably just misusing it)
02:11hiredmanI think you must be missing something
02:11hiredmanwhat did you want with metadata?
02:12hiredmanyou cannot pass local names beyond their scope, or really pass them at all, they are not reified entities
02:12nteonI must be :)
02:12hiredmanthe compiler could just translate local names into numbers for an array access
02:13hiredman(it doesn't)
02:14nteonbasically I want to test that I'm processing chunks of xml correctly. So my thought was to define a var as a string of xml and attach metadata with the correct values I want to be parsing out. I could just use a map instead, with :xml, :name and :equation keys
02:15nteonthat would work just fine, I suppose I wanted to use metadata because 'it was there'.
02:15hiredmanif you take a strict λ calculus view bound variables are subject to renaming under one of the sbstitution rules (alpha? beta?)
02:16hiredmanfyi :user and :import can use and import more than a single thing at a time so you can collapse those seperate uses
02:17hiredman(:import (java.io StringReader ByteArrayInputStream))
02:17hiredman:use
02:17nteonhiredman: ah! good to know
02:18nteon,(doc ns)
02:18clojurebot"([name & references]); Sets *ns* to the namespace named by name (unevaluated), creating it if needed. references can be zero or more of: (:refer-clojure ...) (:require ...) (:use ...) (:import ...) (:load ...) (:gen-class) with the syntax of refer-clojure/require/use/import/load/gen-class respectively, except the arguments are unevaluated and need not be quoted. (:gen-class ...), when supplied, defaults to :name correspon
02:19nteonwhat does the :reload-all do? lein inserted that
02:19nteonI have an inkling, I imagine reloads it when its reevaluated in a repl session
02:21hiredmanhttp://richhickey.github.com/clojure/clojure.core-api.html#clojure.core/require
02:25nteonhiredman: thanks. I had looked up use which wasn't as useful
02:26hiredman,(doc find-doc)
02:26clojurebot"([re-string-or-pattern]); Prints documentation for any var whose documentation or name contains a match for re-string-or-pattern"
02:26nteonI always forget about that one.
02:35LauJensenMorning team
02:36RaynesLauJensen: Morning teammate.
02:45qedMorning teamsters
02:53RaynesLauJensen: Teach me to speak German.
02:54qedNein
02:54LauJensenRaynes: It takes quite some time to learn, that are almost as many small grammar rules as there are stars in the universe - using 'almost' a little lightly
02:54qedyeah.. a billion trillion grammar rules seems excessive
02:54Chousukeheh, sounds like finnish
02:54RaynesHeh, sounds like a crappy language. :|
02:54LauJensenPlus there's the added bonus of them exchanging v for f, and adding a letter which you probably haven't seen before, but are 2 nested S's :)
02:54Chousukewe have grammar rules for everything because they made one for every exception :P
02:54LauJensenRaynes: No its great, finnish is very poor though
02:55qedi love finnish folk music
02:55greghclearly you should learn esperanto, there's like 12 grammer rules total
02:55LauJensenI cant decide if dutch is good or not, because speak it implies spitting and drooling a lot, so I cant make out all the sounds
02:55RaynesOr we could all just learn lojban.
02:55qedthose fake languages are a nice onanistic enterprise
02:55ChousukeAlso consonant gradation if not fun in Finnish
02:58Chousukehttp://www.stanford.edu/~laurik/fsmbook/exercises/FinnishConsonantGradation.html I'm glad I didn't have to learn these rules in school :/
03:02RaynesHrm. How did tabs get mixed in with my spaces in my Clojure code. :o
03:02RaynesI thought Emacs converted tabs to spaces.
03:04greghyeah, the tabs made kind of a mess
03:05RaynesLauJensen: Do you buy any chance know how to make Emacs convert tabs to spaces by default?
03:06RaynesWould save me a google search.
03:06Raynesgregh: Thanks for fixing it. I had no idea.
03:06LauJensenM-x tabify ?
03:07LauJensen(setq-default indent-tabs-mode nil) to use as standard I think
03:07RaynesIt's untabify you were thinking of.
03:07RaynesThanks.
03:07RaynesI'll try that.
03:08LauJensenOnly happy to help out my Texan friend
03:08RaynesAlabamian. Texas is only fake rednecks. :D
03:08RaynesTexans are*
03:13hiredmandepends which walmart you are in
03:14TheBusbyhaha
03:14LauJensenRaynes: I like what Putin said "There's really no point in criticising America, the results speak for themselves"
03:15RaynesHah.
03:22hiredmanof course, at that point someone raised their hand and said "sir, you could replace 'america' with the name of any other country and it would still be true" and then putin raised an eyebrow and the voice of decent vanished and support was unanimous
03:23LauJensensure
03:24hiredmanhttp://blogs.timeslive.co.za/minor/files/2009/08/putin-and-his-horse.jpg
03:24LauJensenAll nations fail remarkable at many levels, but Americas slogan has always been Bigger is Better - even in failure :) We have had bubble bursts here in Europe as well, but I mean, when America goes, it goes all out
03:25LauJensenAnyway, we shouldnt make this a political discussion, the results speak for themselves :)
03:25hiredmanLauJensen: bigger what?
03:27LauJensenfailures?
03:28hiredmanbigger failures than what?
03:29LauJensenI think you just triggered my bike-shed-o-meter
03:29LauJensen:)
03:30hiredmanI think you like the sound of your own voice, but lack any real insight or understanding
03:31hiredmanthis is not a bikeshed
03:32LauJensenwhat defines a bikeshed then ?
03:32hiredmanhttp://www.freebsd.org/doc/en/articles/mailing-list-faq/bikeshed.html
03:33LauJensenah youre a BSD guy ?
03:33hiredmanit's a term that originated in the freebsd community
03:36LauJensenYes I know
03:37LauJensenAnyway , My comment earlier was a reference to the fact, that America is something like the slow kid in the class - Massive debt, massive spending, massive wars, etc. The current worldwide economical crisis originates from your financial market
03:39bosiei have been looking at the y-combinator and really don't understand what you need it for
03:40bosieanyone has an article with a good explanation? :)
03:41hiredmanbosie: it's a formal way of introducing recursion into the λ calculas, it's not needed in clojure, or really any language I know of
03:42bosiehmm
03:44hiredmanLauJensen: that is hopelessly naive
03:44hiredmanlus
03:47bosiegod i hate my internet connection lately
03:50avarusgood mirnong
03:50avaruseh morning
04:00fulletsIs there a Clojure equivalent of common lisp's #'search?
04:01hiredmanwhat does search do?
04:01fulletsFinds a sequence in a sequence
04:01hiredmanclarify
04:01fulletsLike (.indexOf "hello" "el"), but for any sequence
04:02hiredmanI'd look in seq-utils
04:04hiredmanI kind of doubt it exists
04:04fulletsDoesn't look like it
04:05hiredmanclojure and contrib seem to avoid O(n) (or greater) unless it can be done lazily
04:05hiredmanI guess you could iterate rest and map partition
04:06hiredmanbut that wouldn't get you the "index" (of a non-index collection :() just the sequence which you already have
04:06hiredmanindex
04:06hiredmanindexed
04:08ChousukeI suppose for (search [1 2] [5 4 1 2 3 4 5]) it might be useful to return (1 2 3 4 5)
04:12Chousuke,(first (filter #(= [5 6] (take 2 %)) (iterate rest [3 4 5 6 7 8])))))
04:12clojurebot(5 6 7 8)
04:13Chousukeone problem with that is that I it never ends if the common sequence is not found :P
04:14fulletsI just found java.utils.Collections/indexOfSubList, which looks like it'll suit my purposes
04:14hiredman:(
04:15hiredmanI am sure it will work, it just seems like a horrible idea
04:15Chousukeit might work on a vector
04:15hiredmanI guess it would make more sense there
04:16fulletsWorks on seqs too. I never said it was a good idea - it's meant to be fast to type, not run :P
04:16hiredman:(
04:17hiredmanhorrible
04:31AWizzArdMoin moin
04:34ulfstermoin
04:37esjyello
04:45LauJensenhey
04:45avarushi LauJensen
04:53ulfsterif anyone is interested, i just put the start of my first clojure project on github, it shall one day be an online multiplayer version of the popular board game Carcassonne, http://github.com/ulf/carc
04:54ulfsteri am still getting started, so most of the code is probably ugly as hell ;)
04:56avaruswho said the hell is ugly
04:58Chousukeulfster: first problem: you have a single-segment namespace
05:00avarusorg.ulfster.incredible.game would be better?
05:00Chousukeyes
05:00ulfsterwill fix that
05:00avarusok
05:00ulfsterthanks
05:00Chousukeanything but a single-segment namespace :)
05:00ulfstermakes a lot of sense :)
05:01hiredmanulfster.game would be fine
05:01Chousukeit's not just collision-prone. Just a couple days ago there was a person here with a gen-class problem and it was fixed by doing away with a single-segment namespace :P
05:03Chousukeulfster: also, camelCase is not very idiomatic naming for most things. you should use foo-bar instead
05:03Chousukeexcept for things exposed as java methods
05:06Chousukefurthermore, you should avoid using nested refs (it's difficult to produce a consistent snapshot of them), and instead of (ref-set r (assoc @r :foo ...)) you can do (alter r assoc :foo ...)
05:08Chousukefor a simple game like carcassonne, one map inside a ref should be enough mutability. You really don't need to have a separate mutable players list or anything as a part of the already mutable game state.
05:09ulfsterso generally i should limit the mutable parts as much as possible?
05:09Chousukeit'll be less granular, but it'll make the coordination logic a lot simpler, since you can just write most of the game logic as pure functions.
05:09Chousukeyes.
05:10Chousukeyou should only increase granularity if it becomes a bottleneck
05:11RaynesI use double and so on segment namespaces.
05:11RaynesMostly just double and triple.
05:11Chousukeand in general, most of your logic functions should not care about refs at all, only the values.
05:12Chousukeso eg. add-player should be just a pure function creates a new game state. And then in your game loop you have some state handling procedures which call (alter game-state add
05:12Chousukeoops
05:12Chousuke(alter game-state add-player ...)
05:13ulfsteri see
05:13ulfsterthanks for the suggestions
05:13ChousukeIt's basically all about isolation
05:13ulfsterwill try to incorporate that prior to extending the functionality
05:13ulfsterthats real good practice, never did a real project in FP
05:13Chousukemost of the game logic is expressible as pure transformations. You should isolate those from the actual state-changing logic as much as is feasible
05:16Chousukeyou'll benefit from pure functions in that you can just define a struct or whatever representing some "state" value in a repl and then run your functions on it and see if they produce correct output
05:16Chousukeand you won't need to reset the state between tests, because there actually is no state :)
05:52esjis it really the case that on windows elements of the classpath are seperated by ; not : ?
05:52hiredmanyes
05:53esjthis is upsetting leiningen...
06:00esjso much for my cunning plan to get around the horror of windows by simply working in cygwin
06:05sparievI want to load some clojure code from file, process it with clojure.walk, and then save back with modifications
06:05sparievI believe I can load it with (read), it's the save part that puzzles me
06:06sparievany hints ?
06:06AWizzArd,(print '(def x 100))
06:06clojurebotDENIED
06:06AWizzArd,(print '(foo x 100))
06:06clojurebot(foo x 100)
06:06hiredmanyou'll want pr
06:07AWizzArdspariev: you can just print your code, using pr or pr-str at some places maybe.
06:07hiredmanAWizzArd: please don't use print
06:07AWizzArdhiredman: it's just a placeholder
06:07hiredman,(print "foo")
06:07clojurebotfoo
06:07AWizzArdyes
06:07hiredman,(pr "foo")
06:07clojurebot"foo"
06:07AWizzArdthat’s why pr or pr-str etc are better suited
06:07sparievwell, it seems obvious now ) thanks guys
06:08AWizzArdYou can use binding to bind *out* to a file, or you can just spit your lists out
06:09sparievyep, this code-as-data thing takes some time to wrap head around
06:10AWizzArdBtw, what are you doing with it? :)
06:10AWizzArdSomething like GP?
06:10sparievnope, refactoring tool - http://groups.google.com/group/clojure-dev/browse_thread/thread/51988b3dd591c96c
06:12AWizzArdcool stuff
06:12sparievI hope I'll have "free" time for it
06:28jperraswhat's the go-to resource for a pure clojure-based priority queue?
06:33japowlanyone here using the leiningen native-deps plugin dnolen put on clojars?
06:36TheBusby,(let [ [a b] [1 2] ] a)
06:36clojurebot1
06:37TheBusby,(map (fn [ [a b] %1] a) [1 2])
06:37clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: sandbox$eval--7888$fn
06:37TheBusbyhmm, how exactly do fn's support destructuring?
06:38AWizzArdjperras: if you want queues just use the ones from http://java.sun.com/javase/6/docs/api/java/util/concurrent/package-summary.html
06:39AWizzArdulfster: please look into your priv.
06:39triyoTheBusby: http://clojure.org/special_forms look at let form
06:40jperrasAWizzArd: thanks
06:41TheBusbytriyo: destructuring is only mentioned under "let" and hence doesn't have an FN examples
06:42TheBusbyno luck on wikibooks for examples either, which is why I brought it up here
06:44TheBusbyI think I've just provided the example that what works for let doesn't appear to work for fn
06:44TheBusbydoh
06:47TheBusby,(map (fn [[a b] %] a) '([1 2] [3 4]))
06:47clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: sandbox$eval--7898$fn
06:49TheBusbyFor reference in case someone googles, (map (fn [[a b]] a) '([1 2] [3 4]))
06:59triyo,(map (fn [[a b]] (str a " - " b)) '([1 2] [3 4]))
06:59clojurebot("1 - 2" "3 - 4")
07:00TheBusbyI'm slowly learning that it's probably better to grep through contrib that google or read the docs...
07:02triyothat destructures each element (vec) in seq and then binds first vec item to a and the second to b.
07:02TheBusbytriyo: thank you ;)
07:04triyofunction argument binding can be a bit tricky at first as there is quite a few different ways to go about it. Lately, I've seen people create macros that closelly ralte to how python func argument binding works.
07:04triyoTheBusby: also have a look at http://stuartsierra.com/2010/01/15/keyword-arguments-in-clojure
07:06triyothough thats more about keyword argument handling
07:09TheBusbyis there an RSS feed that tracks clojure related blog posts like emacsen?
07:10triyoplanet clojure http://planet.clojure.in/
07:10underdevare the Hudson snapshots suitable for development, or is it recommended to use the stable releases? Usecase: learning clojure, not production
07:13Raynesunderdev: They are stable, though the newer features aren't documented in tutorials yet.
07:13RaynesSuch as deftype and defprotocol, but there is enough documentation on the assembla pages to fix you up for the most part.
07:14underdevRaynes: ty
07:14RaynesI mean, it's bleeding edge and all, but nobody really ever has problems with the snapshots.
07:14underdevokay, great. exactly what i wanted to know :)
07:21AWizzArdHi rhickey. Did you have another wake-me-up-moment this night? ;)
07:23rhickeyAWizzArd: I think I've divulged enough about my sleeping pattern this week
07:23AWizzArdyeah
07:28AWizzArdAbout the Cells example v1: why would one use a Cell for conjing those numbers onto the vector, vs using a transient?
07:28rhickeyAWizzArd: direct transients are going away
07:29AWizzArdAnd why would one use a locked-cell, as in example v2?
07:29rhickeythe data structures will remain but the sharing policy has moved into the cell
07:29rhickeyAWizzArd: you would never as in the example, since it is a local, but anytime you might use the cell in multiple threads
07:30AWizzArdSo, when I have n threads that want to conj numbers onto the celled vector, then a locked-cell would be the right container.
07:31AWizzArdBut in which situation would I not want to use an atom or agent or ref?
07:31rhickeyor a ref, atom or agent, depending on the other factors
07:31rhickeyAWizzArd: we discussed this yesterday a lot
07:32AWizzArdI think it still left some people a bit puzzled.
07:32rhickeylocked cells allow for coordination, like refs, and serialized activity, like agents, but are synchronous, like atoms
07:33rhickeyplus, they support transience
07:33rhickeyso, whenever you want that set of features, use a cell
07:33AWizzArdokay, so a locked cell offers features of all those other reference types
07:41AWizzArdWhich of those features go away for non-locked cells?
07:47AWizzArdrhickey: let's say I have some useful program P, which I control through a pipe. P takes only one input at a time, so it needs serialized input (agents so far). But then I need to know its return value, as soon P outputs them. Here I have a problem with agents: The thread that sent it away won't capture Exceptions, and I can not read the guaranteed correct agent value.
07:48AWizzArdI could (await my-agent) and then deref it. But between awaiting and dereferencing it some other thread could have sent another job to my-agent and now I get that value.
07:48AWizzArdCan Cells help here?
07:50AWizzArdIn principle I would like to have: (let [x (send my-agent foo 1 2 3)] ...) with x having the right value, but blocking as long the agent is busy.
07:50AWizzArdokay, maybe this is more like a queue...
07:53AWizzArdBut could Cells maybe do that? When there is a global locked-cell C and we (let [x (in-cells [C] (>> conj! C (call binary here)) @C)] ...) then this may give the right result.
07:54AWizzArdOnly that instead conj! we would maybe replace the current value.
07:54AWizzArdInstead of pass, is there some kind of set! operator?
08:06AWizzArdSeems not many people are sure if Cells can do that...
08:13rhickeyAWizzArd: you could always pass #(do % 42)
08:14rhickeybut yes, cells are synchronous, and serialized
08:14rhickeysimultaneous calls to the same cells block
08:17AWizzArdGood. And if my cell fn throws an exception, then the thread doing the in-cells call can catch it, yes?
08:17rhickeyyes
08:30AWizzArdrhickey: okay good, thanks, this makes things more plausible, and I have ideas to try it out in my production code.
08:46_fogus_Is there a metadata best-practices somewhere? (from a struct impl perspective)
08:48Raynes_fogus_: Yep, his name is rhickey and he's sitting just down the row from me. ;p
08:50_fogus_Raynes: Understood.
08:56bosieanyone in here participating in the google ai challenge
08:56bosiehttp://csclub.uwaterloo.ca/contest/index.php
08:59RaynesNope. Too intimidating. :p
09:01bosieRaynes: huh?
09:01bosiesign up with a fake name and fake email ;)
09:01Raynes:p
09:07grzm'lo. I'd like to include a java file in my clojure project. I'm using leiningen for management, emacs/slime/swank-clojure for development. swank-clojure-project works: when I call (System/getProperty "java.class.path") in the slime repl, I get the expected classpath
09:08grzmI added the .java file to src. I used the lein-javac plugin to compile the .java file, and I see the corresponding .class file in classes.
09:09grzmHowever, when I attempt to call a (static) method on the class defined in the .java/.class file, I get a "No such namespace: <class>" error in the repl
09:09grzmHow can I further debug this? What might I be doing wrong?
09:16triyogrzm: I didn't see all your messages. You just wish to call static method on class?
09:17triyo,(map #(Character/isDigit %) "12a34")
09:17clojurebot(true true false true true)
09:17grzmtriyo: yup, which I'm trying to do with (Class/staticMethod arg)
09:17grzmtriyo: what you missed: I'd like to include a java file in my clojure project. I'm using leiningen for management, emacs/slime/swank-clojure for development. swank-clojure-project works: when I call (System/getProperty "java.class.path") in the slime repl, I get the expected classpath
09:17grzmI added the .java file to src. I used the lein-javac plugin to compile the .java file, and I see the corresponding .class file in classes.
09:18triyoyou using "lein repl" to test? Just want to make sure your class is on classpath
09:19triyooops sorry missed above
09:20triyowhats your :import look like?
09:21grzmtriyo: :) that's probably it. I haven't one. let's give that a shot
09:21chouserif you use the full name of the class, you don't need an import.
09:22triyohehe, you need to import Java classes first unless you use fully qualified names
09:22jcromartieApparently I have been spoiled by the plain REPL's exceptions when loading code...
09:22RaynesHaha.
09:23jcromartieif I do (use 'foo) in my REPL, I get a simple one-line message that tells me where the problem is
09:23jcromartiein Slime the original source file isn't even listed
09:23jcromartieat least not in the first 87 lines
09:23jcromartieOK, nowhere
09:23jcromartiethe REPL says java.lang.Exception: Unable to resolve symbol: entity-id in this context (messages.clj:38)
09:24jcromartieam I doing something wrong?
09:25grzmchouser: triyo: I was using the full class name (at least as it's defined in the .java file). How might the class name get transformed into something else?
09:26grzmwell, using (ns user (:import ClassName)) worked. Why didn't (ClassName/staticMethod args) prior to import?
09:26grzmtriyo: thanks for the pointer, btw
09:27chouseris ClassName in the default (unnamed) Java package?
09:28grzmchouser: I don't know, which makes me suspect not
09:28chousergrzm: what's the full name of the class, package and all?
09:28triyogrzm: in your java class did you define "package .../"
09:28jcromartieIs there some way to get the same REPL error messages in Slime?
09:29grzmchouser: triyo: the class is one I downloaded: http://people.apache.org/~yonik/code/hash/Hash.java
09:29grzmI haven't modified that file at all
09:30arkrostHi! I'm looking through clojure source, but I can't find implementation of in-ns function. Tell me please in what file I shold searching.
09:30chouserok, that's your problem. I'm actually surprised you got it working at all.
09:30triyono package so default package used
09:30chousergrzm: Java discourages and Clojure doesn't really support classes in the default package.
09:30stuartsierraarkrost: in-ns is a special form, it's handled by the compiler
09:33grzmchouser: so, I should maybe make src/util/Hash.java, and define the package to be util
09:33Raynesjcromartie: Maybe your question should be asked on the swank-clojure ML? I'm interested in the answer as well. technomancy|away is... away, and he's your best bet. :p
09:34jcromartieRaynes: yeah maybe... it's very curious that the plain old REPL can give me a one-line answer as to where the error is coming from, but swank can't
09:34chousergrzm: yes, that would clean things up for you.
09:34Raynesjcromartie: What's even more curious is the fact that people seem to ignore that fact. I think we're missing something.
09:34jcromartieyeah
09:34jcromartiemaybe
09:35jcromartieit's inexcusably bad, if it were the default state of swank/slime then nobody would be able to use it
09:35jcromartieso I can only assume it's not the way it usually works
09:35jcromartiebut then again nobody is saying "it works for me!"
09:35grzmchouser: thanks :) let's see how I can screw this up :)
09:35chouserpeople do complain about clojure errors all the time. I hope it's not slime's fault all along.
09:36jcromartiechouser: well like I said, the plain old REPL in my terminal gives me a one-line error with the source file and line, Slime doesn't list the orginating file or line at all
09:36chouserarkrost: http://github.com/richhickey/clojure/blob/master/src/jvm/clojure/lang/RT.java#LID212
09:36RaynesIt's slimes fault when the Clojure REPL actually answers correctly.
09:37chouserright, unless most people using slime have it configured differently.'
09:37RaynesIndeed, which is my point.
09:37RaynesThough, I'm pretty sure my install is standard.
09:38jcromartieon another tangent: how do you guys organize your tests?
09:41jcromartieyeah my swank setup is straight from ELPA
09:41jcromartierecent, too
09:41grzmchouser: that seems to work. Thanks!
09:41grzmtriyo: thanks for your help as well
09:44jcromartieis there a way to try to coerce a map into a struct?
09:44RaynesYou can ask very nicely,.
09:45chouserinto
09:45chouserinto is how you convert from just about anything to any of clojure's persistent structures.
09:47jcromartieah
09:47AWizzArdyou will have to provide fake args
09:48AWizzArd(defstruct foo :a :b :c) and then (into (struct foo nil nil nil) {:a 1, :b 2, :c 3})
09:48jcromartiestruct-map works
09:48jcromartie(into (struct-map s) some-map)
09:48AWizzArdyes great
09:48AWizzArdI already forgot about struct-map
09:49jcromartiedid you guys see this presentation? http://www.slideshare.net/smartrevolution/how-a-clojure-pet-project-turned-into-a-fullblown-cloudcomputing-webapp
09:49jcromartieit's good
09:51triyo_fogus_: only one part, Clojure on JVM
09:56jcromartietriyo: hah hah
09:59triyojcromartie: well I'm a bit bias; what I meant to have said was: the JVM.
09:59triyo:)
10:04triyo~JVM
10:04clojurebotNo entiendo
10:05triyo~jvm
10:05clojurebotTitim gan éirí ort.
10:06triyohmm "Titim gan éirí ort." -> "May you fall without rising." in Gaelic
10:06powr-tocI'm using promise/deliver to make a JFrame dialog box block on the users answer (the deliver happens in the actionListener). It seems like a really nice pattern... would anyone argue otherwise?
10:11AWizzArdpowr-toc: sounds good
10:11AWizzArdoh btw..
10:11AWizzArdrhickey: is it planned that there will be a way to have something like await-for for Cells?
10:12jcromartieI'm trying to do (defn find ...) in this namespace, and I've used (:refer-clojure :exclude [find])
10:13chouserAWizzArd: cells are synchronous. you don't get control back until the operation is done
10:13jcromartiebut requiring another namespace that uses that namespace results in an error about clojure.core/fin
10:13jcromartiefind
10:13AWizzArd,(/ (* 12000 36000000) 1024 1024 1024)
10:13clojurebot52734375/131072
10:13AWizzArd,(double (/ (* 12000 36000000) 1024 1024 1024))
10:13clojurebot402.3313522338867
10:14jcromartiemy test namespace is like so: (ns foo.test.bar (:use clojure.test [foo.bar :as bar]))
10:14jcromartieand requiring that test namespace fails when loading the foo.bar namespace
10:14jcromartiewhich can be loaded by itself just fine
10:14AWizzArdchouser: I see
10:15jcromartienever mind, I should be requiring instead of using
10:15jcromartie(use '[foo :as bar]) doesn't really work, does it?
10:15AWizzArdyes, use is very comfortable, but sooner or later a require pays off
10:16jcromartieI didn't realize it was just ignoring the :as
10:16AWizzArdjcromartie: in your (ns ...) you can have: (:require [clojure.contrib [def :as d] [pprint :as p]])
10:16chouserjcromartie: no, it works. you get the alias *and* all the vars referred
10:17jcromartieoh, nice :)
10:17arohnerjcromartie: I've noticed the same behavior. Slime doesn't print the line number where the error occurred
10:17chouserI frequently do (:use '[foo :as bar :only []]) to get just the ns alias
10:17arohnerit is a slime problem
10:17AWizzArdfunny
10:18AWizzArdchouser: don’t :)
10:18AWizzArdYou even can program it in Lisp
10:18jcromartiearohner: sounds like it might be a major Clojure adoption obstacle
10:18zaphyrelisp can only vaguely be described as a lisp ;)
10:18chousernot a good lisp. And I don't want my clojure error message to be worse.
10:18chousermessages
10:18AWizzArdchouser: It's a nice lisp for this specific use.
10:21_fogus_chouser: I've been using Emacs for a couple years... I expect to be a novice any day now.
10:21triyo_fogus_: doesn't it take ten to reach that level?
10:22_fogus_triyo: NOOOOO!
10:22_fogus_I thought I was so close
10:24triyo_focus_: I know what you mean. Here is a quote by an emacs expert: "Well, the short answer is, you should learn Emacs by using it for about a decade.", easy as that
10:24chouserI wonder if I can write an elisp macro to create lexical variables.
10:24cemerickchouser: isn't that what (:require [foo :as blah]) is for?
10:25chousercemerick: yes, but if you use require and then later decide there's one function you'd like to use without the alias, you're stuck.
10:25cemerickah
10:25cemerickthat seems like a bad idea anyway
10:25cemerickimplies to the reader that fn a and fn b from the same ns are from different ns'
10:25triyoheheh _focus_.... I mean _fogus_
10:26chousercemerick: on one project I was kept shuffling libs back and forth between the :use and :require blocks as I went along before deciding that was stupid and started doing :use :only [] everywhere.
10:27_fogus_chouser: Yegge tried that same thing
10:27chouseroh dear. nevermind then...
10:27chouser:-)
10:28AWizzArdoh, you were serious about that
10:28Hali_303hi
10:29AWizzArdHello Hali_303
10:31_fogus_,(let [x 1] (let [x-inner 2] (let [x-yet-another-inner 3] [x x-inner x-yet-another-inner])))
10:31clojurebot[1 2 3]
10:31_fogus_^^^ lexical scope in elisp
10:31_fogus_;-)
10:32chouserhm. I guess the problem isn't so much being able to use lexical scope as it is trying to understand elisp code of others that frequently uses dynamic scope.
10:35Hali_303what's an easy way to persistently store clojure data structures?
10:35Hali_303for example, how do I store a list of maps? do you use an RDBMS or object database for that?
10:35AWizzArdA simple one is to just print them into a file which you can then later (read).
10:36Hali_303hm. and what if I have a Date in a map that is not String serializable?
10:36AWizzArdYou can define printers on any data type for serialization.
10:36AWizzArdThis is okay if we are talking about a few MB of data.
10:37Hali_303AWizzArd: how do I do that exactly?
10:38AWizzArdLet's say you have a map {:a 1, :b 2}
10:38cemerick_fogus_: emacs *and* linux? World of pain, that is. ;-)
10:38AWizzArd,(pr {:a 1, :b 2})
10:38clojurebot{:a 1, :b 2}
10:38triyoHali_303: mongoDB with congomongo clojure lib is pretty good option. All really boils down to your requirements. There are newmerious ways, NoSQL, RDBMS, file+serialization.
10:38AWizzArdor you can use pr-str and spit that output into a file.
10:39AWizzArd,(pr-str {:a 1, :b 2})
10:39clojurebot"{:a 1, :b 2}"
10:39AWizzArdFor simple things this is an okay approach. For a full blown app you probably want to use a “real database”.
10:41_fogus_cemerick: After dealing with MS Word, I no longer feel pain like a nomal human.
10:41cemerickclearly
10:42cemerick_fogus_: actually, this mostly means that you'll never finish the book -- 45 minutes / hour will be taken up with babysitting synaptic and fixing .emacs ;-)
10:43Raynescemerick: Netbeans is for skiddies. :p
10:45cemerickskiddies?
10:46_fogus_cemerick: I require approval of Congress to change my .emacs
10:48mattrepl_fogus_: you're just furthering the Washingtonian stereotype. =)
10:52cemerickRaynes: oh, I got it now (after looking it up). Try to keep stuff like that to yourself.
10:52_fogus_mattrepl: Not true... typical Washingtonians use Vi. ;)
10:55mattrepl_fogus_: heh, that's believable
10:57rsynnott_fogus_: but just a simple majority or one of those wacky supermajorities? :)
11:01AWizzArdrhickey: about your Cells gist: is it true that because you extended Strings in lines 149-151 with the Editable Protocol Cell values become inside cell operations such as >> automatically a StringBuilder? And that's why you type hint c in examples s1 - s4 as #^StringBuilder?
11:02rhickeyAWizzArd: yes
11:02AWizzArdoh great, then I think I understand 95% of that
11:03AWizzArdThe Editable Protocol is for "making things transient", while the Transient P. is for reading such objects.
11:03rhickeyeach cell has 2 parts - a transient part and a value part. Those protocols are used to get one from the other
11:03AWizzArdExcellent. Damn, this seems to be *the* store for my DB.
11:04AWizzArdGreat great, I will switch from atom + lock + in-lock-atom to locked-cells
11:04AWizzArdOnly missing piece is the Sentry protocol.
11:06chouseryeah, that's kinda goofy. Locks and Threads *are* Sentrys
11:07rhickeyhow is that goofy?
11:08chouserisn't there a possibility that one might want to provide a cell with a different policy, but still using a ReentrantLock?
11:08chouserbut even if not, it feels odd.
11:09chouserI would expect a sentry to have a lock or a thread, not be one.
11:09rhickeychouser: you can always make an object that holds one of those, at the cost of creating another object
11:10chouserhm, yeah I see.
11:10chouseryou don't think if feels at all odd though?
11:10chouserit
11:10rhickeythink of it this way - image if sentry was an interface in the JVM and Threads and Locks implemented it. If you wanted different behavior you would have to wrap an instance
11:11rhickeyProtocols just let you inject that interface, but admittedly, only once
11:11AWizzArdWhen would I want to extend a class with the Sentry P.?
11:11rhickeyAWizzArd: you should consider Sentry and implementation detail for now
11:11rhickeyan
11:11AWizzArdok fine
11:12AWizzArdSo, the idea about POJOs was to extend on Transient, and have this constructing new instances of the POJO, yes?
11:13rhickeyAWizzArd: there will also be a way to specify to/from transient fns per cell
11:13AWizzArdVery very interesting, I think I got it by now and can start to use them. This will beautify my ugly hacks and make the system easier as well.
11:16rhickeychouser: actually, I think it's awesome to be able to build a protocol on an existing class, and leverage the fact (in the case of Thread) that an instance is already around. Single-threaded cells need to be extremely cheap. Furthermore, the potential exists to add compiler support to single-threaded cells that would detect that they don't escape and get rid of the cell entirely
11:18rhickeybut in any case people should consider the sentries as opaque. The only critical feature is that given one, you can create another cell with the same policy
11:22AWizzArdI will just ignore that Protocol for now and see later if I care about it.
11:33AWizzArdAh, interesting way to sort the cells to lock in a way that can't produce a dead lock.
11:39jcromartieAre there any functions that describe a struct definition?
11:40jcromartieor should I inspect an empty instance for keys?
11:40jcromartiei.e. (keys (struct-map my-struct))
11:40StartsWithKjust check the keys
11:49somniumis there something like autotest for clojure?
11:51StartsWithKsomnium, what is autotest?
11:52dakroneautotest monitors a file for changes and reruns your test suite
11:52somniumit watches source files for changes, runs tests, zeros in on fails, and has hooks for dorky ">_< tests failed" popups
11:54tomojI'd think it would need to be hooked to whatever you use for development
11:54tomojthat or nailgun
11:54tomojotherwise running the tests would be too slow
11:57somniumI was thinking something like $ lein autotest&
11:58somniuma simple one is really trivial to write in ruby/python, does the jvm make it harder?
11:59tomojhmm
12:00tomojI think you wouldn't want to just reload the changed files like the ruby ones do
12:00dakronedoes the JVM have hooks to watch when a file changes?
12:00tomojactually, that would probably work fine
12:01tomojno, you have to do that yourself
12:02tomojhttp://jnotify.sourceforge.net/
12:02chouserthere's some inotify (for linux) code in clojure-jna
12:03tomojnice
12:03StartsWithKlisppaste8, help
12:03tomojapparently java 7 will be able to do it
12:03tomojhttp://java.sun.com/developer/technicalArticles/javase/nio/#6
12:05StartsWithKsomnium, http://paste.pocoo.org/show/179796/
12:05fdaoudi always get caught by this:
12:05StartsWithKand "projects" should be i guess "test" inside your project directory
12:06StartsWithKbut that will be slow, as jvm will need a restart
12:06fdaouddoing (map (fn [x] (something-with-side-effects x)) [....]) doesn't do all the side effects
12:06fdaoudis the solution just (doall (map ...)) ?
12:07StartsWithKfdaoud, yes, but check doseq macro also
12:08fdaoudStartsWithK: oh, cool, thanks
12:15fdaoudStartsWithK: that's much nicer
12:19stuartsierraFirst draft of a new testing framework: http://paste.lisp.org/+21G4
12:20fdaoudstuartsierra: pre-ordered your book :)
12:20stuartsierrafdaoud: Wow, cool, thanks!
12:20jlillyIs there somewhere that I can just download all the clojure documentation?
12:20jlillyI'm going to be taking a flight later today and wouldn't mind having it handy if I need it.
12:21dakronejlilly: you could save http://richhickey.github.com/clojure/clojure.core-api.html as a pdf? would that work for you?
12:22jlillyI think that'll do it. :) Thanks
12:22jasappdon't forget doc is your friend
12:22the-kennystuartsierra: What's your new book?
12:22dakronestuartsierra: I don't understand your usage syntax, you give the tests each 2 contexts, but then give the suite 1 context?
12:23defnstuartsierra: awesome presentation on rubyconf -- ive been waiting for that for 3 months now and it was worth it
12:23StartsWithKjlilly, wget -krmnp -E -X/page,/message --no-check-certificate -P <target>https://clojure.org
12:23defns/on/at
12:23StartsWithKi think it should still work
12:23stuartsierradefn: I've never been to RubyConf.
12:23StartsWithK<target> - output directory
12:24jlillyI just printed the above page to pdf. That has basically what I was looking for.
12:24jlillythanks though.
12:24stuartsierradefn: Maybe you mean Stuart Halloway?
12:24jlillynext question.. when in the repl, how can I change the active namespace to something other than user?
12:24arohnerjlilly: (in-ns 'foo)
12:24stuartsierrathe-kenny: My book, mostly by Luke Vanderhart, from Apress, will come out in a few months.
12:24jlillyrokk.
12:24dakrone(ns foo)
12:24defnoh god sorry stuartsierra
12:25stuartsierradakrone: The purpose of a Suite is to define certain contexts that only run once for the entire suite, not once per test.
12:25stuartsierradefn: no worries, it's confusing
12:26arohnerdoes anyone have experience with hibernate?
12:27fdaoudthe-kenny: http://www.apress.com/book/view/1430272317
12:27arohnerI'm looking for a better ORM solution, and I'm alternating between writing my own, and doing to hibernate what lein did to maven
12:27dakroneso how is (def t1 (Test '[a b] [c1 c2] '[(integer? a) (integer? b)])) supposed to be read? Define t1 as a test mapping a to the result of c1, b to the result of c2 and test the interger-ity of a and b?
12:27dakrone*integer-ity
12:28stuartsierradakrone: Yes. It compiles to something like (fn [a b] (assert (integer? a))...)
12:28stuartsierraBut you won't need to write it like that when I'm done.
12:28dakronestuartsierra: so, then why is the suite context needed for this example at all then?
12:29stuartsierradakrone: Just to demonstrate
12:29dakroneoh okay, I guess I was getting mixed up wondering why the context wouldn't do anything for that example
12:31dakroneI think it looks cool, but I'm wondering, isn't contextual testing supposed to be something that's alleviated with immutable functions since they don't require state?
12:32stuartsierradakrone: Yes, but the real world has state in things like databases.
12:32stuartsierraFor unit testing of pure functions, there's no context.
12:32dakronethat's true, setup is definitely nice for that
12:32dakronewhat kind of changed syntax are you thinking?
12:32stuartsierraBut you could still use contexts to set up a data structure and then run a bunch of assertions on it.
12:33stuartsierradakrone: Everything should nest, i.e. (suite (test ...) (test ...) (test ...))
12:33cemerickstuartsierra: what is the objective with the new test lib?
12:33dakronestuartsierra: (def c3 (Context (def my-url "http://clojure.org&quot;))) would allow using that var in all tests if passed as a Suite context then?
12:33stuartsierracemerick: Cleaner separation of setup/teardown and assertions.
12:34stuartsierradakrone: no
12:34cemerickstuartsierra: nifty. Are you aiming for compat with clojure.test at all?
12:34stuartsierradakrone: Contexts only produce values.
12:34stuartsierracemerick: I could probably write a compatibility layer, but in the core, no.
12:35dakroneokay, can you give an example where the Suite context would be used and how?
12:35stuartsierradakrone: Opening a database connection.
12:35stuartsierradakrone: Creating a temporary directory.
12:36dakronewould you return the handle? or are contexts designed not to return anything used?
12:36stuartsierraA Context consists of two functions, :before and :after.
12:36stuartsierraThe :before function returns a value to be used in a test. The :after function is called on that same value and does clean-up.
12:37fdaoudarohner: do you love hibernate?
12:37arohnerfdaoud: no, never used it before last night
12:37stuartsierraSince Tests know about their Contexts, you can run a test outside of its Suite and still get the proper setup/teardown. But when you run the whole Suite, the setup/teardown only gets executed once.
12:37arohnerI'm trying to figure out whether it would be a good base for an ORM
12:37arohnerfor a clojure orm
12:38fdaoudarohner: hibernate is complicated and I find that when you go off the beaten path, you end up wasting more time fighting with it than you saved for the easy stuff
12:38dakroneokay, I see, so if you ran t1 (in your example) by itself, it'd run the c1 and c2 setups, but if you ran the s1 Suite, it'd only run c1 once for both t1 and t2, is that right?
12:39arohnerfdaoud: thanks
12:39fdaoudarohner: also, given that Clojure works so well with lists/maps instead of objects, I don't think Hibernate would be a good fit
12:39fdaoudarohner: but that's just my opinion.
12:48arohnerfdaoud: that is useful. my current problem is I'm not too interested in writing the SQL queries to make an ORM efficient
12:49arohnerleft outer join, etc
12:49jlillyhttp://pastie.org/831116 -- anyone have suggestions on how I can fix clojure.contrib installation? Running on trunk atm.
12:49technomancyjlilly: unless you're hacking on contrib itself I'd recommend getting it from build.clojure.org instead
12:50jlilly:-/
12:50jlillylet's say I wanted to completely ignore your advice (as well founded as it likely is)...
12:51jlillyis this an issue with contrib not being 100% stable on the master branch?
12:51technomancyclojurebot: restfn?
12:51clojurebotexcusez-moi
12:51fdaoudarohner: are none of the orm solutions for clojure to your satisfaction?
12:51technomancy,RestFn
12:51clojurebotjava.lang.Exception: Unable to resolve symbol: RestFn in this context
12:51technomancy~RestFn
12:51clojurebotI don't understand.
12:51technomancyclojurebot: botsmack!
12:51clojurebotHuh?
12:51technomancy...
12:51Chousuketechnomancy: what are you looking for?
12:52stuartsierraThat's a bug, I think.
12:52jlillyChousuke: the pastie I put above, where maven can't build clojure contrib
12:52fdaoudtechnomancy: sometimes it's better to talk to humans ;)
12:52arohnerfdaoud: which ones are there? I've only seen http://github.com/duelinmarkers/clj-record
12:52technomancyChousuke: I thought clojurebot had a nice anwser for the restfn problem since it's such a faq
12:52Chousuketechnomancy: hmmh
12:52stuartsierratechnomancy, Chousuke: I'm not sure that's the same bug.
12:52stuartsierraThe pastie shows it's downloading the latest Clojure snapshot.
12:53stuartsierraA couple of people have reported this. But Hudson shows no errors.
12:53jlillystuartsierra: I also tried it by specifying a recent checkout and build of clojure from trunk.
12:53stuartsierrajlilly: Try a mvn clean first.
12:53technomancyyeah, I've got no idea about contrib specifically; I just saw that error and it made me think of a bytecode/clojure version mismatch
12:53stuartsierrajlilly: Or just use the snapshot JARs on build.clojure.org
12:53fdaoudarohner: clojureql, clojure.contrib.sql, congomongo
12:54jlillyalso, is it possible to make maven cache the things it downloads so things don't take as long?
12:54stuartsierrajlilly: It does that automatically.
12:54arohnerfdaoud: AFAI understand, clojureql and contrib.sql are about generating queries, and congomongo is for mongoDB
12:54jlillyhrm. alright. Suppose I'm just being impatient.
12:55technomancyclojurebot: botsmack is <reply>Owww!
12:55clojurebotIk begrijp
12:55jlillystuartsierra: mvn clean fixed the issue, it looks like.
12:55jlillythanks.
12:57stuartsierrajlilly: np
13:04AWizzArdWhat again was the syntax for :pre asserts?
13:08jcromartiewow, Compojure + MongoDB testing is so much faster than Rails + *SQL testing :)
13:09dakroneAWizzArd: (defn foo [a] {:pre [(not (nil? a)) (not (= 0 a))]} ... )
13:10AWizzArdthx
13:10AWizzArdjcromartie: why is this faster?
13:10dakronenp
13:11jcromartieAWizzArd: I dunno, I've just always had really slow test in Rails
13:11jcromartieClojure feels faster overall
13:11jcromartiebut the lack of a gigantic framework and twelve bazillion plugins and magical metaprogramming might be part of it
13:11jcromartiefive thousand gem dependencies to load
13:11jcromartieetc.
13:13qbgRandom question: Didn't Clojure use to support CL-style defns (with regards to docstrings)?
13:15arkrosthi! I can't understand in what siyuations I can't use commute instead of alter. Can someone show code example?
13:18qbgIf you were multiplying a matrix in a ref, you couldn't use commute because matrix multiplication isn't commutative.
13:19BrandonWarkrost: i had the same exact question a couple of weeks ago
13:20BrandonWif you perform operations with alter
13:21BrandonWyou are guaranteed that the order of the operations is correct. it will execute the same path that your code designs them
13:21BrandonWif anything fails, it rolls back the entire transaction, and performs the transaction again
13:21BrandonWif you have commute operations, and the transaction fails
13:21BrandonWit doesn't roll back the entire transaction
13:21BrandonWit just executes the commute function calls again, and tries to submit the transaction again
13:22AWizzArdjcromartie: oki, i see
13:22AWizzArdmapcat is lazy, yes?
13:22BrandonWin this way, commute operations will offer a more efficient use of time than alter, since commute won't have to roll back transactions, but alter will
13:31jlillyif I have (:require clojure.contrib.combinatorics) in my ns macro, do I need to prefix the functions inside there that I want? for instance combinatorics/combinations or anything?
13:32danlarkinjlilly: require doesn't refer
13:37chouserin other words, yes.
13:40AWizzArdBtw, when we say that Cells are cooperative like refs, serializing like agents and synchronyzing like atoms, do we then really need to mention the atoms? Aren’t refs also synchronized?
13:42chouseri guess you could say cooperative and synchronous as refs are.
13:43AWizzArdYes.
13:49hiredmanhow are cells cooperative?
13:49chouseryou can lock multiple locked-cells with a single in-cells
13:52AWizzArdhiredman: (in-cells [cell1, cell2, c3, ..] (bar 'foos))
13:53jcromartie"somnium.congomongo" is really hard to type :)
13:53BrandonWjcromartie: did you try other nosql databases before you started with mongo?
13:54jcromartiemostly because 16/18 of the letters are under my right hand
13:54hiredmanmake a namespace a.b that has a macro like refer-clojure for sominium.congomongo
13:54jcromartieI always pick namespaces based on QWERTY letter distributions
13:54technomancyjcromartie: that must really bug dvorak users
13:54hiredman(a.b/mongo)
13:54jcromartieBrandonW: I looked at them but I was impressed by Mongo's track record and successful installations
13:55jcromartieBrandonW: I didn't *try* anything else
13:55BrandonWi've looked at most of them briefly, as i was going to play around on a personal project with one just to dip my feet in the water, so to speak
13:55jcromartieMongo seems focused and supported
13:55BrandonWyeah i had narrowed down between mongo and voldemort
13:55chouserwhat is required to leverage keyword callsite caching for my own class
13:55chouser?
13:55BrandonWbut i've read the same thing you just said-- how mongo is well supported and painless to install
13:55hiredmanooo
13:56hiredmanthat is an interesting question
13:56jcromartieBrandonW: oh man, talk about painless... download the binaries and set up the permissions on /data/db
13:56jcromartieyou're done
13:56jcromartieyou want security between hosts? set up SSH tunneling
13:56jcromartieno users necessary
13:56jcromartieno permissions on the db itself necessary
13:56jcromartie(by default)
13:57BrandonWit is the perfect time, too. i was originally going to just use postgres, but that has always been a pain to set up for me. i like how most of what i read on nosql datastores says it is drastically smaller and less complex to set up initially
13:57chouserI have a bunch of final classes provided by a java lib, and want to provide an ILookup object for each with as much performance as possible.
13:57BrandonWkind of buys in with the whole linux philosophy of doing one thing very wel
13:59jcromartieBrandonW: yeah I think so
13:59jcromartiebut do consider what kind of data you're going to be using
13:59stuartsierraIs there a compiler macro to get the current line of the current file?
13:59jcromartieyou are going to have to enforce every constraint you want on the data in *your* code
14:00jcromartieBrandonW: if you need constraints and transactions, and if you're thinking about handling money or other "important" data then look elsewhere... the MongoDB project says so themselves
14:00BrandonWyeah, well it is a personal project anyways
14:00chouser,@clojure.lang.Compiler/LINE
14:00clojurebot0
14:00jcromartiethen go for it, see how it works
14:00stuartsierrathx
14:00BrandonWit is not going to need scalability or anything special
14:00BrandonWi just wanted to try it out :)
14:00jcromartieheh
14:01chouserstuartsierra: I can't remember if there's something better or not
14:01stuartsierraok
14:12somniumjcromartie: ah, I use dvorak. and autocomplete :)
14:13jcromartiethat'll do it :)
14:13jasappsomnium: are you still looking for a clojure bson encoder / decoder?
14:13jcromartiebut seriously... 88% one-hand on QWERTY is something special
14:14jasappI got distracted over christmas, but I've got a pretty rough version hacked up
14:15jlillyin a for statement, I have a function which is returning a list of 2 item lists. What appears to be wrong with this syntax? (for [[r1 r2] (combinations myitems 2)] <body>) ?
14:15jlillyI'm getting a null pointer exception. (combination myitems 2) results in ((item1 item2))
14:15jlillyI would expect that r1 would be item1 and r2 would be item2. Am I missing something?
14:16the-kennyjlilly: ((i1 i2)) or (i1 i2)
14:16jlillythe-kenny: it returns ((i1 i2))
14:16jlillyie: its a list of combinations(lists)
14:16the-kennyfor the first, you'd need [[[r1 r2]] (fun)] in for
14:17the-kennyin your example, r1 is (item1 item2) and r2 is nil
14:17somniumjasapp: sure
14:17chouser,(for [[r1 r2] '((i1 i2) (i3 i4))] {:r1 r1, :r2 r2})
14:17clojurebot({:r1 i1, :r2 i2} {:r1 i3, :r2 i4})
14:18somniumjasapp: is it on github?
14:18jasappwere you interested in the bson wire protocol too?
14:18the-kennywhoops..
14:18jasappnot yet, at the rate I'm going, it'll be a week or two still
14:19jlilly,(for [[r1 r2] '((i1 i2))] (do (println (format "My thing 1: %s, Thing 2: %s" r1 r2))))
14:19clojurebot(nil)
14:19rhickeyother than the breakage - what do you think of havingto say (map! a-side-effecting-fn ...)
14:20boojum,(inc (Integer/MAX_VALUE))
14:20clojurebotjava.lang.ArithmeticException: integer overflow
14:20chouserinstead of (doall (map impure-fn ...)) ? Or would map! still be lazy?
14:20somniumjasapp: no hurry, so far only one person has had any performance complaints
14:20boojum,(map inc [Integer/MAX_VALUE])
14:20clojurebot(2147483648)
14:20rhickeychouser: still lazy
14:20jlilly,(for [[r1 r2] '((1 2))] (println (format "r1: %s, r2: %s" r1 r2)))
14:21clojurebot(nil)
14:21jlillyhrm. that's not what my repl is returning :(
14:21jasappwas that alexyk?
14:21somniumjasapp: Ive been focused on other things, but steady contributions trickling in, which is cool
14:21somniumjasapp: yeah :)
14:21jlillymine is returning... (r1: 1, r2: 2\n nil)
14:21rhickeyI'm going to add mapv (or something) to map into vector, best for non-lazy
14:21jlillythough I suppose that's correct as clojurebot won't spit out printlines.
14:22rhickeychouser: trying to tease out when a seq is transient-able, never when based on side-effects
14:22jasappI've just done some simple encoding benchmarks, and it's about 4 times faster than the java version
14:22chousermapv instead of (into [] (map ...)) ?
14:22rhickeymost of the seq fns could recursively detect transient-ability, but I need to know about side-effects
14:22jasappjust doing things like strings and integers
14:22rhickeychouser: yes, just shorthand for that
14:23somniumjasapp: wow, now that sounds really promising
14:23jasapplike I said, it's still pretty rough right now, but I'll let you know when it's suitable for public consumption
14:24rhickeychouser: the plan I had for making transient versions of ordinary seqs doesn't work, as lazy-seq-iter will have to retain head in a closure
14:24chouserah, ok.
14:25rhickeyso instead, the macro will generate code that will create either a LazySeq or LazySeqIter depending on the recursive transience of the passed colls
14:25chouseryou probably missed my question earliery: what is required to leverage keyword callsite caching for my own class?
14:25chouserI have a bunch of final classes provided by a java lib, and want to provide an ILookup object for each with as much performance as possible.
14:26chouserso analysis done at runtime, and you'd get a single object -- one or the other instead of both as with earlier plan
14:27jcromartiehmm, why can't I seem to find the encodeBase64String static method in the Apache Base64 encoder?
14:27rhickeychouser: right, but still some kinks like side-effects and the fact that cols might be passed and not seqs
14:27jcromartieI mean, it's in the docs
14:27somniumjasapp: let me know when its suitable for hackery even, sounds very cool
14:27jcromartiebut I get No matching method: encodeBase64String
14:28jcromartieam I doing this wrong? (Base64/encodeBase64String (.getBytes "foo:bar"))
14:28rhickeychouser: to get keyword lookup you need to implement IKeywordLookup, and return ILookupThunks for any keywords for which you want direct lookup
14:28the-kennyjcromartie: maybe you supply the wrong type of data as the argument?
14:28the-kennyI'd try a type-hint
14:29chouserrhickey: ok, thanks.
14:29jcromartiethe-kenny: hmm, I'm using decodeBase64 just fine, though
14:29jasappsomnium: sure thing
14:30jcromartiehm, weird, it must be the codec version I have or something
14:30rhickeychouser: you won't be able to implement IKeywordLookup without access to the Java lib
14:33chouserrhickey: I'll have access to the Java lib at macroexpand time.
14:33rhickeychouser: no, I mean the ability to make those classes implement the interface
14:34chouserbut I should be able to create an object at runtime that wraps a particular instance of a Java lib class, and delegates.
14:35chouserso (:foo javaobj) can't work, but (:foo (wrapmacro javatype javaobj)) should
14:36chouserand I think will still make sense for my use cases.
14:40rhickeychouser: I take that back, there is more to keyword lookup - kind of hardwired to deftype right now
14:45chouserhm...
14:46lancepantzhey chouser, remember that line you were talking to me about last night?
14:46lancepantz(defn to-seq [data] (into {} (for [[k v] (into {} data)] [k (if (instance? java.util.LinkedHashMap v) (to-seq v) v)])))
14:47lancepantzyou suggested removing the inner into
14:47chouserI suppose my macro could generate a defprotocol with a method for each of the java class's methods, then generate a deftype to implement them as simple calls on the wrapped java instance.
14:47chouserlancepantz: yes
14:47lancepantzchouser: so it worked, but i don't understand why, i was hoping you could explain
14:48lancepantzbecause data the first time there is't a seq
14:48lancepantzits a LinkedHashMap
14:48chouser(into {} ...) doesn't return a seq either, it returns a map. Probably a hash-map
14:48lancepantzso is clojure coercing the k/v from the java datastructure
14:48lancepantzyeah, i'm sorry, thats what i mean
14:48lancepantzmap not seq
14:48lancepantzbut it's a clojure map
14:48lancepantznot a java primitive
14:49chouserlancepantz: 'for' calls 'seq' on each of the collections you give it.
14:49chouser'seq' knows how to return sequences for much more than just clojure collections. It can do Java Maps, strings, etc.
14:49chouser,(map int "abc")
14:49clojurebot(97 98 99)
14:50lancepantzok, yeah, that's what i wasn't aware of
15:19Hali_303when doing a (:use somnium.congomongo), it throws a classnotfoundexception. How to find out what class is missing? (using slime)
15:22Licenserhmm hmm hmm
15:23Licenserhow can it be that code (once executed in pmap once in map) behaves entirely different?
15:23stuartsierraLicenser: dynamic context
15:23Licenserhm?
15:23somniumHali_303: are you typing that into the repl?
15:23Licensercan it be that something ghat was set using binding isn't the same over al pmap instaces?
15:23stuartsierraLicenser: thread-bound Vars won't propagate to calls from pmap
15:23Hali_303somnium: yes
15:24somniumHali_303: then it should be (use 'somnium.congomongo)
15:24Licenserhmm so how can I make the content of this stuff I have in binding the same in all instances of pmap?
15:25stuartsierra(fn [x] (binding [*some-var* ...] (function x))
15:25stuartsierraI think there's a contrib macro for that.
15:25Hali_303somnium: I can do that, but then (mongo! does not work
15:26Licenserhm what I have is: (binding [*v* ...] (pmap #(some stuff that uses *v* %) list stuff)))
15:26hiredmanwell that is obviously not going to work
15:26abscondmentHali_303: can you catch & inspect the exception?
15:26Licenserhiredman: obviousely not no :P but intuitively I'd expect that
15:26hiredmanbinding is thread local, pmap executes things on other threads
15:27Licenserso what I'd have to do is make a function with a cosure around it?
15:27hiredmanno
15:27hiredmana function is a closure
15:28hiredmanif closures were the answer that would solve it
15:28Hali_303abscondment: how?
15:28hiredmanbut closures don't close over dynamic scope
15:29Licenserso I am very confused now
15:29hiredman(let [*v* *v*] #(some stuff that uses *v*)) will work because it captures the dynamic scoped value of *v* in the lexical scope binding it to the name *v*
15:29somniumHali_303: what is the error message slime shows?
15:29Licenserah hiredman thanks I'll try that
15:30Hali_303somnium: ahh. nothing. I'm a retard :D
15:30hiredmanit's not something for trying, it works
15:32Licenser__hiredman: nah he does tell me he does not know *v*
15:32Licenser__since it's from a different namespace :P
15:33hiredmanLicenser__: then you did it wrong
15:33Licenser__hiredman: yap likely, that is why I'm a bloody beginner :P
15:35hiredmanso you have a var that you have dynamically rebound?
15:37Licenserhiredman: I use it for logging, there is a function (log ) that writes into *log*
15:38hiredman(pmap (let [*log* *log*] #(do stuff with logging)) list-of-stuff)
15:38brandonwdon't worry Licenser I'm right there with ya :D
15:39brandonwclojure definitely has a learning curve coming from more procedural oo languages
15:39brandonwso cool once stuff starts to click, though :)
15:39chouserdo you understand dynamic scope and lexical scope? if not, that's a good place to start.
15:39chouserperl has both. closures too.
15:40hiredman:(
15:40hiredmanwhy would you mention that?
15:40chouser:-)
15:40chouserthat's where I learned all three!
15:41Licenserchouser: dynamical scope=it figures what it is when he comes there, lexical scope=it figures what it is during parsing
15:41Licenserat least that is how I understood it :P
15:41hiredmanlexical scope is creation time and dynamic is call time, and closures close of lexical scope
15:41hiredmanover
15:45brandonwhttp://en.wikipedia.org/wiki/Scope_(programming)
15:46brandonwthink of lexical scope as what you define a symbol in the scope of reading the code
15:46brandonwinside a function
15:46brandonwdynamic scope isn't related to where it is defined, but rather by the last thing that defined it, like a thread-local binding
15:47hiredmanyou can actually think of it as a single scope with the dynamic scope as a mutable environment frame at the bottom of the stack
15:47hiredmanbrandonw: that is very confusingly worded
15:47brandonwit's scope isn't local to a function, its value is whatever last successfully changed the value, which could be anywhere on that thread (not necessarily where the symbol was defined)
15:48hiredmanbrandonw: still confusingly worded
15:48LicenserI understand the problem but my brain right now failes to wrap around a solution o.o
15:48hiredmanso you can get stickers like "my other car is a cdr"
15:48somnium:D
15:50brandonwyes hiredman your explanation is definitely better
15:51brandonwexcept i don't understand what you mean by 'single scope'
15:53brandonwdoes clojure offer a stack of dynamic bindings? or is it only like you said hiredman: a single mutable frame
15:54chouserbrandonw: theres a stack, but you can only see the current one
15:55brandonwhow would you pop off the last binding off the dynamic stack?
15:55chouseryou leave a (binding ...) scope
15:55brandonwah yes, that makes sense
15:56kotarakbrandonw: I think the pop doesn't return the map. So you can't push it again, to fix the stack.
15:56brandonwi'm thinking in a procedural way again.. assuming each change to the binding is an actual change
15:56brandonwright
15:56brandonwi recall reading that somewhere, too, i think
15:57chouserbrandonw: well you can do that but you'd better know exactly what you're doing.
15:57chouser(doc push-thread-bindings)
15:57clojurebot"([bindings]); WARNING: This is a low-level function. Prefer high-level macros like binding where ever possible. Takes a map of Var/value pairs. Binds each Var to the associated value for the current thread. Each call *MUST* be accompanied by a matching call to pop-thread-bindings wrapped in a try-finally! (push-thread-bindings bindings) (try ... (finally (pop-thread-bindings)))"
15:57Licenserso I've a ns that declares *log* a function that binds *log* to a ref and then calls another function in another ns that calls pmap with some functions that write to *log*. If I do it like this it fails since *log* isn't the right *log* if I do (let [*log* *log*] it failes since it does not know *log* yet if I use (let [*log* my-ns/*log*] it doesn't work since it's a different *log* then I bound :(
15:58kotarakLicenser: guessing: bound-fn?
15:58Licenser*Reads on that*
15:58kotarak(doc bound-fn)
15:58clojurebotNo entiendo
15:58kotarakclojurebot: :(
15:58clojurebotPardon?
15:59brandonwwait
15:59brandonwi just noticed
15:59brandonwthe prefix , was removed from clojurebot interaction?
15:59kotarakdoc always worked without. no?
15:59brandonwoh, it might have
15:59kotarak(inc 1)
15:59kotarak,(inc 1)
15:59clojurebot2
15:59brandonwokay, you're right
16:00Licenserthanks kotarak I see if that helps me ^^
16:00brandonwjust coincidence that this was the first time i was looking at a doc call
16:00kotarakLicenser: you scenario sounds like a valid use case.
16:00Licenserkotarak: my scenario sounds like total mess to me when explaing int :P
16:00kotarakLicenser: (pmap (bound-fn [x] ...) blabla)
16:02hiredmankotarak: if the let is failing I don't see how bound-fn could work
16:02hiredmanthe let takes the value from the dynamic environment, and bound-fn would capture and restore the dynamic environment
16:03hiredmanso if one fails because the value you want is not in the dynamic env so would the other
16:05hiredmanLicenser: if you intend to capture the value of *log* you have to, you know, bind *log* to that value first
16:05Licenserhmm sounds like an idea hiredman now I figure how :P
16:06kotarakLicenser: do you have some code to paste?
16:06Licenserkotarak: yes like 2 dozent files :P let me see if I can extract the important stuff
16:06hiredmanLicenser: it sounds like you are building a circular dependency
16:07Licenserhiredman: shouldn't be no
16:07hiredmannamespace a.a uses and calls functions in namespace b.b and functions in namespace b.b use and depend on vars from namespace a.a
16:07hiredmanthat is a circular dependency
16:09Licenserbut I've a utils namespace (for logging stuff) a frontend namespace and a abackend namespace
16:09Licenserth
16:09hiredmanso?
16:09hiredmanare you or are you not doing what I just described?
16:09LicenserI'll post something one second
16:09hiredmanyou description of what you are doing earlier is exactly that
16:10hiredmanyour
16:13Licenserhttp://gist.github.com/308078
16:13Licenserthat is about what I'm doing
16:13Licensernow *log* is empty after run :(
16:15kotarakLicenser: you need bound-fn, because the let does not change the binding in utils
16:16Licenser*googles for an bound-fn example*
16:16hiredmankotarak: binding changes the binding for *log* from utils
16:17kotarakLicenser: (pmap (bound-fn [x] (log x)) (range 1000))
16:17kotarakhiredman: which does not carry over the pmap
16:17hiredmankotarak: right, but that has nothing to do with thelet
16:17hiredmanlet
16:17kotarakLicenser wrote something about let somewhere above.
16:18hiredmanthe issue with the let is *log* cannot be resolved in backend
16:18Licensersomeone suggested let
16:18hiredmanI did
16:18kotarakOk. I'm confused.
16:18Licenserodd thing is: boundfn does not work either
16:18hiredmankotarak: I am not
16:19kotarakhiredman: good for you
16:19Licenser*tries something*
16:19Licenserah there we go
16:20Licenserproblem was that I bound'fn in the inner map not in the outer map
16:21Licenserkotarak: hiredman thank you two a hell lot for your patience
16:21LicenserI really appriciate it :)
16:21kotarakLicenser: gern geschehen
16:21Licenserkotarak: :D
16:22Licenserheh trairig ist nur, dass pmap langsamer ist als map :P
16:22hiredmanI still think you are going to end up in a circular dependency, you've just delayed it
16:23Licensernarf wrong language sorry
16:23kotarakLicenser: for small problems. The idea of pmap is that the mapped funciton is expensive. For cheap functions the thread spawn overhead dominates
16:23Licenserhiredman: I acutally fixed one by moving stuff to the untils thing
16:23LicenserI had the impression that they use a thread pool so the spawn time is minimal?
16:24chouserminimal is more than none
16:24kotarakLicenser: well, there's a thread called for each item in the seq. So for cheap function "(log x)" pmap *will* be slower.
16:25jcromartieIs there a way to apply middleware to all of the routes in a compojure app?
16:25Licenserkotarak: that is why I used batches
16:25jcromartieI've tried unsuccessfully
16:26somniumjcromartie: (decorate the-app with-my-awesome-middleware) is the usual way, do you have multiple defroutes clauses?
16:26jcromartiesomnium: no, just one defroutes
16:26jcromartiethat's easy enough though
16:26somniumthen decorate should work
16:26jcromartieI was using decorate-with
16:27jcromartieerr, wait... not sure what was going on there
16:33Licenseris there a way to see how many transaction rollbacks I have?
16:34chousernothing non-invasive yet, afaik
16:34Licenseraww :(
16:34Licenserbecause I've the feeling that is an isue right now
16:35Licenserconcidering that when using pmap my entire time goes from 100s to 200s even usign batches
16:36kotarak Licenser: how about sending to an agent?
16:36hiredmannot big enough batches
16:36stuartsierraLicenser: if your logging function does I/O, you could be screwing your throughput.
16:36Licenserno logging isn't what is the issue I think
16:36chouseror increment an AtomicInteger
16:36Licenserat least not this :P
16:37Licenserthe problem is surely the map that is one big ref so if a unit (I code a game) moves any any other unit acceses the map in the same time it goes all boom I fear
16:37Licenserpropably should make each field a ref
16:38chouserLicenser: you can try using an AtomicInteger to count your retries, but of course that may change the behavior
16:39Licenser*scratches head how to handle this best
16:40Licenserchouser: *nods* that's an idea but I feel I already know where the issue is, as some a unit moves every other unit will have to retry the entire thing
16:40Licenserbut enough clojure for today, sadly work is calling tomorrow :(
16:40Licenserthank you all for your help!
16:40LicenserYou're a great bunch of community!
16:58hiredmangeez
17:00arohnersomnium: does congomongo support db-refs?
17:04somniumarohner: the java-driver has a db-ref class
17:05arohnersomnium: k. looks pretty easy to write a wrapper for it
17:05lancepantzi do not see a way to access the nth item in a sequence, am i missing something?
17:05arohner,(doc nth)
17:05clojurebot"([coll index] [coll index not-found]); Returns the value at the index. get returns nil if index out of bounds, nth throws an exception unless not-found is supplied. nth also works for strings, Java arrays, regex Matchers and Lists, and, in O(n) time, for sequences."
17:05somniumarohner: since its a convention for a map with {:collection ... :id ...} Im still not convinced of their utility, but maybe Im misunerstanding
17:06arohnersomnium: I'm hardly an expert on mongoDB, but I think it's for "joins". if you have a bunch of objects that "point" at the same obj, you can save duplication
17:06arohneror if you modify the objecting being pointed at
17:09somniumarohner: right, what I dont get is that a map like {:name "bob" :friends [#someid #someid]} seems more or less equivalent, but without the extra type
17:10lancepantzthanks again arohner
17:10lancepantzthat one's not in my book :/
17:11kotaraklancepantz: http://clojure.org/API
17:12lancepantzstill need to know what the function is called
17:13kotaraklancepantz: skimming over it, clicking on interesting sounding/strangely looking/unfamiliar functions, I always find something interesting. :)
17:13lancepantzagree
17:13arohnersomnium: how do you fetch by id?
17:16somniumarohner: (fetch :things :where { :_id #<ObjectId abcdefgh...> })
17:16arohnerhuh, that wasn't working for me
17:17arohnerbut :_id (ObjectId. "abdef...") does
17:17somniumarohner: have to make an Id object
17:18somniumsomeone suggested adding an (object-id ...) fn, but its the same length as the java constructor :/
17:18arohnerI slightly prefer (object-id ...) over (ObjectId. )
17:18somniumat first I tried auto-coercing them, but it got confusing
17:18arohnerthe other nice thing is you don't have to import it
17:19somniumon the server usually have the id objects, but receiving json need to wrap
17:19somniumtrue, I can go ahead and add it
17:23lpetitrhickey: would you mind if I use the clojure logo as the logo for the counterclockwise project on google code ? (would be better that the "out-of-the-box" logo) : http://code.google.com/p/counterclockwise
17:23redwyrmif functions are side-effect free, then that means you can't call any Java library functions that have side effects (such as windowing stuff), right?
17:23redwyrmunless it's not in a function
17:25rhickey_lpetit: the Clojure logo should only be used to refer to Clojure itself
17:26dakroneare there any html-stripping libraries for clojure?
17:26lpetitrhickey_: that's what I wanted to check with you. Thought it could be more "visual" for people to remind them of clojure, but you're right of course.
17:33piccolinoAm I correct in my understanding of the docs for the function read that it will take a string representation of a clojure form, and give you back the actual form without evaluating it?
17:34technomancypiccolino: not quite; it actually takes a reader which provides the string
17:34piccolinoOh, right. But the rest is correct?
17:34hiredmanread-string takes a string
17:35piccolinoAh, there we go.
17:35piccolinoJust had to scroll down a bit more.
17:35piccolinoThanks guys.
17:36hiredmanyou can get the reader to eval stuff
17:36Chousukebind *read-eval* to false to prevent that
17:36Chousukeif course it doesn't matter if you control the input completely
17:37piccolinoYeah, I want it to not eval stuff.
17:37Chousukebut eg, someone might pass you a string "(foo bar #=(take-over-system))" :P
17:38Chousukethe #= reader macro is a way to eval things at read time
17:38piccolinoAh, I see.
17:45powr-tochas anyone here used clojure.contrib.http.agent ?
17:47powr-toctomoj: was it any good? :-)
17:47tomojI like it
17:48tomojhave to be kinda careful or you end up with a lot of trouble debugging
17:48hiredmanI think stuartsierra said it needed to die a thousand deaths
17:49powr-tochiredman: yeah, I seem to remember seeing him mention that... Being the author what was his problem with it? :-)
17:49tomojif you treat it like a synchronous library and just try to call result on the agent as soon as you create it, and then your handler blows up, it's ugly to debug
17:49hiredmanpowr-toc: I think he hates contrib
17:50hiredmanwhich I understand, it's a giant pile of stuff
17:50powr-tochiredman: it sure is :-)
17:51powr-toctomoj: I shouldn't need it to read a page... I just want a place to send outbound post requests to
17:52powr-toctomoj: so asynchrony is what I want
17:53powr-tocby that, I mean non-blocking
17:54dakroneany NLP fans in here?
17:55tomojpowr-toc: should at least work then
17:56tomoj(http-agent "url" :method "POST" :body "post body")
17:56powr-tocwhat happens if an exception is thrown inside the agent?
17:56tomojdakrone: I'm a fan
17:56tomojnot an expert
17:57tomojpowr-toc: then the agent has errors, which you can see with agent-errors
17:57tomojdone? and error? are helpful too
17:58dakronetomoj: cool, I'm working on a clojure-opennlp library
17:58tomojawesome
17:58tomojI have dreamed before of replacing nltk
17:59tomojunfortunately my nlp TA doesn't want to read clojure code so I have to use python :(
18:00powr-toctomoj: Am I right in thinking each request is effectively an agent?
18:01tomojyep
18:01powr-tocmakes sense
18:02dakronetomoj: check out http://gist.github.com/308172
18:02dakronesuper rough, anyway
18:03tomojawesome
18:03tomojmy next homework assignment is a pos-tagger
18:15jcromartieI wish int coerced strings into integers
18:24dakronejcromartie: http://pastie.org/831753
18:25jcromartie:) ahead of you
18:25dakrone:)
18:29alexyk,(->> (remove nil? [nil nil 1.0 2.0]) (apply max))
18:29clojurebot2.0
18:29alexyk(->> (remove nil? [nil nil]) (apply max))
18:30alexykwell, java.lang.IllegalArgumentException: Wrong number of args passed to: core$max (NO_SOURCE_FILE:0)
18:30alexykcan't it just say nil?
18:32alexykI need a -->>-ble way to apply max to non-zero args or return nil
18:35dakrone,(first (->> (vector (remove nil? [nil 1])) (apply max)))
18:35clojurebot1
18:35dakrone,(first (->> (vector (remove nil? [nil nil])) (apply max)))
18:35clojurebotnil
18:35dakronealexyk: how about that?
18:36dakronenot exactly the same, since it would return a list without the (first ..)
18:36alexykhmm
18:36hiredman
18:37alexykhiredman: is it the ellipsis of disapproval?
18:37hiredmanyes
18:37alexykhiredman: (macroexpand ...)
18:37dakronethere are probably much better ways to do it, I'm still learning clojure entirely, so take hiredman's advice over mine
18:37somniumwasnt that some artifact from Lord of the Rings?
18:37hiredmandakrone: that does not work
18:38hiredmandakrone: it's not a matter of better ways to do it
18:38hiredmanit just doesn't work
18:38dakronehiredman: bleh, you're right
18:38alexykyeah
18:38dakronemy fault, sorry
18:39hiredman,(-> [nil nil] (remove nil?) (apply max 0))
18:39clojurebotjava.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to clojure.lang.IFn
18:39hiredman,(->> [nil nil] (remove nil?) (apply max 0))
18:39clojurebot0
18:39hiredmanbleh
18:39alexykah, sticking 0 works
18:40slyphonhrm
18:41slyphondo you have a set of things you import into your repl when you're working on something? in addition to the code you're working on, that is
18:41somniumalexyk: is the stuff you did with the cursors on github?
18:41slyphonis there a convention for including that stuff?
18:41somniumslyphon: user.clj
18:41dakroneyea, a user.clj
18:42dakronein your classpath
18:42slyphonoh sweet
18:42slyphonahhh
18:42slyphonok, that makes sense
18:42slyphondo you normally work from the context of the user namespace, and import/use stuff from the other namespaces?
18:43slyphoni've been switching to the ns of my project and mucking about
18:43alexyksomnium: kind of, in the guts of another project
18:43alexyksomnium: I'll send you a link
18:47slyphonsomnium dakrone: thanks! that's way more convenient :)
19:08nathanmarzanyone here familiar with clojure.contrib.logging? - it's not finding log4j even though it's in my classpath
19:10slyphonnathanmarz: i set it up with apache-commons + log4j last night but it "just worked"
19:10nathanmarzslyphon: did you just include those jars in your classpath?
19:10slyphonpretty much
19:11nathanmarzthe odd thing is that if i copy-paste the source of clojure.contrib.logging into my repl it works
19:11slyphoni'm pretty new to this, though so i'm afraid i'm not gonna be able to be much help
19:11slyphonthat is odd
19:12technomancynathanmarz: earlier versions of c.c.logging had bugs that would cause the logging impl to get hard-coded at compile-time
19:12slyphonalso, *impl-name* will tell you what implementation it's using, i found that helpful
19:12technomancyjava logging is such a mess. I have used three different libraries that provide abstraction between different logging backends, but I've only used two backends.
19:13slyphonhaha
19:13nathanmarzmy project.clj has this as dependencies: :dependencies [[org.clojure/clojure "1.1.0"]
19:13nathanmarz [org.clojure/clojure-contrib "1.1.0"]]
19:13technomancyand one of the two was by accident, due to the aforementioned bug
19:13technomancynathanmarz: it should be fixed in that version; must be another problem.
19:13slyphonhah
19:13slyphontechnomancy: i tried out the new project by the guy that wrote log4j, it was pretty good
19:14slyphonbut, i mean, then again, it's a friggin *logging library*
19:14technomancyif I had to do it from scratch again, I'd just write a wrapper around log4j instead of using c.c.logging
19:14technomancyheh
19:14slyphoni really like the 'spy' function
19:14slyphon*that* is something i've wanted in other langauges for a long time
19:15slyphonso, if i'm going to change the state of a java object, it doesn't make a difference if i have a ref pointing to that object or not
19:15slyphonin terms of concurrency concerns
19:16slyphonso, what do you do to synchronize access?
19:16slyphoni'm specifically working with a socket, here
19:17slyphonnot all at once, now
19:18somniumslyphon: you can put it an agent to serialize access
19:19slyphonok, that should do it
19:19slyphondidn't think of that, thanks
19:19raeki've been thinking about trying out cells (the new reference primitive) on these sort of things...
19:19slyphonit's different from (dosync) right?
19:20slyphondosync only cares if the ref itself changes
19:20somniumslyphon: its async, just send or send-off
19:38raekwhich version of clojure is this intended to be run in? http://gist.github.com/306174
19:39hiredmanmaster I imagine
19:39raekI get "Cannot assign to non-volatile: val" in 1.2.0-master when I evaluate (deftype ThreadCell ...
19:40hiredmanmaster from git?
19:40raekyes
19:40raekmaybe I need build a newer version
19:42hiredman
19:42hiredman"master from git" implies the latest from git
19:42hiredmanso don't say "yes I have that" unless you have the latest
19:44raekok, that was not a very clear utterance of mine... :)
19:44raekanyway, what I had was a less-than-a-week old version of master
19:46hiredmanwell, the gist is less-than-two-days old
19:47raekI guess I didn't realize how quick things change... :)
19:48raekit works with master from git, I see now
19:48raekthanks
19:49lancepantzanyone mind looking at http://github.com/lancepantz/clj-yaml and seeing if you can figure out why 'lein test' doesn't work?
19:56chouseroooo... metadata on local from an outer scope are available to macros that expand inside.
19:57technomancylancepantz: lein test only supports clojure.test not clj-unit
19:57lancepantzah
19:57lancepantzcool
19:57lancepantzthanks for the project btw man
19:59technomancyglad you like it
20:00hiredmanchouser: did you ever figure out keyword call site caching?
20:00hiredmanwell then
21:30jcromartieno offense to Dan Larkin, but I went back to http://richhickey.github.com/clojure-contrib/json.write-api.html after banging my head against the wall adding datatype handlers to clojure-json
22:19jcromartieis there a more idiomatic way to turn a map into a keyword vector than (reduce into [] m)
22:19jcromartie,(reduce into [] {:foo 1 :bar 2})
22:19jcromartieclojurebot: on vacation?
22:20clojurebot[:foo 1 :bar 2]
22:21clojurebothttp://haacked.com/images/haacked_com/WindowsLiveWriter/IConfigMapPathIsInaccessibleDueToItsProt_1446B/works-on-my-machine-starburst.png
22:27Rayneshttp://stackoverflow.com/questions/2245985/compile-clojure/2246577#2246577 "Thank you so much, you are amazing."
22:29JonSmithi need to download lein
22:33jcromartieWhen did Google start returning results without all of the words in the query?
22:34TheBusbywhen did they not?
22:34jcromartiefor a long time
22:35jcromartieif I search with "compojure" in the query I can get results that clearly never had "compojure" on the page
22:35TheBusbyI think you may be mistaken, or are you using "+keyword" syntax?
22:35jcromartieno, except for stop words, they always returned results that matched all of the words in the query
22:35TheBusbyif you search for elephant, you'll find pages that only refer to packaderm
22:36TheBusbyI don't think they've ever supported "all pages that include all keywords" as the default behaviour
22:36TheBusbygoogle derives most of their logic from links, hence keywords aren't valued as highly
22:37TheBusbyhence you can google for "evil dictator" and the first hit may be the whitehouse.gov
22:37RaynesLOL
22:39wiligHopefully a simple question: If a have a function that requires 3 arguments and a sequence of three things is there a way to call the function with the sequence? Without split out each one?
22:40TheBusbywilig: do you have an example of what you might be looking for?
22:40jcromartiewilig: apply
22:41jcromartie,(apply + [1 2 3])
22:41jcromartie,(apply str [1 2 3])
22:41clojurebot6
22:41clojurebot"123"
22:41jcromartieseriously, what's up with clojurebot
22:41BrandonWi thought he said that the function requires 3 arguments?
22:41wiligjcromartie: duh! Thanks.
22:41TheBusbyapply should work for N arguments
22:41BrandonWoh okay, nevermind
22:42BrandonWi thought apply worked on the basis that it can apply the first two arguments, then the result of that to the 3rd arg, then the result of that to the next.. etc.
22:42jcromartiethat's reduce
22:42BrandonWoh okay
22:42jcromartieoh wait
22:42jcromartieno
22:42BrandonW(doc apply)
22:42clojurebot"([f args* argseq]); Applies fn f to the argument list formed by prepending args to argseq."
22:42BrandonW(doc reduce)
22:43hiredman,((reduce partial + [1 2 3]))
22:43clojurebot"([f coll] [f val coll]); f should be a function of 2 arguments. If val is not supplied, returns the result of applying f to the first 2 items in coll, then applying f to that result and the 3rd item, etc. If coll contains no items, f must accept no arguments as well, and reduce returns the result of calling f with no arguments. If coll has only 1 item, it is returned and f is not called. If val is supplied, returns the re
22:43clojurebot6
22:43dnolen_ato: you around?
22:43BrandonWok you are right, jcromartie
22:47RaynesApply just takes the elements out of the sequence and lays them neatly in a row in front of the fnmonster so he can gobble them up.
22:48TheBusbyso ((reduce partial + [1 2 3]) 4) would end up being (+ 4 (+ 3 (+ 2 1)). What is the common use case for something like this?
22:50slyphonwhere's the "cell" stuff?
22:50chouserslyphon: just in a gist
22:50slyphonoh
22:50slyphonbummer
22:56chouseryou can use it though
22:56chouserjust load the file. :-)
22:56slyphondo you have a link?
22:56chouserhttp://www.shadyurl.com/
22:56chouserno. not that
22:57chousertry this: http://gist.github.com/306174
22:58TheBusbyWhat is "magic" here? (magic - [4 5 6] [1 2 3]) => [3 3 3)
23:01BrandonWthe magic of functional programming, of course!
23:02drewrTheBusby: map
23:03BrandonWif i was looking to learn more about clojure, should i get one of paul graham's books, go through SICP, or wait for the new clojure books to arrive?
23:03TheBusbydrewr: thanks! I didn't realize you could use map like that
23:05drewrBrandonW: depends on what kind of knowledge you have already
23:05BrandonWthis is my first foray into both lisp and functional programming
23:05BrandonWi forgot to say, i already went through Programming Clojure
23:09drewrstart writing code and see what kinds of issues you run into along the way
23:09drewrthough joyofclojure.com has been great so far, so get that when it comes out
23:19TheBusbyFor dealing with nested structures, how can you do this? (-> [1 2 3 4] (partial #(nth %2 %1) 3))
23:20TheBusby,((partial #(nth %2 %1) 3) [1 2 3 4]) ;; Works
23:20clojurebot4
23:24jcromartieOK so doing a with-json middleware using (decorate routes with-json) doesn't work
23:24jcromartiebecause whatever is returned by the route handler is converted into a response map as it goes up the chain of middleware
23:24jcromartieI think
23:25jcromartiei.e. I can't return a simple map from a handler and expect my with-json middleware to take care of it
23:29JonSmithare there any html generating frameworks for clojure that are higher level than converting vectors into html?
23:30JonSmithi'm using clj-html and it is really good, but i keep ending up with stuff that seems kind of awkward
23:33JonSmithi'm just having trouble conceptualizing managing all of the different pieces of webpages that i want to put together, and normally that means i need some macros or a higher level abstraction
23:34konrAnybody here does automatic stock trading?
23:34BrandonWexit
23:34BrandonWwhoops
23:40jcromartieJonSmith: there's Enlive
23:40jcromartiebut that doesn't generate HTML, it transforms it
23:41JonSmithyeah
23:41JonSmithi'm hoping to get 1 level up the abstraction level
23:41JonSmithif that makes any sense
23:44jcromartiecan you work with functions that generate the HTML-generating code?
23:44jcromartiemacros, etc?
23:44jcromartiethat's what lisp is all about after all
23:44JonSmithyeah that's kind of what i'm doing write now
23:45JonSmithright now*
23:45JonSmithi'm working the clj-html and making a bunch of functions that expand into templates
23:45JonSmithi guess i can build a lower level of utility functions and work my way up
23:47JonSmithi guess the problem is that i build lisp code programmatically all of the time using macros and backquote and stuff, but i'm not seeing an obvious way to do a similar thing with html
23:48JonSmithI guess mostly because i think i'll run into efficiency problems and there is nothing quite like unsplice
23:49JonSmithnot unsplice, splice
23:49JonSmithanyway i'm rambling