#clojure log - Jul 14 2009

The Joy of Clojure
Main Clojure site
Google Group
List of all logged dates

0:47 yangsx: durka42: yes, that's my last-resort

3:10 Lau_of_DK: Good morning gents

4:55 svqyqb: http://tinyurl.com/nkypfa

4:56 jdz: ,'(x ^ 2)

4:56 clojurebot: (x (clojure.core/meta 2))

4:57 jdz: this looks quite wrong to me

4:57 kotarak: Why?

4:57 jdz: oh, nvm

4:58 kotarak: ^foo is syntactic sugar for (clojure.core/meta foo)

4:58 jdz: ye, i just checked the reader doc

8:05 mattrepl: anyone 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

8:06 in this specific case, I have a :once fixture... code here: http://github.com/mattrepl/clojure-cassandra/blob/c0b8acda065b312882a73755834c378f6aa0b2c4/src/cassandra/test.clj

8:34 * Chouser reads about fixtures for the first time

8:40 Chouser: mattrepl: you're binding 'f' in the inner doseq.

8:40 mattrepl: that shadows the 'f' arg, so you don't call what you want to call at (f)

8:42 mattrepl: Chouser: (f) is in outside the scope of that doseq though, no?

8:42 Chouser: oh

8:42 yes. hm.

8:43 mattrepl: the problem I'm seeing is that init-db isn't invoked at all, so when the tests are run there is no database available

8:50 Chouser: mattrepl: you see your fixture if you eval ^(the-ns 'cassandra.test) ?

8:52 mattrepl: yup

8:55 though appreciated, don't worry about spending too much time on that specific case - just wanted to see if anyone else had issues with fixtures =)

8:56 Chouser: I've never heard of them before

8:56 but it looks like if test-ns-hook is provided, the fixtures aren't called

9:00 mattrepl: ah, 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

9:02 Chouser: it ok if I submit a ticket?

9:04 Chouser: heh. good question.

9:04 that's not contrib anymore so I suppose we need rhickey approval for that?

9:05 mattrepl: it'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

9:06 Chouser: my opinion is that a ticket is warranted -- it could be closed either with a fix to the code or to the docs, I suppose.

9:07 * rhickey doesn't know what you are talking about

9:07 Chouser: rhickey: fixtures are a clojure.test feature

9:07 mattrepl: for clojure.test, fixtures aren't called if test-ns-hook is being used

9:07 * rhickey still doesn't :)

9:07 mattrepl: test-ns-hook allows one to specify which tests get called (and their order)

9:08 Chouser: yeah, I hadn't heard of fixtures before. but they're in clojure now! :-)

9:09 it's just a bit of combinatorial complexity. the test-ns-hook feature doesn't compose with the fixtures feature.

9:09 Chousuke: you suppose test-ns-hook could be replaced or augmented with a higher-level macro or something?

9:09 mattrepl: if 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

9:09 Chouser: test-ns-hook lets you control which tests in your ns get run and in which order

9:10 Chousuke: like (namespace-test-order [testfn1 testfn2 ...])

9:10 Chouser: but fixtures run something before and/or after each test

9:11 mattrepl: or before/after all tests

9:11 Chouser: right. the latter case would be easier to fix to work with test-ns-hook

9:12 Chousuke: while 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) ...)))

9:12 and set it as the hook

9:12 Chouser: mmmmm... complexity. :-)

9:12 Chousuke: not really.

9:12 Chouser: anyway, the question at hand is: does something need to be fixed.

9:12 "how?" can be answered later

9:13 and I think at the very least the lack of support for the two features together should be documented.

9:13 mattrepl: I agree with you that at least documentation should be amended

9:13 rhickey: seems like something to discuss on the group. Too difficult to make decisions here not involving all interested parties

9:13 Chousuke: I 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.

9:14 Chouser: mattrepl: there you go -- you have recieved permission to bring it up on the group. :-)

9:15 mattrepl: heh, alright. Will fire a note off shortly

9:15 thanks for taking a look

9:16 Chouser: sure. thanks for pointing out a part of clojure proper that I didn't know existed! :-}

9:24 AWizzArd: rhickey: do you still have enough time to work "full time" on Clojure?

9:41 rhickey: AWizzArd: not a matter of time, but of money

10:42 Has anyone tried the ensure branch?

