#clojure log - Oct 02 2008

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

1:24 scottj_: How come clojure doesn't figure out automatically what can be run in parallel and do that?

1:34 Chouser: is that easy to do?

1:36 scottj_: I think I've heard Haskell does it.

1:38 But yeah, I was wondering if there was a reason other than "it's hard and we haven't gotten to it" that clojure doesn't have it.

1:38 walters: i think haskell's static typing makes that much easier for them

1:39 clojure is dynamically typed with the advantages and disadvantages that typically entails

1:40 i.e. you can run your app without going through cycles of staring at obscure type inference clash errors from the compiler, but you lose some smarts and checking that could be done at compile time

3:00 Lau_of_DK: Morning gents - Quick JAVA question: Where can I find an example of the mainloop in a swing application, so as to enable my clojure program to run from clojure.lang.Script ?

3:16 hoeck: Lau_of_DK: for all i know, there is no user-defined main loop in a swing application, the components just fire events which call the associated Listeners

3:17 Lau_of_DK: so just setting up the Listeners and open a main swing window should do it

3:19 Lau_of_DK: but im not a swing guru, just played with swing and clojure a while ago

4:08 Lau_of_DK: hoeck, im pretty sure that there's something simliar to c's main.c which needs to start some kind of loop, I vaguely remember RHickey pointing to an example and saying that I should mimic that behavior

4:08 Of course, I lost the link

4:14 Looking over Suns site, you might be right though

4:17 hoeck: mhh, maybe you have to check (in a loop) wether your main swing window is still open so that the script does not quit before

4:18 achim_p: Lau_of_DK: take a look at ants.clj: http://groups.google.com/group/clojure/files. no main loop. that's one of the differences between swing and swt.

4:22 Lau_of_DK: but achim_p, ants.clj wont run strictly from the command line either, you need to maintain a repl

4:27 achim_p: Lau_of_DK: i just tried with a clj file with this single line: "(doto (new javax.swing.JFrame) (show))". it didn't terminate when run as a script. does that work for you?

4:30 Lau_of_DK: gimme a few secs,colleague knocking on the door

4:46 achim_p , yes that works, thanks :)

4:55 Do you guys remember how to add the exit-listner so that the script terminates when the windows is closed? As I recall there was a one-liner posted somewhere

5:11 achim_p: Lau_of_DK: i think you'll have to extend a WindowAdapter for this and add it to the JFrame. there might be a shorter way ...

5:19 Lau_of_DK: achim_p, I worked out, that if you do this do your main JFrame, then it will exit when it closes

5:19 (doto frame (setDefaultCloseOperation (. JFrame EXIT_ON_CLOSE)))

5:19 (doto frame (setDefaultCloseOperation (. JFrame EXIT_ON_CLOSE)))

5:19 (sorry, my paste putty/bitchx thing messed up on my screen, but I suppose you can read the bottom Line?

5:33 achim_p: yes, thanks! that's better.

8:42 drewr: I love seeing all the chatter on twitter about clojure.

8:42 abrooks: ;-)

8:42 drewr: It's grown a lot in the past few weeks.

8:42 abrooks: It has.

8:42 drewr: "While I appreciate most of the ways clojure deviates from CL some things are just plain wrong. I mean, nil *is* (). Come on, people!" --appelberg

8:43 abrooks: Bzzt.

8:43 rhickey: why is nil () and not [] or {} ?

8:44 abrooks: rhickey: I was just about to note how you put that argument to rest in the recent talk.

8:44 * drewr is only a few minutes into it

8:45 rhickey: It made sense when there were only lists... but now, not so much. or you''d also have to have null

8:45 abrooks: When you're in a universe that has a single instance of something it's very hard to see the distinct attributes of that thing. An emtpy list may reasonably look like nothing when it's the only empty sort of thing that you have.

8:45 Heh. Crosspost.

8:46 rhickey: heh

8:47 jdz: rhickey: you're my hero of the day!

8:47 * abrooks spends his morning doing something very un-Clojure -- tracking down pointer misalignments in OCaml on n32 MIPS.

8:47 jdz: (i smell some Java stuff will have to be done in near future, and this is a perfect time to start learning Clojure)

8:48 rhickey: jdz: great!

8:48 drewr: abrooks: How can OCaml have pointer misalignments??

8:48 jdz: i'm just looking through the website and wonder if there is a way to create .jar files from clojure sources...

8:49 rhickey: can Clojure dump it's generated bytecode?

8:50 abrooks: drewr: Heh. The compiler does...

8:50 drewr: In theory this runs on IRIX6 but their avoidance of GNU autoconf is my pain.

8:51 drewr: ...and their joy. :-)

8:51 jdz: rhickey: not that it is very important. but you know, i'm new to Clojure, and all newbies that come to #lisp ask about making executables :)

8:51 rhickey: jdz: not at present. You can jar up src with the normal Java jar tools

8:52 jdz: rhickey: ok, thanks. i won't take any more of your precious hacking time.

