#clojure logs

2009-07-14

00:47yangsxdurka42: yes, that's my last-resort
03:10Lau_of_DKGood morning gents
04:55svqyqbhttp://tinyurl.com/nkypfa
04:56jdz,'(x ^ 2)
04:56clojurebot(x (clojure.core/meta 2))
04:57jdzthis looks quite wrong to me
04:57kotarakWhy?
04:57jdzoh, nvm
04:58kotarak^foo is syntactic sugar for (clojure.core/meta foo)
04:58jdzye, i just checked the reader doc
08:05mattreplanyone know if fixtures in clojure.test are supposed to work? 'run-tests doesn't seem to kick them off - i'll spend some time finding the problem but first wanted to verify it's not just me
08:06mattreplin this specific case, I have a :once fixture... code here: http://github.com/mattrepl/clojure-cassandra/blob/c0b8acda065b312882a73755834c378f6aa0b2c4/src/cassandra/test.clj
08:40Chousermattrepl: you're binding 'f' in the inner doseq.
08:40Chousermattrepl: that shadows the 'f' arg, so you don't call what you want to call at (f)
08:42mattreplChouser: (f) is in outside the scope of that doseq though, no?
08:42Chouseroh
08:42Chouseryes. hm.
08:43mattreplthe problem I'm seeing is that init-db isn't invoked at all, so when the tests are run there is no database available
08:50Chousermattrepl: you see your fixture if you eval ^(the-ns 'cassandra.test) ?
08:52mattreplyup
08:55mattreplthough appreciated, don't worry about spending too much time on that specific case - just wanted to see if anyone else had issues with fixtures =)
08:56ChouserI've never heard of them before
08:56Chouserbut it looks like if test-ns-hook is provided, the fixtures aren't called
09:00mattreplah, wondered about that. thought I tried it but guess the recompiled version with it commented out wasn't being picked up. easy to work around it, might submit a patch if the innards don't require too much modification
09:02mattreplChouser: it ok if I submit a ticket?
09:04Chouserheh. good question.
09:04Chouserthat's not contrib anymore so I suppose we need rhickey approval for that?
09:05mattreplit'll either be a quick fix, or a bigger reworking. but I think having fixtures and defined order of tests don't need to be mutually exclusive. though, it's not that hard to manually use the fixture by calling it in 'test-ns-hook
09:06Chousermy opinion is that a ticket is warranted -- it could be closed either with a fix to the code or to the docs, I suppose.
09:07Chouserrhickey: fixtures are a clojure.test feature
09:07mattreplfor clojure.test, fixtures aren't called if test-ns-hook is being used
09:07mattrepltest-ns-hook allows one to specify which tests get called (and their order)
09:08Chouseryeah, I hadn't heard of fixtures before. but they're in clojure now! :-)
09:09Chouserit's just a bit of combinatorial complexity. the test-ns-hook feature doesn't compose with the fixtures feature.
09:09Chousukeyou suppose test-ns-hook could be replaced or augmented with a higher-level macro or something?
09:09mattreplif you group tests under one big test (e.g., test-addition, test-multiplication are individual tests that could be called from a higher-level test, test-arithmetic) then to prevent the lower-level tests from being called directly the user needs to supply a test-ns-hook function that specifies which test to call
09:09Chousertest-ns-hook lets you control which tests in your ns get run and in which order
09:10Chousukelike (namespace-test-order [testfn1 testfn2 ...])
09:10Chouserbut fixtures run something before and/or after each test
09:11mattreplor before/after all tests
09:11Chouserright. the latter case would be easier to fix to work with test-ns-hook
09:12Chousukewhile test-ns-hook could be the low-level "plumbing"... you could have ns-test-order generate (once-fixture (fn [] (each-fixture testfn1) (each-fixture testfn1) ...)))
09:12Chousukeand set it as the hook
09:12Chousermmmmm... complexity. :-)
09:12Chousukenot really.
09:12Chouseranyway, the question at hand is: does something need to be fixed.
09:12Chouser"how?" can be answered later
09:13Chouserand I think at the very least the lack of support for the two features together should be documented.
09:13mattreplI agree with you that at least documentation should be amended
09:13rhickeyseems like something to discuss on the group. Too difficult to make decisions here not involving all interested parties
09:13ChousukeI don't think there's anything wrong with test-ns-hook; you could very well use it to set up a custom hook that ignores fixtures for a certain test.
09:14Chousermattrepl: there you go -- you have recieved permission to bring it up on the group. :-)
09:15mattreplheh, alright. Will fire a note off shortly
09:15mattreplthanks for taking a look
09:16Chousersure. thanks for pointing out a part of clojure proper that I didn't know existed! :-}
09:24AWizzArdrhickey: do you still have enough time to work "full time" on Clojure?
09:41rhickeyAWizzArd: not a matter of time, but of money
10:42rhickeyHas anyone tried the ensure branch?
10:43rhickeymaybe I'll just have to merge it with master :)
10:43drewrI haven't yet.
10:43ChouserI don't even have any code that uses ensure
10:44rhickeyChouser: hopefully that code will be unaffected, but all STM code runs through new logic
10:44Chouserah. well, not even very many transactions...
11:11rysNot having to sleep would be pretty excellent
11:13rsynnottrys: as long as employers weren't let in on the secret, yes
11:16rysHeh
11:16rysBeing asked to work more hours on PHP projects would have to be close to the bottom of the programming ladder, yes
12:06cemerickwasn't there a function that returned the namespaced symbol for a var? It's easy enough to poke at the public fields of Var and Namespace, but I could have sworn that there was a fn for this. var-sym?
12:15lisppaste8cemerick pasted "Stuff like this makes me think I'm just doing it wrong..." at http://paste.lisp.org/display/83579
12:20rhickeycemerick: I don't think there is a fn for that
12:22cemerickrhickey: watching myself jump through hoops makes me think that wanting that symbol is indicative of a more fundamental design flaw (on my part)
12:23rhickeycould be
12:23rhickeyvars aren't necessarily interned
12:24rhickeyor there hasn't been much demand. Vars used to keep their syms ns-qualified
12:25rhickeyggroups seems to have stopped updating membership counts
12:26rhickey2212 vs 2028
12:30cemerickI need to track whether certain functions have been applied to certain objects, so I've been keeping a map of fns -> sets of objs around. That gets a little tiring when debugging, so I figured I'd keep a map of symbols of fns -> sets of objs. Seems simple enough, but I feel like I'm going to get burned.
12:44rgrquit
12:57AWizzArdrhickey: and I was already wondering why nothing happens anymore
12:57AWizzArdtypically the user count went up a little every few days
12:59cemerickis user count really a concern in general?
12:59rhickeyits still going up, they must not be running the map-reduce job that updates the front page stats
13:53Chousercemerick: seems like I've written a function like that before.
13:55ChouserHm. I want 'promise', but we're on 1.0.0 and it would be tough getting our build system to use git instead of fetching a .zip
14:01technomancyso is it true that keywords can't have metadata?
14:02Chouser,(instance? clojure.lang.IMeta :foo)
14:02clojurebotfalse
14:02technomancy=(
14:02technomancyI guess I can use symbols for this
14:02Chouserthere's only one keyword object for each keyword
14:03Chouserso you wouldn't be able to have two :foo's with different metadata
14:03technomancyright, that makes sense
14:03technomancybut that would be true for symbols too, right?
14:03Chousernope, lots of symbols that look the same.
14:03Chouser,(identical? 'a 'a)
14:03clojurebotfalse
14:04technomancywouldja look at that
14:09Chouser,(binding [*print-meta* true] (prn '{:a #^a foo, :b #^b foo}))
14:09clojurebot{:a #^a foo, :b #^b foo}
14:10Chouser,(binding [*print-meta* true] (prn '#{#^a foo, #^b foo}))
14:10clojurebot#{#^a foo}
14:18Anniepooanybody know where to tell La Clojure/IntelliJ innerds where clojure is? Have a working project, made a new one, and askign for a repl does java.lang.NoClassDefFoundError: clojure/lang/Repl
14:20Anniepoostrange part is, I can compile and run
14:22Anniepoo(fwiw, this is a bug in La Clojure)
15:07Lau_of_DKWhere do I go to read about these upcoming modifications to the STM ?
15:08Chouserwhich ones?
15:09hiredmanI've heard of exposure of some already existing nobs, but not modifications
15:09Lau_of_DKChouser: Ensure branch, etc
15:09Chouseroh! I've not seen anything detailed about the ensure branch. I guess there was a g.group thread that may have had the gist of it.
15:11ChouserLau_of_DK: http://groups.google.com/group/clojure/browse_thread/thread/f7b4365b1c71b665
15:11hiredmanI seem to recall that currently ensure just does a dummy write or something, so I imagine the ensure branch is about actually implementing ensure as its own code path
15:11Lau_of_DKThanks
15:34rzoomafter reading that thread about ensure, it is amazing that clojure does all of that "under-the-hood". wow.
15:39rhickeyhiredman: ensure never did a dummy write, but took a similar write lock, now takes shared read locks. Thus, ensure now sits squarely between reads and writes, imposing no conflict with reads but holding up writes. It should be avoided unless you have a genuine write-skew situation, rare in practice
15:39rhickeyhttp://en.wikipedia.org/wiki/Snapshot_isolation
15:39hiredmanI see
15:40rhickeythe benefit is now multiple overlapping ensures all succeed
15:40rhickeybefore they took turns
15:40hiredmanah
15:41rhickeyvs dummy writes, which will (still) take turns
15:46Chouser*sigh*
15:47rhickeyI'm closer to adding map! or mapv all the time - would it help?
15:47Chouseryup
15:48Chouser(map deref (doall (map make-promise-fn input-seq)))
15:49Chouserif input-seq were longer, I suppose inserting a seque might make sense as well.
15:49Chouserhm
15:49Chouseractually...
15:49rhickey(mapv (comp deref make-promise-fn) input-seq))?
15:50Chouserwell, I want the make-promise-fn calls to run on ahead
15:51rhickeyI was ignoring that bit
15:51Chouseroh
15:51Chouserwell then, yes
15:51Chouser:-)
15:51rhickeywhat about mapv as the 'imperative' map
15:51rhickeywould return a vector
15:52rhickeynon-lazy
15:52Chouseressentially like (vec (map func coll)), but implemented more efficiently?
15:52rhickeyright
15:53Chouserworks find for me. I find myself wanting (vec (for ...)) approximately as often
15:53rhickeyand (vec (filter .. etc
15:53Chouseractually -- I dunno.
15:53Chouseryeah
15:54Chousermaybe better to have vec standing out there, telling everying you're going non-lazy here
15:54Chouserin this case it was just a silly slip do you dorun instead of doall -- I use both infrequently and get them confused.
15:54Chousershould have just used vec
15:55rhickeyvec is the advice I give these days
15:55Chousers/should have/could have/
15:55Knekk(vec forces evaluation?
15:55rhickeyKnekk: has to
15:55Chouseronly didn't becuase it seemed silly to go do a vec in the middle of (map ... (map ...))
15:56Knekkrhickey: It's not documented, for those of us who don't yet start thinking about how data is implemented in clojure
15:57rhickeyKnekk: only lazy things are documented as such, everything else is not lazy
15:58rhickey#!(map ...)
15:59rhickey#!(for...) #!(filter ..)
15:59Chouseris that vec or doall ?
15:59rhickeyvec
15:59Chouserok
16:00rhickeyone problem is it no longer returns a seq
16:00clojurebotPeople have a problem and think "Hey! I'll use a regular expression!". Now they have two problems....
16:00rhickeyclojurebot, the life of the party!
16:01hiredman~rhickey
16:01clojurebothe works hard so you don't have to
16:03Lau_of_DKhehe, fun
16:09Chouserhuh, this works: (def #^Integer nums {:a 5})
16:10Chouseras in, this then requires no runtime reflection: (.shortValue (nums :a))
16:13hiredmanHuh
16:14Chouserof course if you use (get nums :a) you lose it
16:14hiredmanweird
16:14hiredmanI don't understand that
16:14technomancythat's wild
16:15hiredmanit seems like that should make type hinting the return values of functions possible
16:15Chouserit does
16:16hiredman(defn #^{:tag Integer} foo [a b] (+ a b))
16:16Chouserthe :tag metadata on a var means either that var holds a value of that type *or* holds a function that returns that type
16:17hiredmanno kidding
16:17hiredmanof this I was not aware
16:17Chouseryour foo example works fine
16:18hiredmanI, of course, was jsut playing with it in a repl
16:18Chouseror just (defn #^Integer foo [a b] (+ a b))
16:18hiredmanI started looking at rewriting LispReader in clojure
16:19Chouserah! what do you think?
16:19hiredmanread() is very imperative
16:19hiredmanand many things are private or package scoped
16:20ozzileeMind-bender: If Foo is a gen-class class, and it uses bar.clj, can functions in bar.clj call methods from Foo's superclass?
16:21ozzileeWait, I'm doing something terribly wrong.
16:23ozzileeOk, Foo inherits from javax.servlet.http.HttpServlet. It's compiled into a .war file. I want to call Foo's inherit getServletContext method. It's not a static method. How can I get at the Foo instance?
16:23hiredmanI wanted to start by just implementin LispReader/read and still calling stuff in LispReader and slowing swap stuff out
16:25replaca__rhickey: are you hanging out in these parts?
16:25ChouserAnyway, there's currently no way to hint (defn nums {:a 1}) so that you can do (.count nums) and (.shortValue (nums :a)) without runtime reflection
16:26Chouserhiredman: ah. yeah, you might have to go whole-hog
16:26hiredman:(
16:26hiredmananyway, I am going to continue to meditate on it
16:30ozzileeThis is insane. Surely someone has gotten Compojure to serve resources out of a .war file?
16:31Chouserozzilee: you want to call an inherited method of a gen-class class?
16:31Chouserozzilee: see :exposes-methods in (doc gen-class)
16:32ChouserI didn't say that right. See that doc anyway. :-)
16:34ozzileeChouser: I don't know if that helps me. I need to call an instance method, but I don't see a way to get hold of the instance.
16:35Chouseryou're in a gen-class namespace?
16:35Chouserthat is, where is the code that's trying to make the call?
16:35ozzileeChouser: In a file :use'd into a gen-class namespace.
16:36ozzileeIn the namespace I'd be able to do it. I think I need to get the instance through some other means though.
16:36Chouserwho is calling your :use'd code?
16:38ozzileeHrm. Me, directly, on the repl, without the class ever being instantiated. I was thinking it was a static method, it's not. Can't be done this way.
16:40ozzileeI have some initialization code I need to run when the webapp is deployed, I was going to just run it with a repl with the .war file, but it doesn't work because I can't get at resources without a servletconfig. I'll have make a separate initialization tool.
16:40ozzileeOr make the initialization code callable through the webapp.
19:15hamza`are there any side effects to creating a structure called a line and use a varible name line to refer to the line structure?
19:15ataggartthe variable name wilol shadow the struct so you won't be able to call (struct line)
19:15ataggartbut other than that I don't htink so
19:16RaynesThat's odd. Why would he ever need to?
19:17hamzasorry i got disconnected can you write what you said again..
19:18Raynes[18:14] <ataggart> the variable name wilol shadow the struct so you won't be able to call (struct line)
19:18Raynes[18:14] <ataggart> but other than that I don't htink so
19:18ataggarttypos and all :)
19:18Raynesataggart: :p I only copy things, I don't fix them. :)
19:19hamzathank you.
19:21hiredman“which makes sense since 5 could be anything”
19:27Raynes"I tried Clojure now, "Hello, World" takes over 1 second to start and run for me. Is it supposed to be like that, or am I doing something wrong?"
19:27RaynesWhat is wrong with people? :|
19:28Chousuke:P
19:28RaynesThey always seem to forget that Clojure is running on the JVM.
19:28Chousukewell, it is a real problem.
19:28RaynesIndeed, but still.
19:28ataggartthere are no solutions, only trade-offs
21:20cp2ffsdafsdfds231233346123123332131234444
21:20cp2oops
22:02carkhello
23:21grrrtIf I were to package a project and put it online somewhere, what's the best way to deal with dependencies?
23:21grrrtI currently have clojure, clojure.contrib, jLine and a jar for Swank/Clojure support in my lib dir
23:22grrrtbut including them in the project might not be such a good idea
23:22grrrt- this is for development only, a finished product would be self-contained
23:30technomancygrrrt: if your project doesn't have any non-development dependencies outside clojure or contrib, just offering it as a jar is reasonable
23:30technomancygrrrt: is it an application, or a library?
23:31grrrtit wil be a library
23:31grrrtit's about the packaging of the source code
23:31grrrtin a repository somewhere
23:31technomancyin that case it would be most useful for others using it as a dependency to make it a maven project
23:31technomancysince that's the only system that supports real dependencies
23:31grrrtyeah I know...
23:31grrrtso clojure's in maven now
23:32grrrtbut what about clojure.contrib?
23:32technomancyit's not in the central repos, but there are 3rd-party repos that have it
23:32grrrtah that's good to know. I'll search the google group for info
23:32technomancyactually... you might be able to use corkscrew for this
23:32clojurebotcorkscrew is a proof-of-concept build system and dependency manager (http://github.com/technomancy/corkscrew)
23:33grrrthmm
23:33grrrtinteresting!
23:33technomancyjust put a project.clj file in your project root that mentions the contrib dependency, then run "corkscrew install"
23:33technomancythen your ~/.m2/repository directory should be good to go; you can rsync it to an HTTP server somewhere and anyone can use it as a dependency
23:33grrrtI'll look into that, thanks
23:34technomancyI would like to get corkscrew to a point where it works with zero maven knowledge, but at this point the abstraction will probably leak out a bit
23:34ddonnellhow do I build clojure-contrib?
23:34technomancygrrrt: I'm about to head off, but you should be able to catch me here later this week if you have questions.
23:34grrrtthanks!
23:35grrrtI'll look at corkscrew
23:35grrrtand try to get my library sources presentable :)
23:35technomancywell that's the hard part. =)
23:35technomancywhat's the library?
23:35grrrthm
23:36grrrtI had to think about that for a second :)
23:36grrrtthere are three parts: a system to create Swing widgets in a very simple declarative fashion
23:36technomancyactually just putting your library in a public git repo and keeping all the source under src/ is enough for it to work as a dependency using corkscrew, but since there are only about five corkscrew users in the world (including you) that's not so great. =)
23:36grrrta system to make Swing's listener and event system behave better / easier with clojure
23:37grrrtand, the main dish: a dataflow approach to getting values and events from one place to another
23:37technomancycool
23:37grrrtwell I have to make it work first :)
23:37grrrtstill a proof of concept. but I might be onto something
23:37technomancyat least half of all clojure projects in existence are proofs of concepts.
23:37grrrthaha
23:37grrrttrue
23:38grrrtthe idea of my approach is that you create signals from some source (a swing widget, a ref, ...)
23:38grrrtto some target
23:38grrrtthe system defines operations on signal flows, such as filter, map, merge and split
23:39grrrtat least in theory it does :)