10:43 maybe I'll just have to merge it with master :)

10:43 drewr: I haven't yet.

10:43 Chouser: I don't even have any code that uses ensure

10:44 rhickey: Chouser: hopefully that code will be unaffected, but all STM code runs through new logic

10:44 Chouser: ah. well, not even very many transactions...

10:45 * rhickey registered to present at JVM Language Summit - http://openjdk.java.net/projects/mlvm/jvmlangsummit/

10:59 * danlarkin wishes there were more hours in a day

11:11 rys: Not having to sleep would be pretty excellent

11:13 rsynnott: rys: as long as employers weren't let in on the secret, yes

11:16 rys: Heh

11:16 Being asked to work more hours on PHP projects would have to be close to the bottom of the programming ladder, yes

11:16 * rys cries a little

12:06 cemerick: wasn'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:15 lisppaste8: cemerick pasted "Stuff like this makes me think I'm just doing it wrong..." at http://paste.lisp.org/display/83579

12:20 rhickey: cemerick: I don't think there is a fn for that

12:22 cemerick: rhickey: watching myself jump through hoops makes me think that wanting that symbol is indicative of a more fundamental design flaw (on my part)

12:23 rhickey: could be

12:23 vars aren't necessarily interned

12:24 or there hasn't been much demand. Vars used to keep their syms ns-qualified

12:25 ggroups seems to have stopped updating membership counts

12:26 2212 vs 2028

12:30 cemerick: I 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:44 rgr: quit

12:57 AWizzArd: rhickey: and I was already wondering why nothing happens anymore

12:57 typically the user count went up a little every few days

12:59 cemerick: is user count really a concern in general?

12:59 rhickey: its still going up, they must not be running the map-reduce job that updates the front page stats

12:59 * cemerick reminds himself to watch out for Insular Lisper Disorder

13:53 Chouser: cemerick: seems like I've written a function like that before.

13:53 * Chouser wonders where and what for...

13:55 Chouser: Hm. 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

13:57 * Chouser considers copying (defn promise ...)

14:01 technomancy: so is it true that keywords can't have metadata?

14:02 Chouser: ,(instance? clojure.lang.IMeta :foo)

14:02 clojurebot: false