8:52 rhickey: I think it's a viable question, there was a thread and some code for it here: http://groups.google.com/group/clojure/browse_frm/thread/3c2010cde7d87a6d

8:54 abrooks: drewr: I'm not about to defend GNU autoconf on any grounds of cleanliness. It's a horrific catastrophy of POSIX shell and M4. It's just that encapsulates so much knowledge about portability and cross-compiling that individual engineers simply don't have. It's necessary. GNu autoconf is the worst build configuration system ever... except for all the others.

8:54 drewr: So rhickey, did you pass the Xach test at the talk?

8:55 rhickey: drewr: I think so: http://xach.livejournal.com/191581.html

8:55 drewr: abrooks: Yeah, that's what I thought. I've mostly stayed on the user end of autotools.

8:57 jdz: rhickey: btw, one thing i missed from the videos (maybe it's just me): what is the result of (first empty-sequence)? (in the 'rest' case it's nil)

8:57 drewr: rhickey: Ah, that post just came up in my feed reader. If you impressed that group then Clojure has a bright future!

8:58 abrooks: jdz: (first empty-sequence) -> nil

8:58 jdz: The reason is there is no empty sequence.

8:58 jdz: abrooks: yeah, that's quite natural. it's just that it was not mentioned in the presentation. and i'm not sure it should...

8:59 abrooks: jdz: (seq []) -> nil

8:59 jdz: abrooks: no, there is an empty sequenc. that's the whole point!

9:00 abrooks: it's just that there is nothing in the sequence, so you can't take neither the first nor the rest of it. but it still is a sequence.

9:00 abrooks: You never have an empty sequence. You may have an empty list/vector/set/hash but if you get it's sequence you have nothing.

9:00 jdz: (well you can take first and rest of it, and you get nil)

9:01 abrooks: oh, right. right.

9:02 rhickey: in Clojure, nil means "nothing", but first and rest are defined on nil to return nothing/nil too

9:02 abrooks: Er... s/it's/its/ ----^ (It's too early in the morning...)

9:03 * abrooks sips tea and returns to unmangling C

9:11 andrewdotnich: g'day everyone

9:12 rhickey: andrewdotnich: hi

9:12 andrewdotnich: rhickey, watched your "Clojure for Lisp programmers" talk this afternoon

9:12 going to start playing around with it in my spare time, looks quite impressive

9:13 rhickey: great!

9:14 andrewdotnich: I'm a 3rd-year university student in Melbourne, Australia - we haven't had much FP teaching as part of our course

9:14 although we did go through Lambda Calculus for a languages subject

9:20 abrooks: andrewdotnich: If you've not come across http://projecteuler.net , it's a great way to learn a new language (particularly functional ones). Plus it's loads of fun.

9:20 ER. I meant to have "I highly recommend it" in there some where. ---^

9:25 andrewdotnich: yeah, I've done a few Euler problems

9:26 abrooks: andrewdotnich: In Clojure or another language?

9:26 andrewdotnich: Python, mainly

9:26 another language I've had to teach myself

9:27 my university being quite traditional in its language selection (Pascal, then C# / Java, with some C++ thrown in)

9:31 rhickey: in your talk you mention that you use emacs to write in Clojure - are you aware of any work to create a Clojure bundle for TextMate (my editor of choice)?

9:32 rhickey: H4ns: nice blog post. http://netzhansa.blogspot.com/2008/10/trying-clojure.html Did you try debugging with JSwat or enclojure?

9:32 H4ns: rhickey: no, i've tried sticking to slime. i guess i should try to be more open :)

9:33 rhickey: for the next project, i'll look into one of those, thanks!

9:33 rhickey: ah, there's not the same infrastructure to support Slime debugging, but Clojure follows all the rules for Java debugging and profiling. Should be able to debug with break points, line-stepping, locals etc

9:35 H4ns: rhickey: i'll look at that and post praise to my blog, promised :)

9:35 rhickey: H4ns: ok :)

9:36 also, I've been working on error messages and will look at anything specific

9:38 H4ns: rhickey: for today, i need to return to good old common lisp, but i will come up with specific reports - should i post to the group?

9:38 rhickey: H4ns: yes please

9:38 H4ns: ok.

10:07 Chouser: earthvssoup: the new code looks beautiful

10:07 earthvssoup: Chouser: thanks to you

10:07 Chouser: I'm starting to get the feeling people want more or different documentation. ;-)

10:08 earthvssoup: For me... a little bit from column B and a lot from column A ;)

10:08 rhickey: I'd love to see a Clojure examples project get going somehow

10:08 earthvssoup: I am totally a n00b here, but I would be happy to help however I can

10:09 H4ns: planet.clojure.org and aggregate manually maybe?

10:10 Chouser: At this point there's a whole lot of example code floating around "out there" -- is google any good at collecting that?

10:10 alec: no

10:10 earthvssoup: not really

10:11 Chouser: to be more useful, I think an examples project might have to work hard at being well organized -- start simple, build up a topic at a time.

