#clojure logs

2008-08-07

03:32cemerickrhickey: a classpath-aware clojure.lang.Script patch is on the group now. I've actually come to be fond of the '@' notation, amazingly enough.
03:38rhickeycemerick: patch applied - thanks!
03:39cemerickrhickey: No, thank you :-) Q: what is the fate of the UTF-8 patch (or any other default encoding)?
03:52rhickeycemerick: going through it now - shouldn't loadResourceScript use UTF8 as well?
03:53rhickeycemerick: nevermind, got it
03:55cemerickrhickey: I was surprised by your message regarding preventing macros from being passed as arguments.
03:55rhickeycemerick: how so?
03:56rhickeypeople trying to apply or map macros is a common problem
03:56cemerickwell, short of the wrongness of applying them, being able to pass macros around and use them as if they were regular functions is really, really useful
03:56cemerickwell, then apply should check that
03:56rhickeythat's not behavior you should depend upon, the fact that macros are functions is an implementation detail, could change
03:57cemerickoh, but what a glorious implementation detail!
03:58cemerickthe alternative is to define foo-macro, and then a fn named foo that uses foo-macro, just so you can pass around foo. The current state of affairs is preferable, IMO.
03:59cemerickor, the current state of affairs, modulo some prevention of macro application
03:59rhickeycemerick: what's a real use case
04:03rhickeycemerick: UTF-8 is up
04:05cemerickrhickey: sorry, phone's going nuts already. Excellent.
04:06cemerickAn acquaintence of mine is working on a logic programming "environment" in clojure that uses macros to define certain predicate operations, and I know he passes those around like mad.
04:09cemerickanother use case are declarative "DSLs" where certain words are in function position as macros as well as used as arguments to other macros (so you can neatly reuse those definitions, etc)
04:10cemerickNot that you couldn't just use functions for these things -- just that being able to use macros, and treat them as functions (short of apply) makes for clearer, shorter implementations.
04:35rhickeycemerick: I would question whether that passing shouldn't be of the macro name rather than its value. Are they really calling the macros at runtime? Are the forms returned by the macros useful at runtime? Don't they want the evaluation of the expansion and not the expansion itself?
04:36cemerickIn the case of the logic programming, yes, they're definitely being called at runtime. And yes, one would (almost) always want the evaluation of the expansion, which you get for free by treating it as a function (again, short of using apply).
04:37cemerickpassing the macro name instead of the macro itself requires that the receiver either be a macro or know to eval the macro name.
04:37rhickeyno you don't get the evaluation of the expansion by treating the macro as a function, you just get the expansion
04:39rhickeyuser=> (def andf (.get #'and))
04:39rhickey#'user/andf
04:39rhickeyuser=> (andf 1 2)
04:39rhickey(clojure/let [and__179 1] (if and__179 (clojure/and 2) and__179))
04:48cemerickrhickey: Given that, I'm stunned how the code that I have that uses import-static works at all.
04:49cemerickor, confused more than stunned, perhaps
04:50cemerickthinking about what a macro is (fn that returns forms), I'm not sure how it could possibly work.
04:52rhickeycemerick: I don't think it can:
04:52rhickey(import-static java.lang.Math floor)
04:52rhickeyuser=> (map (.get #'floor) [1 2 3])
04:52rhickey((. java.lang.Math (floor 1)) (. java.lang.Math (floor 2)) (. java.lang.Math (floor 3)))
04:53cemerickwell, it's passing tests as we speak, so something very funky is going on
04:53cemerickobviously my problem, though
04:55rhickeythus the change - users that really do need this and are willing to risk the implementation-detail dependency can always use (.get macro-var) to get the macro fn
08:57drewrrhickey: You've been putting in some late nights.
09:19rhickeydrewr: seems like more early mornings
11:38ChouserI haven't been paying attention for the past few days -- any further interest in gen-interface, or is it a boondoggle?
11:39ChouserAnd what about the test-case wiki? any progress or conclusions?
11:46rhickeyChouser: off to my semantic web talk - I think gen-interface will work out, will try to look at it tomorrow, no further word on test wiki
11:47cemerickChouser: Hi there -- I ended up not using it, due to the javadoc requirement. Might come up again, tho.
11:48Chouserok, thanks guys.
13:11shooverI'm interested in contributing to test.clj. I'm not too concerned if there's a wiki or not, as long as I can work in my normal dev environment and send patches.
13:33Chousershoover: do you use a VCS currently? Subversion?
13:33shooveryep, Subversion and Mercurial
13:34shooverI do like the idea of a wiki, but someone like rhickey needs a file that's sitting there with his code so he can just run it.
13:34Chousermy current thought (which as usual is probably over-complicated) would be to provide a repo with one test per file, plus a pretty web front-end to view and even edit and run the tests.
13:35shooverIt doesn't seem like the Clojure way to have lots of little files, but the web front end idea is interesting. Have you looked at FitNesse?
13:35Chouserif we put all the tests into one file and try to use a VCS, will have constant conflicts as people try to append their tests.
13:36shooverTrue re: conflicts. It depends on how many people work on tests.
13:37Chouserindeed -- and when they work on them.
13:39albinoone test per file is way way better than one file for all tests
13:39Chouserhm, FitNesse clearly has a similar idea at work.
13:39albinoor at least a suite of testcases per file
13:40shooveralbino: Yes, suite per file is nice, once you have a body of tests and can see where to break it into suites.
13:40ChouserI was also thinking that tagging the tests might be useful, so you could search for, I dunno, "math" and get a bunch of guaranteed-to-work examples.
13:41albinoare you guys going to write your own unit-test lib or just use junit?
13:41albinos/lib/lib or runner
13:41ChouserI don't know enough about junit to know if it's a good fit or not.
13:42cemerickjunit is really painful to use in clojure, IMO
13:42cemerickcontrib's test-is is really fantastic
13:42albinoI'm sure one of you guys could whip up an equivalent basic functioning junit with clojure like feel pretty quick
13:44albinoI'm used to python's nose where tests are grouped into classes and each class has a setup() method and teardown() method with test_*() methods in between
13:44shooverI've been meaning to check out the existing Clojure test options. I just saw this one in the wiki: http://gnufoo.org/clojure/unit-test/README.html
13:44cemerickalbino: I think test-is is what you'd be looking for in that case, although junit's model (search for and run static impl's of TestCase and TestSuite) doesn't really map up with clojure
14:54shoovertest-is looks nice. I like how it integrates with the rest of Clojure. If any var in any ns has a :test metadata, it gets tested by test-is/run-all-tests.
14:54shooverAnd tests defined with test-is/deftest work out of the box with clojure/test
14:55shooverPerhaps some of the output ideas from unit-test (linked above) could be ported to test-is.