14:02 technomancy: =(

14:02 I guess I can use symbols for this

14:02 Chouser: there's only one keyword object for each keyword

14:03 so you wouldn't be able to have two :foo's with different metadata

14:03 technomancy: right, that makes sense

14:03 but that would be true for symbols too, right?

14:03 Chouser: nope, lots of symbols that look the same.

14:03 ,(identical? 'a 'a)

14:03 clojurebot: false

14:04 technomancy: wouldja look at that

14:09 Chouser: ,(binding [*print-meta* true] (prn '{:a #^a foo, :b #^b foo}))

14:09 clojurebot: {:a #^a foo, :b #^b foo}

14:10 Chouser: ,(binding [*print-meta* true] (prn '#{#^a foo, #^b foo}))

14:10 clojurebot: #{#^a foo}

14:18 Anniepoo: anybody 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:20 strange part is, I can compile and run

14:22 (fwiw, this is a bug in La Clojure)

15:07 Lau_of_DK: Where do I go to read about these upcoming modifications to the STM ?

15:08 Chouser: which ones?

15:09 hiredman: I've heard of exposure of some already existing nobs, but not modifications

15:09 Lau_of_DK: Chouser: Ensure branch, etc

15:09 Chouser: oh! 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:10 * technomancy likes the term knobs

15:11 Chouser: Lau_of_DK: http://groups.google.com/group/clojure/browse_thread/thread/f7b4365b1c71b665

15:11 hiredman: I 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:11 Lau_of_DK: Thanks

15:34 rzoom: after reading that thread about ensure, it is amazing that clojure does all of that "under-the-hood". wow.

15:34 * rzoom gives rhickey claps

15:39 rhickey: hiredman: 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:39 http://en.wikipedia.org/wiki/Snapshot_isolation

15:39 hiredman: I see

15:40 rhickey: the benefit is now multiple overlapping ensures all succeed

15:40 before they took turns

15:40 hiredman: ah

15:41 rhickey: vs dummy writes, which will (still) take turns

15:45 * Chouser concludes 15 minutes of debugging by replacing a careless dorun with a doall

15:46 Chouser: *sigh*

15:47 rhickey: I'm closer to adding map! or mapv all the time - would it help?

15:47 Chouser: yup

15:48 (map deref (doall (map make-promise-fn input-seq)))

15:49 if input-seq were longer, I suppose inserting a seque might make sense as well.

15:49 hm

15:49 actually...

15:49 * Chouser looks at pmap

15:49 rhickey: (mapv (comp deref make-promise-fn) input-seq))?

15:50 Chouser: well, I want the make-promise-fn calls to run on ahead

15:51 rhickey: I was ignoring that bit

15:51 Chouser: oh

15:51 well then, yes

15:51 :-)

15:51 rhickey: what about mapv as the 'imperative' map

15:51 would return a vector

15:52 non-lazy

15:52 Chouser: essentially like (vec (map func coll)), but implemented more efficiently?

15:52 rhickey: right

15:53 Chouser: works find for me. I find myself wanting (vec (for ...)) approximately as often

15:53 rhickey: and (vec (filter .. etc

15:53 Chouser: actually -- I dunno.

15:53 yeah

15:54 maybe better to have vec standing out there, telling everying you're going non-lazy here

15:54 in this case it was just a silly slip do you dorun instead of doall -- I use both infrequently and get them confused.

15:54 should have just used vec

15:55 rhickey: vec is the advice I give these days

15:55 Chouser: s/should have/could have/

15:55 Knekk: (vec forces evaluation?

15:55 rhickey: Knekk: has to

15:55 Chouser: only didn't becuase it seemed silly to go do a vec in the middle of (map ... (map ...))

15:56 Knekk: rhickey: It's not documented, for those of us who don't yet start thinking about how data is implemented in clojure

15:57 rhickey: Knekk: only lazy things are documented as such, everything else is not lazy

15:58 #!(map ...)

15:59 #!(for...) #!(filter ..)

15:59 Chouser: is that vec or doall ?

15:59 * rhickey ducks

15:59 rhickey: vec

15:59 Chouser: ok

16:00 rhickey: one problem is it no longer returns a seq

16:00 clojurebot: People have a problem and think "Hey! I'll use a regular expression!". Now they have two problems....

16:00 rhickey: clojurebot, the life of the party!

16:01 hiredman: ~rhickey

16:01 clojurebot: he works hard so you don't have to

16:02 * rhickey likes clojurebot, but often doesn't understand him

16:03 Lau_of_DK: hehe, fun

16:09 Chouser: huh, this works: (def #^Integer nums {:a 5})

16:10 as in, this then requires no runtime reflection: (.shortValue (nums :a))

16:13 hiredman: Huh

16:14 Chouser: of course if you use (get nums :a) you lose it

16:14 hiredman: weird

16:14 I don't understand that

16:14 technomancy: that's wild

16:15 hiredman: it seems like that should make type hinting the return values of functions possible

16:15 Chouser: it does

16:16 hiredman: (defn #^{:tag Integer} foo [a b] (+ a b))

16:16 Chouser: the :tag metadata on a var means either that var holds a value of that type *or* holds a function that returns that type

16:17 hiredman: no kidding

16:17 of this I was not aware

16:17 Chouser: your foo example works fine

16:18 hiredman: I, of course, was jsut playing with it in a repl

16:18 Chouser: or just (defn #^Integer foo [a b] (+ a b))

16:18 hiredman: I started looking at rewriting LispReader in clojure

16:19 Chouser: ah! what do you think?

16:19 hiredman: read() is very imperative

16:19 and many things are private or package scoped

16:20 ozzilee: Mind-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:21 Wait, I'm doing something terribly wrong.

16:23 Ok, 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:23 hiredman: I wanted to start by just implementin LispReader/read and still calling stuff in LispReader and slowing swap stuff out

16:25 replaca__: rhickey: are you hanging out in these parts?

16:25 Chouser: Anyway, 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:26 hiredman: ah. yeah, you might have to go whole-hog

16:26 hiredman: :(

16:26 anyway, I am going to continue to meditate on it

16:30 ozzilee: This is insane. Surely someone has gotten Compojure to serve resources out of a .war file?

16:31 Chouser: ozzilee: you want to call an inherited method of a gen-class class?

16:31 ozzilee: see :exposes-methods in (doc gen-class)

16:32 I didn't say that right. See that doc anyway. :-)

16:34 ozzilee: Chouser: 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:35 Chouser: you're in a gen-class namespace?

16:35 that is, where is the code that's trying to make the call?

16:35 ozzilee: Chouser: In a file :use'd into a gen-class namespace.

16:36 In the namespace I'd be able to do it. I think I need to get the instance through some other means though.

16:36 Chouser: who is calling your :use'd code?

16:38 ozzilee: Hrm. 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:40 I 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:40 Or make the initialization code callable through the webapp.

19:15 hamza`: 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:15 ataggart: the variable name wilol shadow the struct so you won't be able to call (struct line)

19:15 but other than that I don't htink so

19:16 Raynes: That's odd. Why would he ever need to?

19:17 hamza: sorry i got disconnected can you write what you said again..

19:18 Raynes: [18:14] <ataggart> the variable name wilol shadow the struct so you won't be able to call (struct line)

19:18 [18:14] <ataggart> but other than that I don't htink so

19:18 ataggart: typos and all :)

19:18 Raynes: ataggart: :p I only copy things, I don't fix them. :)

19:19 hamza: thank you.

19:21 hiredman: “which makes sense since 5 could be anything”

19:27 Raynes: "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:27 What is wrong with people? :|

19:28 Chousuke: :P

19:28 Raynes: They always seem to forget that Clojure is running on the JVM.

19:28 Chousuke: well, it is a real problem.

19:28 Raynes: Indeed, but still.

19:28 ataggart: there are no solutions, only trade-offs

21:20 cp2: ffsdafsdfds231233346123123332131234444

21:20 oops

22:02 cark: hello

23:21 grrrt: If I were to package a project and put it online somewhere, what's the best way to deal with dependencies?

23:21 I currently have clojure, clojure.contrib, jLine and a jar for Swank/Clojure support in my lib dir

23:22 but including them in the project might not be such a good idea

23:22 - this is for development only, a finished product would be self-contained

23:30 technomancy: grrrt: if your project doesn't have any non-development dependencies outside clojure or contrib, just offering it as a jar is reasonable

23:30 grrrt: is it an application, or a library?

23:31 grrrt: it wil be a library

23:31 it's about the packaging of the source code

23:31 in a repository somewhere

23:31 technomancy: in that case it would be most useful for others using it as a dependency to make it a maven project

23:31 since that's the only system that supports real dependencies

23:31 grrrt: yeah I know...

23:31 so clojure's in maven now

23:32 but what about clojure.contrib?

23:32 technomancy: it's not in the central repos, but there are 3rd-party repos that have it

23:32 grrrt: ah that's good to know. I'll search the google group for info

23:32 technomancy: actually... you might be able to use corkscrew for this

23:32 clojurebot: corkscrew is a proof-of-concept build system and dependency manager (http://github.com/technomancy/corkscrew)

23:33 grrrt: hmm

23:33 interesting!

23:33 technomancy: just put a project.clj file in your project root that mentions the contrib dependency, then run "corkscrew install"

23:33 then 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:33 grrrt: I'll look into that, thanks

23:34 technomancy: I 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:34 ddonnell: how do I build clojure-contrib?

23:34 technomancy: grrrt: I'm about to head off, but you should be able to catch me here later this week if you have questions.

23:34 grrrt: thanks!

23:35 I'll look at corkscrew

23:35 and try to get my library sources presentable :)

23:35 technomancy: well that's the hard part. =)

23:35 what's the library?

23:35 grrrt: hm

23:36 I had to think about that for a second :)

23:36 there are three parts: a system to create Swing widgets in a very simple declarative fashion

23:36 technomancy: actually 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:36 grrrt: a system to make Swing's listener and event system behave better / easier with clojure

23:37 and, the main dish: a dataflow approach to getting values and events from one place to another

23:37 technomancy: cool

23:37 grrrt: well I have to make it work first :)

23:37 still a proof of concept. but I might be onto something

23:37 technomancy: at least half of all clojure projects in existence are proofs of concepts.

23:37 grrrt: haha

23:37 true

23:38 the idea of my approach is that you create signals from some source (a swing widget, a ref, ...)

23:38 to some target

23:38 the system defines operations on signal flows, such as filter, map, merge and split

23:39 at least in theory it does :)

Logging service provided by n01se.net