10:11 earthvssoup: agreed

10:11 rhickey: we've imagined a structure with a page per function, with doc/example/test/tips

10:12 earthvssoup: For me, good examples are key

10:14 jdz: i miss interactive documentation. like (describe defstruct)

10:14 Chouser: doc

10:14 jdz: Chouser: oh thank you.

10:15 earthvssoup: Many examples projects fall into the trap of, "this is the bad way to do it... now look at the right way to do it"

10:15 Chouser: Also: (find-doc "struct")

10:15 blackdog: i think the best examples are in boot.clj, keeping it open at all times for reference is well worth it

10:15 Chouser: earthvssoup: I'm not quite sure what you mean.

10:16 blackdog: that's certainly what I used, but you do have to be a bit careful -- at the top of boot.clj there's not enough clojure defined yet to do things the Right Way

10:17 earthvssoup: Well, for example On Lisp PG (at times) creates functions such as (bad-reverse) and then (good-reverse). I suppose that there is some value in that there are discussion points made about why (bad-reverse) is bad, but for me it is distracting

10:18 Chouser: ah, I see. That might make more sense if you've got a coherent narrative (such as in a book) -- for reference docs I would agree bad examples aren't very useful.

10:18 H4ns: earthvssoup: i think good examples must tell you not only why they are as they are, but also why other ways are not as good.

10:19 earthvssoup: BTW, I agree that boot.clj is great. Perhaps an annotated version explaining how it builds on itself would be useful?

10:19 H4ns: agreed

10:19 H4ns: earthvssoup: i think good example code should be good enough that could copy and paste it, but one never should actually do it :)

10:21 earthvssoup: Of course my On Lisp -> Clojure project takes the (bad/good-reverse) approach, but that is only a product of my ignorance

10:22 Chouser: btw, the "else" part of "if" is optional. If you leave it out, it's as if you specified nil.

10:23 H4ns: Chouser: in common lisp, we prefer when over if without an else clause. same in clojure?

10:23 Chouser: H4ns: yes

10:24 H4ns: yes

10:24 H4ns: Chouser: ok

10:25 drewr: rhickey's explanation of cons/seq is awesome.

10:28 Chouser: Having just spent 10 minutes looking at the problem, I think I'm the wrong person to set up a examples wiki. :-/

10:28 drewr: What's the behind-the-scenes difference of:

10:28 wm> (first {:foo 1 :bar 2})

10:28 [:bar 2]

10:28 wm> (first (seq {:foo 1 :bar 2}))

10:28 [:bar 2]

10:28 lisppaste8: rhickey pasted "make-adderb" at http://paste.lisp.org/display/67788

10:28 Chouser: drewr: first calls seq on its arg for you

10:28 drewr: Ahh.

10:29 rhickey: earthvssoup: that's the most straightforward make-adderb

10:31 Chouser: H4ns: that PDF is beautiful.

10:31 earthvssoup: rhickey: awesome. My v2 version wrapped the entire if in the dosync. I guess that was overkill. Also, I should have picked up on the @ deref Thanks

10:32 jdz: which pdf?

10:32 H4ns: Chouser: yep - it will propably be very helpful for when to just read it back to back.

10:33 http://clojure.googlegroups.com/web/manual.pdf?gda=HTUM7jwAAABoLitVpBTEcNIQc_NHg39S6DeYQuwQGx9N3mteasxC_bb1z1jhUxpJojBve3FvCyr9Wm-ajmzVoAFUlE7c_fAt&gsc=IJhlFgsAAAB2uMKWD8zLj_ZrTVfKpqX8

10:33 dunno about the gibberish in the end, sorry.

10:33 alec: rhickey: thanks again for speaking on Monday. Clojure has been the topic of more than a few conversations at ITA (the big area Common Lisp employer) in the past few days

10:33 H4ns: alec: the food sponsor, too!

10:34 rhickey: alec: you're welcome. what are the conversations like?

10:34 blackdog: thanks for that pdf, v. useful

10:35 rhickey: it was my pleasure to speak to an audience so deeply engaged in the concepts

10:37 alec: some cool Common Lisp code has come out of it, especially from discussion of the assertion "Common Lisp's standard library is very much tied to cons cells"

10:37 we also dream about how easy it would be to parallelize our applications - that's a big selling point

10:38 the "I don't care about consing 20GB/s" remark was also funny, since one of our applications cares especially about performance and we see better performance with less consing

10:39 overall good reception

10:39 * H4ns never believed in the "consless programming is teh new cool" chants

10:40 rhickey: alec: there certainly are times when I do care, but was more impressed by the Azul GC not breaking a sweat at those rates

10:40 blackdog: rhickey: what is ephemeral garbage? is that the first generation of garbage?

10:41 H4ns: rhickey: i suppose that they do have certain advantages due to the fact that they can change the hardware to suit their garbage collector, is that true?

10:41 jdz: blackdog: it's just recently generated garbage since last GC.

10:41 rhickey: blackdog: something you allocate and stop referencing almost immediately

10:41 blackdog: ok, thanks

10:43 rhickey: H4ns: I presume, but everyone is working on reducing GC costs, parallel GC etc. Bottom line is ephemeral garbage is relatively cheap, and eventually, with escape analysis, might often not even exist

10:44 jdz: in what ballpark those Azul systems cost?

10:44 rhickey: The Clojure seq abstraction couldn't exist without ephemeral garbage

10:45 jdz: if you need to ask, you can't afford it :)

10:45 jdz: fair enough

10:46 i know i don't want one under my desk :)

10:46 (i don't have a desk that big)

10:46 rhickey: I do, they are very small (something like 200 cores in 5U)

10:47 jdz: sounds pretty awesome

10:47 * H4ns detects some faint resemblence of a symbolics carrion smell wading through the channel

10:47 rhickey: :)

11:14 * abrooks works with three ex-Symbolics employees

11:15 jdz: or is it Symbolics ex-employees?

11:16 abrooks: It's hard to see but that's a non-breaking space. ;-)

11:16 jdz: nice one!

11:32 achim_p_: hi! re: examples blog/wiki - when i started with lisp/clojure, i did some project euler problems, which i put up here then: http://clojure-euler.wikispaces.com. quickly got fed up with number theory, though, and stopped. if anyone would like to contribute/discuss solutions, please do! access to the wiki should be completely open.

12:55 scottj_: how do you guys think enclojure would do at the benchmark game? about like groovy/jruby?

12:57 I mean clojure. I was just installing enclojure :)

12:57 abrooks: Ruby is slow in its native install. I wouldn't expect JRuby to win any speed competitions but perhaps I'm wrong.

12:58 rhickey_: scottj_: should be able to get close to Java, perhaps not with the most idiomatic Clojure, but that's the game

12:58 abrooks: I know nothing of groovy's performance.

12:59 I'd sort of expect Groovy to be significantly better than JRuby as Groovy is explicitly a language designed around the JVM.

13:00 rhickey_: abrooks: there's a tremendous amount of dynamism in both Groovy and JRuby getting in the way of perf

13:00 abrooks: rhickey_: I suspected as much of Groovy (I know that JRuby is hampered).

13:00 walters: though groovy does have the nice aspect that you can just replace "var" with "int"

13:01 abrooks: Does Groovy use unboxed numbers?

13:01 walters: i think currently when you declare types it doesn't do anything useful

13:02 scottj_: So maybe performance closer to Scala? http://shootout.alioth.debian.org/gp4/benchmark.php?test=all&lang=all is a summary including groovy and jruby

13:04 abrooks: This is one of the more fatuous language articles I've read recently: http://java.dzone.com/news/groovy-will-replace-java-langu

13:04 Did you know that "Groovy is the only language together with Scala and of course Java that always compiles to true Java byte-code."

13:05 rhickey_: scottj_: statically typed langs should have best perf, but Clojure should be closer to Java than to Groovy, certainly

13:10 scottj_: abrooks: does Clojure use unboxed numbers?

13:13 abrooks: Not directly though within a function unboxed numbers can be used without reboxing them on recur calls if the proper type hinting is provided. I think I'm getting this right. rhickey_?

13:13 ^directly^directly,

13:15 rhickey_: abrooks: yes, it supports unboxed numbers (and arithmetic) locally, and in non-reflective calls to/from Java, given any needed hints

13:16 ditto arrays of primitives - see type hints and primitives sections here: http://clojure.org/java_interop

13:19 danlarkin: just read http://netzhansa.blogspot.com/2008/10/trying-clojure.html

13:20 H4ns: danlarkin: let me know if i wrote something silly

13:21 danlarkin: no no, I like it

13:21 * H4ns is trying to install enclojure, fails. it complains about a network problem while accessing the nbm file, which is stored locally. ?

13:21 scottj_: H4ns: I think those nbm files have dependencies that it will download from netbeans

13:22 H4ns: scottj_: the error message refers to the local file and complains about the network settings, so it does not seem to know the real url or something.

13:23 "Networking problem in file:/C:/Users/hans..."

13:24 * H4ns makes screenshot, posts to list

13:33 lisppaste8: danlarkin pasted "def def" at http://paste.lisp.org/display/67800

13:34 danlarkin: I'm confused about what happens in that snippet I pasted

13:35 Chouser: don't def def

13:36 ;-)

13:36 rhickey: danlarkin: right now there aren't prohibitions on redefinitions of special ops

13:36 but invocation always resolves def to special op, so you haven't truly shadowed it

13:39 danlarkin: so special symbols get short-circuted in the evaluator?

13:39 would that be fair to say?

13:39 rhickey_: right, there aren't necessarily vars for them

13:41 danlarkin: right, since in a clean environment (resolve 'def) returns nil

13:41 rhickey_: I should lock them down...

13:42 H4ns: wow, slime with a working repl _is_ amazing! :)

13:43 btw, does the repl have something like *, **, ***?

13:44 * rhickey_ still hasn't tried slime, still using clojure-mode

13:44 Chouser: H4ns: *1 *2 *3 ?

13:45 H4ns: Chouser: java.lang.IllegalStateException: Var *1 is unbound. (NO_SOURCE_FILE:0)

13:45 maybe the slime repl is not a repl thread in that sense.

13:46 rhickey_: you should (i admit, this is kind of a selfish remark) :)

13:46 "i wanted to enter the 21th century, but enclosure did not even want to install"

13:46 Chouser: H4ns: could be. I don't use emacs, so I can't say.

13:48 drewr: abrooks: I think JRuby has actually surpassed CRuby in speed, but I don't keep up with that stuff.

13:49 aking: H4ns: are you using clojure from svn or the release version? *1/*2/*3 was added two days after the release

13:49 achim_p: the star vars don't work in slime

13:50 another downside is the lack of input line numbering

13:50 H4ns: aking: svn

13:50 walters: drewr: it has yeah...but ruby 1.8 is a *really* bad VM

13:51 drewr: walters: :-)

13:51 H4ns: achim_p: input line numbering i don't miss so much. what do you use that for?

13:56 fyuryu: lazy-cat

13:56 abrooks: drewr: JRuby/CRuby -- interesting.

13:56 fyuryu: ups

13:56 wrong buffer

13:57 walters: drewr: also my impression is the jruby hackers are particularly good

13:57 H4ns: given a command-line repl, how do i load foo.clj into the running clojure? the getting started page does not tell.

13:58 Chouser: (doc load)

14:00 H4ns: java.lang.ClassCastException: java.lang.String cannot be cast to java.io.Reader when i type (load "foo.clj"), which is an empty file?

14:00 Chouser: rhickey: is there some reason you used fns-in-metadata instead of multimethods for clojure.zip?

14:01 abrooks: H4ns: You probably want (load-file )

14:01 (load-file "foo.clj")

14:01 H4ns: abrooks: ah! damnit.

14:01 thanks!

14:02 Chouser: huh. for me, (load "foo.clj") says Could not locate Clojure resource on classpath: user/foo.clj

14:02 abrooks: Chouser: load works in the classpath.

14:02 Chouser: if it finds foo.clj, but it's empty, I get nil

14:02 abrooks: yes

14:03 abrooks: Oh, you're having a different problem.

14:03 Chouser: I'm not having a problem, I'm just failing to understand H4ns'

14:05 H4ns: i don't understand my problem either, but load-file works a little better.

14:05 rhickey: Chouser: those fns are supplied by users of the lib, it's composition. I guess the could have supplied a tag of some sort and then 3 multimethods, but much more verbose

14:06 Chouser: rhickey: ok, thanks.

14:09 achim_p: H4ns: never mind my comment about line numbers, i just checked, the standard repl doesn't seem to do it either. i could have sworn ... maybe i confused sth.

14:10 Chouser: ^(def x) includes a :line number for me

14:12 achim_p: Chouser: ah, that's the difference i meant. in slime it's always 1

14:13 i checked the error message on (/ 0 0), which states "NO_SOURCE_FILE:0" in both environments.

14:18 abrooks: user=> (/ 0 0)

14:18 java.lang.ArithmeticException: Divide by zero (NO_SOURCE_FILE:0)

14:18 user=> (def x (/ 0 0))

14:18 java.lang.ArithmeticException: Divide by zero (NO_SOURCE_FILE:62)

14:19 There's the difference. I think you must have something (such as a symbol) to associate the metadata with.

14:19 rhickey: Is there something useful about repl line #s?

14:21 abrooks: rhickey: I think so, particularly if you have the REPL joined to an editor or an IDE.

14:22 rhickey: I mean for source entered into the repl

14:23 like above, line 62

14:24 abrooks: rhickey: Yes. If you have scroll back or prompt numbering or something managing the lines input to the REPL, I think that's useful.

14:31 rhickey: I would eventually like to have enough to print the offending snippet with an indication of what's wrong. Being able to externally retrieve that snippet seems like a first step (of several possible).

14:33 rhickey: abrooks: understood, here with emacs + clojure-mode in inferior lisp I don't see any way to use those numbers

14:35 abrooks: At this point, I think it just runs against the users expectations when one sometimes gets an exception with a real line number sometimes and zero other times.

14:37 rhickey: Line numbers in a file mean one thing, in a repl..., but in any case, what you are seeing is that (/ 00) w/o the def is wrapped in a fn before eval, that fn having no line. I can change that to adopt the line of the wrapped expression - on todo list

14:43 abrooks: rhickey: I have the CA printed out and just need to fill it out and mail it. Perhaps I can express my wishes more helpfully/productively in diffs. ;-)

14:43 IOW, don't bother yourself. ;-)

14:44 I've been looking at datalog implementations. Which implementation were you thinking of using?

14:45 rhickey: abrooks: IRIS Reasoner: http://iris-reasoner.org/

14:46 abrooks: Every once in a while I find myself really missing CLIPS and then I know how sad things are...

14:51 IRIS looks very complete and well constructed.

14:52 rhickey: yes, nice set of interfaces for extension

14:56 earthvssoup: My first job out of college was CLIPS

14:56 I look back on it fondly (although doesn't everyone with their first?)

14:58 Chouser: rhickey: is LGPL a problem with IRIS?

15:00 rhickey: Chouser: it means if we provide fixes to IRIS, they must be LGPL, but we should be able to consume IRIS by linking to it without tainting. It may be an issue for consumers of Clojure who want no LGPL

15:00 Chouser: ok, doesn't sound too bad.

15:03 rhickey: The idea would be to provide a datalog library for Clojure that encapsulated the use of IRIS, in case someone ambitious later wanted to implement datalog directly in Clojure - I've had a lot of difficulty finding all of the details needed to do the latter with Query/SubQuery/Recursive + negation, otherwise I would have tackled it

15:03 abrooks: rhickey: Are you thinking of pulling IRIS sources into Clojure and tracking upstream or are you thinking that we'd have a Clojure glue library that links with a user provided IRIS jar?

15:04 rhickey: abrooks: the latter

15:06 IRIS is doing magic sets and stratified negation already, so if it is fast enough, why reinvent the wheel?

15:07 abrooks: rhickey: I think there's some value to the Pythonic "Batteries Included" model. If you know that standard distributions will have X it becomes much more useful.

15:08 rhickey: abrooks: we can battery-include the jar

15:08 abrooks: Ah, okay. My latter case was a user provided jar.

15:08 rhickey: right, you only gave me 2 choices :)

15:09 I don't want to track the source

15:09 abrooks: ;-)

15:09 rhickey: That's wise, particularly with Subversion which goes out of its way to be sucky at tracking third-party changesets.

15:10 * walters notes you can use an OS which includes a system for finding and installing free software =)

15:11 abrooks: Ullman has a presentation "Semantics of Datalog With Negation" among other things: http://www.google.com/search?q=site%3Ainfolab.stanford.edu%2F~ullman%2F+datalog

15:11 walters: though the fact that there's no standard mechanism for system jar installation sucks badly

15:13 rhickey: abrooks: I'm not at home with my materials, but I've read that, 2 other Ullman books, a book that specializes on Datalog and a bunch of other papers so far. I can post to the group with those details to start a discussion on this to see if there's sufficient interest/expertise

15:15 what I've found so far is, lots of talk about the semantics, very little discussion of implementation, and when there is, it is always for simple datalog - no negation/built-ins or functions

15:16 sometimes it seems as easy as - if you can stratify first, it goes back to the simple case, but everyone talks about implementation before they talk about negation

15:16 abrooks: Simple datalog is certainly the place to start, IMO.

15:16 * rhickey wants negation

15:17 abrooks: Can't it be incorporated without negation at first?

15:17 rhickey: but yes, should start simply

15:17 abrooks: Right.

15:18 rhickey: Where I'm at is the "buy" vs build point - IRIS is sitting there, with nice interfaces

15:18 OTOH, I have my own ideas about purely functional dbs, with indexes

15:18 abrooks: rhickey: Don't we all. ;-)

15:20 I think IRIS looks like a very reasonable starting place. Nobody's forced to use it. There's no reason why another reasoning system couldn't be added (or replace it) at some point in the future.

15:21 rhickey: What I imagine is this: create maps in memory or pull them from a db, pour them into a Clojure 'db', where they get tripletized. Tell the db which attributes to index. Then, attach a rule set to it and run queries. Both the rule set and db support non-destructive functional enhancement

15:21 abrooks: Chouser: Is noiski nearly done? We could just go with that? ;-D

15:22 Chouser: abrooks: noiski will use this feature, not the other way around.

15:22 abrooks: rhickey: That would be grand.

15:23 Chouser: Silly - noiski has had this feature forever -- it's just missing from the current implementation.

15:31 rhickey: I'm assuming that we wouldn't use the IRIS parser (primarily/at all?) in favor of using a native Clojure interface.

15:33 rhickey: abrooks: right - native Clojure

15:33 Chouser: woohoo! prn works, which proves multimethods at least kinda work, which proves isa? kinda works, which proves the type system is close enough.

15:34 rhickey: go Chouser !

15:34 abrooks: Chouser: Congrats!

15:34 Chouser: I gotta get this to a useful state soon -- I'm afraid I'm approaching burn out.

15:34 I don't even remember why I wanted it anymore.

15:35 abrooks: Heh.

16:12 danlarkin: can I flip ([1 2 3] 0) around like I can with a map?

16:13 Chouser: keywords look themselves up in a collection, numbers don't.

16:17 danlarkin: why not?

16:17 lisppaste8: H4ns pasted "Backtrace for the swank-clojure maintainer" at http://paste.lisp.org/display/67814

16:18 abrooks: danlarkin: Keywords are functions of maps and maps are functions of keywords (both in the logical sense and in the Ifn interface sense).

16:18 Chouser: danlarkin: I can't answer that kind of "why" with authority, but I suppose it has something to do with Clojure numbers being Java numbers, and Java numbers not implementing IFn, Callable, or Runnable.

16:20 danlarkin: it seems like it would be nice to have the same syntax rules for a map no matter what one's keys are

16:20 although if it's not possible, it's not possible

16:21 Chouser: well it couldn't work for everything, since a fn is a perfectly valid map key, but if it's named in functional position you'd want to pass the map to the fn, not the other way around.

16:23 abrooks: danlarkin: You'll never have that symmetry as you can have a key be an IFn but putting an IFn in the callable position of the list will result in it being called, not being looked up in a subsequent map.

16:23 * Chouser blinks

16:23 abrooks: i.e. (def x #(println "foo"))

16:24 user=> (x {:foo :bar})

16:24 java.lang.IllegalArgumentException: Wrong number of args passed to: x (NO_SOURCE_FILE:0)

16:24 danlarkin: would it be unreasonable to suggest that the (:a {:a 0}) syntax be deprecated? in favor of uniformity? or is using a non-keyword hash key such an edge case as to make it not a huge issue

16:24 abrooks: user=> ({:foo :bar} x)

16:24 nil

16:24 user=> ({x :bar} x)

16:24 :bar

16:24 danlarkin: I think because of the special nature and usage patterns around keywords, that reversed structure is very reasonable.

16:25 A keyword never has a value or other functionallity other than referring to itself. Looking itself up is a pretty close concept.

16:27 * abrooks is totally not sure why he reached for (def x #(println "foo")) instead of (defn [] x (println "foo"))

16:47 danlarkin: is there a function to return the arity of another function? I looked but could not find anything appropriate

16:48 smoofra: can someone help to enlighten me please: what's the diffirence between alter and commute?

16:50 danlarkin: not only does commute set the in-transaction-value of ref, it also sets the current value

16:50 * danlarkin doesn't know what he's saying

16:51 ozzilee: smoofra: Commute means the order doesn't matter, so Clojure is free to apply commute calls in whatever order it pleases.

16:58 smoofra: ah

16:58 abrooks: Okay, I'm baffled. I would think that I could get the function's metadata:

16:58 user=> ^(defn x [a b c] (println "foo"))

16:58 {:line 11, :arglists ([a b c]), :name x, :file "NO_SOURCE_FILE", :ns #<Namespace: user>}

16:58 user=> (defn x [a b c] (println "foo"))

16:58 #'user/x

16:58 user=> ^x

16:58 nil

16:59 wwmorgan: function can't have metadata. Try ^#'x

17:00 abrooks: Arg. Of course. I tried ^'x but forgot the sharp.

17:01 danlarkin: is #'foo shorthand for (resolve 'foo)?

17:02 smoofra: so is there any way to get mutable datastructures in clojure without going to refs or java?

17:02 wwmorgan: http://clojure.org/reader #'foo is short for (var foo)

17:03 H4ns: smoofra: what are you trying to achive?

17:04 abrooks: danlarkin: (map count ((meta (var x)) :arglists)) or (map count (^#'x :arglists)), depending on your taste, will give you a list of the arities of the function.

17:05 smoofra: H4ns: something like a haskell stref i suppose. a nice little ref you can read and write from without doing a transaction.

17:05 danlarkin: abrooks: thanks! didn't think of looking at the metadata, d'oh

17:06 H4ns: smoofra: why can't you use a ref and transaction for that? performance issue?

17:07 abrooks: danlarkin: np

17:10 smoofra: H4ns: im not trying to do something at the moment. just trying to understand. it just seems pretty incomplete to leave nakid refs entirely out of the language. and yea, performance is always a concern. i presume that the performance hit for using stm refs is not entirely negligable.

17:11 er. naked even.

17:12 H4ns: smoofra: i'd say: don't worry. if you want to mutate, use other languages :)

17:13 Chouser: smoofra: you could use a var with binding and set!

17:14 smoofra: I believe the overhead of a transaction when there is no contention is pretty small.

17:14 smoofra: H4ns: that's a bit silly. what with haskell having ST and all.

17:15 H4ns: smoofra: you need to talk to rhickey and have him convince you that you just don't want that.

17:15 Chouser: smoofra: but otherwise, if you're really sure you want to do unsafe mutation, using a Java array or some such isn't terribly hard.

17:15 or right, what H4ns said. :-)

17:15 rhickey: just hopping on - don't want what?

17:15 H4ns: rhickey: mutate data.

17:16 rhickey: you have refs, vars, agents and java.util.concurrent.atomic for mutating data

17:17 ozzilee: rhickey: AFn.java line 169 has "Object... args)" at the end of the method signature. gcj doesn't like it, what is it?

17:17 rhickey: ozzilee: java variadics

17:17 walters: ozzilee: your best best is going to be to use openjdk

17:18 ozzilee: rhickey: Hmm ok.

17:18 walters: Any idea if that will work on the PPC?

17:18 walters: ozzilee: it's a better match particularly for a dynamic language, and really what we want is hotspot to have a native code compilation cache

17:18 ozzilee: work on a zero-assembler version is in icedtea from some Red Hat hackers

17:19 ozzilee: there is also an ongoing port to LLVM but that's not ready yet

17:20 ozzilee: walters: So it looks like no dice for running Clojure on Debian PPC today. Bummer.

17:20 walters: ozzilee: is debian's openjdk pulled from icedtea? if so and it's recent enough i think it should work

17:21 drewr: H4ns: You can send your swank problem to jochu0@gmail.com. Jeffrey is very helpful.

17:21 walters: it will not be blazingly fast but it should work

17:21 alec: walters: I run svn clojure with Debian's openjdk 6

17:22 (amd64, not ppc)

17:22 works fine

17:22 H4ns: drewr: he's already looking at it, but thanks!

17:22 ozzilee: walters: Not in stable, anyway. I'll have to look around a bit.

17:22 walters: alec: yeah, the main pain point is ppc since hotspot is a highly tuned and custom JIT for x86/x86_64/sparc

17:23 ozzilee: you might ask on OFTC #openjdk

17:24 ozzilee: walters: I'll do that, thanks.

17:30 rhickey: danlarkin: you asked earlier about keywords as functions. Not everything can be a fn, I can't change numbers for instance. If you want consistency, always use the map itself as the fn - that will always work. Keywords were made fns too because they are often used as keys, and when doing so tend to 'feel' like properties, in which case reading (:name x) as 'the name of x' works well.

17:30 I don;t think it would work as well for numbers and strings, even if I could support that

17:30 but I wouldn't take it out for keywords

17:33 danlarkin: rhickey: thanks for the explanation... I guess I will just stick to using the map/vector as the function, for consistency's sake

17:44 smoofra: is there a document anywhere that explains how closure maps to java? things like the calling convention, boxing, etc

17:44 wwmorgan: smoofra: http://clojure.org/java_interop

17:49 Chouser: rhickey: clojurescript/avoid-java-in-boot.patch moves some references to java from boot.clj into RT.java

17:50 Any remaining references in boot.clj are skipped by clojurescript when compiling boot.clj, either because they don't make sense in javascript or because they'll need to be written in js by hand.

19:41 H4ns: can anyone recommend a fast, small java http server that i could use to run clojure applications in? i'm looking for something that can handle a lot (>1000) of persistent connections.

19:47 * H4ns looks at xSocket, jetty

20:31 ozzilee: Good news everybody! Turns out openjdk6 runs on PPC Debian Lenny. So I've now got Clojure running on my 700mhz iBook :-)

20:45 arohner: what is the idiomatic way to see if an item is in a list?

20:45 like contains? for a seq/list/vector

20:48 * ozzilee also would like to know

20:48 arohner: I could use filter or some, but it seems like there should be a shorter way

20:52 H4ns: (take-while (partial = <elem>) <seq>) would work, but doesn't look quite idiomatic (and also cons)

20:53 can someone explain how i would instantiate a class from a random .jar containing java classes that i have downloaded? i seem to be totally confused

20:55 fyuryu: H4ns: you have to add the .jar to you classpath, then import it in Clojure, and then instantiate like this: (ClassName. ...)

20:56 H4ns: fyuryu: import would work like what? can you give me an example?

20:57 danlarkin: H4ns: you can find examples of importin in the clojure-contrib repo

20:57 AFAIR it's (import '(java.whatever.whatever))

20:58 H4ns: wow.

20:58 i must have tried almost everything almost like that :) thanks!

21:00 fyuryu: H4ns: http://github.com/rosado/clj-processing/tree/master/rosado/processing/processing.clj

21:01 H4ns: thanks - the import itself does not seem to check its arguments, so i'll need to learn more

21:05 fyuryu: success, thanks!

21:42 * H4ns discovered jconsole and is impressed

21:55 danlarkin: H4ns: wow thanks for sharing, jconsole is really cool

21:57 H4ns: danlarkin: i'm only beginning to recognize what "leveraging the platform" really implies. there is just a hell of a lot of enterprise class infrastructure that comes along with the jvm.

21:57 xlightweb also looks very good, both for client and server side http

23:46 arohner: is there a way to convert a java.util.Set into a clojure data structure?

23:48 danlarkin: perhaps call set on it?

23:48 arohner: I'm trying that

23:48 I get "Don't know how to create ISeq from:"

23:48 danlarkin: does (set (seq x)) work?

23:50 arohner: nope

23:51 the (seq x) fails

23:54 danlarkin: I'm sure there's a way

23:55 you could always do it manually

23:55 arohner: yeah, I'm surprised because set implements java.util.Collection

23:55 yeah

23:55 I thought Collection was what seqs used

Logging service provided by n01se.net