#clojure logs

2008-10-02

01:24scottj_How come clojure doesn't figure out automatically what can be run in parallel and do that?
01:34Chouseris that easy to do?
01:36scottj_I think I've heard Haskell does it.
01:38scottj_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.
01:38waltersi think haskell's static typing makes that much easier for them
01:39waltersclojure is dynamically typed with the advantages and disadvantages that typically entails
01:40waltersi.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
03:00Lau_of_DKMorning 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 ?
03:16hoeckLau_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
03:17hoeckLau_of_DK: so just setting up the Listeners and open a main swing window should do it
03:19hoeckLau_of_DK: but im not a swing guru, just played with swing and clojure a while ago
04:08Lau_of_DKhoeck, 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
04:08Lau_of_DKOf course, I lost the link
04:14Lau_of_DKLooking over Suns site, you might be right though
04:17hoeckmhh, maybe you have to check (in a loop) wether your main swing window is still open so that the script does not quit before
04:18achim_pLau_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.
04:22Lau_of_DKbut achim_p, ants.clj wont run strictly from the command line either, you need to maintain a repl
04:27achim_pLau_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?
04:30Lau_of_DKgimme a few secs,colleague knocking on the door
04:46Lau_of_DKachim_p , yes that works, thanks :)
04:55Lau_of_DKDo 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
05:11achim_pLau_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 ...
05:19Lau_of_DKachim_p, I worked out, that if you do this do your main JFrame, then it will exit when it closes
05:19Lau_of_DK(doto frame (setDefaultCloseOperation (. JFrame EXIT_ON_CLOSE)))
05:19Lau_of_DK(doto frame (setDefaultCloseOperation (. JFrame EXIT_ON_CLOSE)))
05:19Lau_of_DK(sorry, my paste putty/bitchx thing messed up on my screen, but I suppose you can read the bottom Line?
05:33achim_pyes, thanks! that's better.
08:42drewrI love seeing all the chatter on twitter about clojure.
08:42abrooks;-)
08:42drewrIt's grown a lot in the past few weeks.
08:42abrooksIt has.
08:42drewr"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
08:43abrooksBzzt.
08:43rhickeywhy is nil () and not [] or {} ?
08:44abrooksrhickey: I was just about to note how you put that argument to rest in the recent talk.
08:45rhickeyIt made sense when there were only lists... but now, not so much. or you''d also have to have null
08:45abrooksWhen 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.
08:45abrooksHeh. Crosspost.
08:46rhickeyheh
08:47jdzrhickey: you're my hero of the day!
08:47jdz(i smell some Java stuff will have to be done in near future, and this is a perfect time to start learning Clojure)
08:48rhickeyjdz: great!
08:48drewrabrooks: How can OCaml have pointer misalignments??
08:48jdzi'm just looking through the website and wonder if there is a way to create .jar files from clojure sources...
08:49jdzrhickey: can Clojure dump it's generated bytecode?
08:50abrooksdrewr: Heh. The compiler does...
08:50abrooksdrewr: In theory this runs on IRIX6 but their avoidance of GNU autoconf is my pain.
08:51drewr...and their joy. :-)
08:51jdzrhickey: 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 :)
08:51rhickeyjdz: not at present. You can jar up src with the normal Java jar tools
08:52jdzrhickey: ok, thanks. i won't take any more of your precious hacking time.
08:52rhickeyI 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
08:54abrooksdrewr: 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.
08:54drewrSo rhickey, did you pass the Xach test at the talk?
08:55rhickeydrewr: I think so: http://xach.livejournal.com/191581.html
08:55drewrabrooks: Yeah, that's what I thought. I've mostly stayed on the user end of autotools.
08:57jdzrhickey: 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)
08:57drewrrhickey: Ah, that post just came up in my feed reader. If you impressed that group then Clojure has a bright future!
08:58abrooksjdz: (first empty-sequence) -> nil
08:58abrooksjdz: The reason is there is no empty sequence.
08:58jdzabrooks: yeah, that's quite natural. it's just that it was not mentioned in the presentation. and i'm not sure it should...
08:59abrooksjdz: (seq []) -> nil
08:59jdzabrooks: no, there is an empty sequenc. that's the whole point!
09:00jdzabrooks: 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.
09:00abrooksYou never have an empty sequence. You may have an empty list/vector/set/hash but if you get it's sequence you have nothing.
09:00jdz(well you can take first and rest of it, and you get nil)
09:01jdzabrooks: oh, right. right.
09:02rhickeyin Clojure, nil means "nothing", but first and rest are defined on nil to return nothing/nil too
09:02abrooksEr... s/it's/its/ ----^ (It's too early in the morning...)
09:11andrewdotnichg'day everyone
09:12rhickeyandrewdotnich: hi
09:12andrewdotnichrhickey, watched your "Clojure for Lisp programmers" talk this afternoon
09:12andrewdotnichgoing to start playing around with it in my spare time, looks quite impressive
09:13rhickeygreat!
09:14andrewdotnichI'm a 3rd-year university student in Melbourne, Australia - we haven't had much FP teaching as part of our course
09:14andrewdotnichalthough we did go through Lambda Calculus for a languages subject
09:20abrooksandrewdotnich: 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.
09:20abrooksER. I meant to have "I highly recommend it" in there some where. ---^
09:25andrewdotnichyeah, I've done a few Euler problems
09:26abrooksandrewdotnich: In Clojure or another language?
09:26andrewdotnichPython, mainly
09:26andrewdotnichanother language I've had to teach myself
09:27andrewdotnichmy university being quite traditional in its language selection (Pascal, then C# / Java, with some C++ thrown in)
09:31andrewdotnichrhickey: 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)?
09:32rhickeyH4ns: nice blog post. http://netzhansa.blogspot.com/2008/10/trying-clojure.html Did you try debugging with JSwat or enclojure?
09:32H4nsrhickey: no, i've tried sticking to slime. i guess i should try to be more open :)
09:33H4nsrhickey: for the next project, i'll look into one of those, thanks!
09:33rhickeyah, 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
09:35H4nsrhickey: i'll look at that and post praise to my blog, promised :)
09:35rhickeyH4ns: ok :)
09:36rhickeyalso, I've been working on error messages and will look at anything specific
09:38H4nsrhickey: 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?
09:38rhickeyH4ns: yes please
09:38H4nsok.
10:07Chouserearthvssoup: the new code looks beautiful
10:07earthvssoupChouser: thanks to you
10:07ChouserI'm starting to get the feeling people want more or different documentation. ;-)
10:08earthvssoupFor me... a little bit from column B and a lot from column A ;)
10:08rhickeyI'd love to see a Clojure examples project get going somehow
10:08earthvssoupI am totally a n00b here, but I would be happy to help however I can
10:09H4nsplanet.clojure.org and aggregate manually maybe?
10:10ChouserAt this point there's a whole lot of example code floating around "out there" -- is google any good at collecting that?
10:10alecno
10:10earthvssoupnot really
10:11Chouserto 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:11earthvssoupagreed
10:11rhickeywe've imagined a structure with a page per function, with doc/example/test/tips
10:12earthvssoupFor me, good examples are key
10:14jdzi miss interactive documentation. like (describe defstruct)
10:14Chouserdoc
10:14jdzChouser: oh thank you.
10:15earthvssoupMany 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:15ChouserAlso: (find-doc "struct")
10:15blackdogi think the best examples are in boot.clj, keeping it open at all times for reference is well worth it
10:15Chouserearthvssoup: I'm not quite sure what you mean.
10:16Chouserblackdog: 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:17earthvssoupWell, 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:18Chouserah, 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:18H4nsearthvssoup: 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:19earthvssoupBTW, I agree that boot.clj is great. Perhaps an annotated version explaining how it builds on itself would be useful?
10:19earthvssoupH4ns: agreed
10:19H4nsearthvssoup: i think good example code should be good enough that could copy and paste it, but one never should actually do it :)
10:21earthvssoupOf course my On Lisp -> Clojure project takes the (bad/good-reverse) approach, but that is only a product of my ignorance
10:22Chouserbtw, the "else" part of "if" is optional. If you leave it out, it's as if you specified nil.
10:23H4nsChouser: in common lisp, we prefer when over if without an else clause. same in clojure?
10:23ChouserH4ns: yes
10:24ChouserH4ns: yes
10:24H4nsChouser: ok
10:25drewrrhickey's explanation of cons/seq is awesome.
10:28ChouserHaving just spent 10 minutes looking at the problem, I think I'm the wrong person to set up a examples wiki. :-/
10:28drewrWhat's the behind-the-scenes difference of:
10:28drewrwm> (first {:foo 1 :bar 2})
10:28drewr[:bar 2]
10:28drewrwm> (first (seq {:foo 1 :bar 2}))
10:28drewr[:bar 2]
10:28lisppaste8rhickey pasted "make-adderb" at http://paste.lisp.org/display/67788
10:28Chouserdrewr: first calls seq on its arg for you
10:28drewrAhh.
10:29rhickeyearthvssoup: that's the most straightforward make-adderb
10:31ChouserH4ns: that PDF is beautiful.
10:31earthvssouprhickey: 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:32jdzwhich pdf?
10:32H4nsChouser: yep - it will propably be very helpful for when to just read it back to back.
10:33H4nshttp://clojure.googlegroups.com/web/manual.pdf?gda=HTUM7jwAAABoLitVpBTEcNIQc_NHg39S6DeYQuwQGx9N3mteasxC_bb1z1jhUxpJojBve3FvCyr9Wm-ajmzVoAFUlE7c_fAt&gsc=IJhlFgsAAAB2uMKWD8zLj_ZrTVfKpqX8
10:33H4nsdunno about the gibberish in the end, sorry.
10:33alecrhickey: 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:33H4nsalec: the food sponsor, too!
10:34rhickeyalec: you're welcome. what are the conversations like?
10:34blackdogthanks for that pdf, v. useful
10:35rhickeyit was my pleasure to speak to an audience so deeply engaged in the concepts
10:37alecsome 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:37alecwe also dream about how easy it would be to parallelize our applications - that's a big selling point
10:38alecthe "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:39alecoverall good reception
10:40rhickeyalec: there certainly are times when I do care, but was more impressed by the Azul GC not breaking a sweat at those rates
10:40blackdogrhickey: what is ephemeral garbage? is that the first generation of garbage?
10:41H4nsrhickey: 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:41jdzblackdog: it's just recently generated garbage since last GC.
10:41rhickeyblackdog: something you allocate and stop referencing almost immediately
10:41blackdogok, thanks
10:43rhickeyH4ns: 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:44jdzin what ballpark those Azul systems cost?
10:44rhickeyThe Clojure seq abstraction couldn't exist without ephemeral garbage
10:45rhickeyjdz: if you need to ask, you can't afford it :)
10:45jdzfair enough
10:46jdzi know i don't want one under my desk :)
10:46jdz(i don't have a desk that big)
10:46rhickeyI do, they are very small (something like 200 cores in 5U)
10:47jdzsounds pretty awesome
10:47rhickey:)
11:15jdzor is it Symbolics ex-employees?
11:16abrooksIt's hard to see but that's a non-breaking space. ;-)
11:16jdznice one!
11:32achim_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:55scottj_how do you guys think enclojure would do at the benchmark game? about like groovy/jruby?
12:57scottj_I mean clojure. I was just installing enclojure :)
12:57abrooksRuby is slow in its native install. I wouldn't expect JRuby to win any speed competitions but perhaps I'm wrong.
12:58rhickey_scottj_: should be able to get close to Java, perhaps not with the most idiomatic Clojure, but that's the game
12:58abrooksI know nothing of groovy's performance.
12:59abrooksI'd sort of expect Groovy to be significantly better than JRuby as Groovy is explicitly a language designed around the JVM.
13:00rhickey_abrooks: there's a tremendous amount of dynamism in both Groovy and JRuby getting in the way of perf
13:00abrooksrhickey_: I suspected as much of Groovy (I know that JRuby is hampered).
13:00waltersthough groovy does have the nice aspect that you can just replace "var" with "int"
13:01abrooksDoes Groovy use unboxed numbers?
13:01waltersi think currently when you declare types it doesn't do anything useful
13:02scottj_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:04abrooksThis is one of the more fatuous language articles I've read recently: http://java.dzone.com/news/groovy-will-replace-java-langu
13:04abrooksDid you know that "Groovy is the only language together with Scala and of course Java that always compiles to true Java byte-code."
13:05rhickey_scottj_: statically typed langs should have best perf, but Clojure should be closer to Java than to Groovy, certainly
13:10scottj_abrooks: does Clojure use unboxed numbers?
13:13abrooksNot 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:13abrooks^directly^directly,
13:15rhickey_abrooks: yes, it supports unboxed numbers (and arithmetic) locally, and in non-reflective calls to/from Java, given any needed hints
13:16rhickey_ditto arrays of primitives - see type hints and primitives sections here: http://clojure.org/java_interop
13:19danlarkinjust read http://netzhansa.blogspot.com/2008/10/trying-clojure.html
13:20H4nsdanlarkin: let me know if i wrote something silly
13:21danlarkinno no, I like it
13:21scottj_H4ns: I think those nbm files have dependencies that it will download from netbeans
13:22H4nsscottj_: 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:23H4ns"Networking problem in file:/C:/Users/hans..."
13:33lisppaste8danlarkin pasted "def def" at http://paste.lisp.org/display/67800
13:34danlarkinI'm confused about what happens in that snippet I pasted
13:35Chouserdon't def def
13:36Chouser;-)
13:36rhickeydanlarkin: right now there aren't prohibitions on redefinitions of special ops
13:36rhickeybut invocation always resolves def to special op, so you haven't truly shadowed it
13:39danlarkinso special symbols get short-circuted in the evaluator?
13:39danlarkinwould that be fair to say?
13:39rhickey_right, there aren't necessarily vars for them
13:41danlarkinright, since in a clean environment (resolve 'def) returns nil
13:41rhickey_I should lock them down...
13:42H4nswow, slime with a working repl _is_ amazing! :)
13:43H4nsbtw, does the repl have something like *, **, ***?
13:44ChouserH4ns: *1 *2 *3 ?
13:45H4nsChouser: java.lang.IllegalStateException: Var *1 is unbound. (NO_SOURCE_FILE:0)
13:45H4nsmaybe the slime repl is not a repl thread in that sense.
13:46H4nsrhickey_: you should (i admit, this is kind of a selfish remark) :)
13:46H4ns"i wanted to enter the 21th century, but enclosure did not even want to install"
13:46ChouserH4ns: could be. I don't use emacs, so I can't say.
13:48drewrabrooks: I think JRuby has actually surpassed CRuby in speed, but I don't keep up with that stuff.
13:49akingH4ns: are you using clojure from svn or the release version? *1/*2/*3 was added two days after the release
13:49achim_pthe star vars don't work in slime
13:50achim_panother downside is the lack of input line numbering
13:50H4nsaking: svn
13:50waltersdrewr: it has yeah...but ruby 1.8 is a *really* bad VM
13:51drewrwalters: :-)
13:51H4nsachim_p: input line numbering i don't miss so much. what do you use that for?
13:56fyuryulazy-cat
13:56abrooksdrewr: JRuby/CRuby -- interesting.
13:56fyuryuups
13:56fyuryuwrong buffer
13:57waltersdrewr: also my impression is the jruby hackers are particularly good
13:57H4nsgiven a command-line repl, how do i load foo.clj into the running clojure? the getting started page does not tell.
13:58Chouser(doc load)
14:00H4nsjava.lang.ClassCastException: java.lang.String cannot be cast to java.io.Reader when i type (load "foo.clj"), which is an empty file?
14:00Chouserrhickey: is there some reason you used fns-in-metadata instead of multimethods for clojure.zip?
14:01abrooksH4ns: You probably want (load-file )
14:01abrooks(load-file "foo.clj")
14:01H4nsabrooks: ah! damnit.
14:01H4nsthanks!
14:02Chouserhuh. for me, (load "foo.clj") says Could not locate Clojure resource on classpath: user/foo.clj
14:02abrooksChouser: load works in the classpath.
14:02Chouserif it finds foo.clj, but it's empty, I get nil
14:02Chouserabrooks: yes
14:03abrooksOh, you're having a different problem.
14:03ChouserI'm not having a problem, I'm just failing to understand H4ns'
14:05H4nsi don't understand my problem either, but load-file works a little better.
14:05rhickeyChouser: 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:06Chouserrhickey: ok, thanks.
14:09achim_pH4ns: 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:10Chouser^(def x) includes a :line number for me
14:12achim_pChouser: ah, that's the difference i meant. in slime it's always 1
14:13achim_pi checked the error message on (/ 0 0), which states "NO_SOURCE_FILE:0" in both environments.
14:18abrooksuser=> (/ 0 0)
14:18abrooksjava.lang.ArithmeticException: Divide by zero (NO_SOURCE_FILE:0)
14:18abrooksuser=> (def x (/ 0 0))
14:18abrooksjava.lang.ArithmeticException: Divide by zero (NO_SOURCE_FILE:62)
14:19abrooksThere's the difference. I think you must have something (such as a symbol) to associate the metadata with.
14:19rhickeyIs there something useful about repl line #s?
14:21abrooksrhickey: I think so, particularly if you have the REPL joined to an editor or an IDE.
14:22rhickey I mean for source entered into the repl
14:23rhickeylike above, line 62
14:24abrooksrhickey: Yes. If you have scroll back or prompt numbering or something managing the lines input to the REPL, I think that's useful.
14:31abrooksrhickey: 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:33rhickeyabrooks: understood, here with emacs + clojure-mode in inferior lisp I don't see any way to use those numbers
14:35abrooksAt 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:37rhickeyLine 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:43abrooksrhickey: 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:43abrooksIOW, don't bother yourself. ;-)
14:44abrooksI've been looking at datalog implementations. Which implementation were you thinking of using?
14:45rhickeyabrooks: IRIS Reasoner: http://iris-reasoner.org/
14:46abrooksEvery once in a while I find myself really missing CLIPS and then I know how sad things are...
14:51abrooksIRIS looks very complete and well constructed.
14:52rhickeyyes, nice set of interfaces for extension
14:56earthvssoupMy first job out of college was CLIPS
14:56earthvssoupI look back on it fondly (although doesn't everyone with their first?)
14:58Chouserrhickey: is LGPL a problem with IRIS?
15:00rhickeyChouser: 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:00Chouserok, doesn't sound too bad.
15:03rhickeyThe 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:03abrooksrhickey: 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:04rhickeyabrooks: the latter
15:06rhickeyIRIS is doing magic sets and stratified negation already, so if it is fast enough, why reinvent the wheel?
15:07abrooksrhickey: 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:08rhickeyabrooks: we can battery-include the jar
15:08abrooksAh, okay. My latter case was a user provided jar.
15:08rhickeyright, you only gave me 2 choices :)
15:09rhickeyI don't want to track the source
15:09abrooks;-)
15:09abrooksrhickey: That's wise, particularly with Subversion which goes out of its way to be sucky at tracking third-party changesets.
15:11abrooksUllman 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:11waltersthough the fact that there's no standard mechanism for system jar installation sucks badly
15:13rhickeyabrooks: 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:15rhickeywhat 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:16rhickeysometimes 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:16abrooksSimple datalog is certainly the place to start, IMO.
15:17abrooksCan't it be incorporated without negation at first?
15:17rhickeybut yes, should start simply
15:17abrooksRight.
15:18rhickeyWhere I'm at is the "buy" vs build point - IRIS is sitting there, with nice interfaces
15:18rhickeyOTOH, I have my own ideas about purely functional dbs, with indexes
15:18abrooksrhickey: Don't we all. ;-)
15:20abrooksI 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:21rhickeyWhat 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:21abrooksChouser: Is noiski nearly done? We could just go with that? ;-D
15:22Chouserabrooks: noiski will use this feature, not the other way around.
15:22abrooksrhickey: That would be grand.
15:23abrooksChouser: Silly - noiski has had this feature forever -- it's just missing from the current implementation.
15:31abrooksrhickey: I'm assuming that we wouldn't use the IRIS parser (primarily/at all?) in favor of using a native Clojure interface.
15:33rhickeyabrooks: right - native Clojure
15:33Chouserwoohoo! prn works, which proves multimethods at least kinda work, which proves isa? kinda works, which proves the type system is close enough.
15:34rhickeygo Chouser !
15:34abrooksChouser: Congrats!
15:34ChouserI gotta get this to a useful state soon -- I'm afraid I'm approaching burn out.
15:34ChouserI don't even remember why I wanted it anymore.
15:35abrooksHeh.
16:12danlarkincan I flip ([1 2 3] 0) around like I can with a map?
16:13Chouserkeywords look themselves up in a collection, numbers don't.
16:17danlarkinwhy not?
16:17lisppaste8H4ns pasted "Backtrace for the swank-clojure maintainer" at http://paste.lisp.org/display/67814
16:18abrooksdanlarkin: Keywords are functions of maps and maps are functions of keywords (both in the logical sense and in the Ifn interface sense).
16:18Chouserdanlarkin: 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:20danlarkinit seems like it would be nice to have the same syntax rules for a map no matter what one's keys are
16:20danlarkinalthough if it's not possible, it's not possible
16:21Chouserwell 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:23abrooksdanlarkin: 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:23abrooksi.e. (def x #(println "foo"))
16:24abrooksuser=> (x {:foo :bar})
16:24abrooksjava.lang.IllegalArgumentException: Wrong number of args passed to: x (NO_SOURCE_FILE:0)
16:24danlarkinwould 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:24abrooksuser=> ({:foo :bar} x)
16:24abrooksnil
16:24abrooksuser=> ({x :bar} x)
16:24abrooks:bar
16:24abrooksdanlarkin: I think because of the special nature and usage patterns around keywords, that reversed structure is very reasonable.
16:25abrooksA keyword never has a value or other functionallity other than referring to itself. Looking itself up is a pretty close concept.
16:47danlarkinis there a function to return the arity of another function? I looked but could not find anything appropriate
16:48smoofracan someone help to enlighten me please: what's the diffirence between alter and commute?
16:50danlarkinnot only does commute set the in-transaction-value of ref, it also sets the current value
16:51ozzileesmoofra: Commute means the order doesn't matter, so Clojure is free to apply commute calls in whatever order it pleases.
16:58smoofraah
16:58abrooksOkay, I'm baffled. I would think that I could get the function's metadata:
16:58abrooksuser=> ^(defn x [a b c] (println "foo"))
16:58abrooks{:line 11, :arglists ([a b c]), :name x, :file "NO_SOURCE_FILE", :ns #<Namespace: user>}
16:58abrooksuser=> (defn x [a b c] (println "foo"))
16:58abrooks#'user/x
16:58abrooksuser=> ^x
16:58abrooksnil
16:59wwmorganfunction can't have metadata. Try ^#'x
17:00abrooksArg. Of course. I tried ^'x but forgot the sharp.
17:01danlarkinis #'foo shorthand for (resolve 'foo)?
17:02smoofraso is there any way to get mutable datastructures in clojure without going to refs or java?
17:02wwmorganhttp://clojure.org/reader #'foo is short for (var foo)
17:03H4nssmoofra: what are you trying to achive?
17:04abrooksdanlarkin: (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:05smoofraH4ns: something like a haskell stref i suppose. a nice little ref you can read and write from without doing a transaction.
17:05danlarkinabrooks: thanks! didn't think of looking at the metadata, d'oh
17:06H4nssmoofra: why can't you use a ref and transaction for that? performance issue?
17:07abrooksdanlarkin: np
17:10smoofraH4ns: 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:11smoofraer. naked even.
17:12H4nssmoofra: i'd say: don't worry. if you want to mutate, use other languages :)
17:13Chousersmoofra: you could use a var with binding and set!
17:14Chousersmoofra: I believe the overhead of a transaction when there is no contention is pretty small.
17:14smoofraH4ns: that's a bit silly. what with haskell having ST and all.
17:15H4nssmoofra: you need to talk to rhickey and have him convince you that you just don't want that.
17:15Chousersmoofra: 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:15Chouseror right, what H4ns said. :-)
17:15rhickeyjust hopping on - don't want what?
17:15H4nsrhickey: mutate data.
17:16rhickeyyou have refs, vars, agents and java.util.concurrent.atomic for mutating data
17:17ozzileerhickey: AFn.java line 169 has "Object... args)" at the end of the method signature. gcj doesn't like it, what is it?
17:17rhickeyozzilee: java variadics
17:17waltersozzilee: your best best is going to be to use openjdk
17:18ozzileerhickey: Hmm ok.
17:18ozzileewalters: Any idea if that will work on the PPC?
17:18waltersozzilee: 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:18waltersozzilee: work on a zero-assembler version is in icedtea from some Red Hat hackers
17:19waltersozzilee: there is also an ongoing port to LLVM but that's not ready yet
17:20ozzileewalters: So it looks like no dice for running Clojure on Debian PPC today. Bummer.
17:20waltersozzilee: is debian's openjdk pulled from icedtea? if so and it's recent enough i think it should work
17:21drewrH4ns: You can send your swank problem to jochu0@gmail.com. Jeffrey is very helpful.
17:21waltersit will not be blazingly fast but it should work
17:21alecwalters: I run svn clojure with Debian's openjdk 6
17:22alec(amd64, not ppc)
17:22alecworks fine
17:22H4nsdrewr: he's already looking at it, but thanks!
17:22ozzileewalters: Not in stable, anyway. I'll have to look around a bit.
17:22waltersalec: yeah, the main pain point is ppc since hotspot is a highly tuned and custom JIT for x86/x86_64/sparc
17:23waltersozzilee: you might ask on OFTC #openjdk
17:24ozzileewalters: I'll do that, thanks.
17:30rhickeydanlarkin: 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:30rhickeyI don;t think it would work as well for numbers and strings, even if I could support that
17:30rhickeybut I wouldn't take it out for keywords
17:33danlarkinrhickey: thanks for the explanation... I guess I will just stick to using the map/vector as the function, for consistency's sake
17:44smoofrais there a document anywhere that explains how closure maps to java? things like the calling convention, boxing, etc
17:44wwmorgansmoofra: http://clojure.org/java_interop
17:49Chouserrhickey: clojurescript/avoid-java-in-boot.patch moves some references to java from boot.clj into RT.java
17:50ChouserAny 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:41H4nscan 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.
20:31ozzileeGood news everybody! Turns out openjdk6 runs on PPC Debian Lenny. So I've now got Clojure running on my 700mhz iBook :-)
20:45arohnerwhat is the idiomatic way to see if an item is in a list?
20:45arohnerlike contains? for a seq/list/vector
20:48arohnerI could use filter or some, but it seems like there should be a shorter way
20:52H4ns(take-while (partial = <elem>) <seq>) would work, but doesn't look quite idiomatic (and also cons)
20:53H4nscan 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:55fyuryuH4ns: you have to add the .jar to you classpath, then import it in Clojure, and then instantiate like this: (ClassName. ...)
20:56H4nsfyuryu: import would work like what? can you give me an example?
20:57danlarkinH4ns: you can find examples of importin in the clojure-contrib repo
20:57danlarkinAFAIR it's (import '(java.whatever.whatever))
20:58H4nswow.
20:58H4nsi must have tried almost everything almost like that :) thanks!
21:00fyuryuH4ns: http://github.com/rosado/clj-processing/tree/master/rosado/processing/processing.clj
21:01H4nsthanks - the import itself does not seem to check its arguments, so i'll need to learn more
21:05H4nsfyuryu: success, thanks!
21:55danlarkinH4ns: wow thanks for sharing, jconsole is really cool
21:57H4nsdanlarkin: 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:57H4nsxlightweb also looks very good, both for client and server side http
23:46arohneris there a way to convert a java.util.Set into a clojure data structure?
23:48danlarkinperhaps call set on it?
23:48arohnerI'm trying that
23:48arohnerI get "Don't know how to create ISeq from:"
23:48danlarkindoes (set (seq x)) work?
23:50arohnernope
23:51arohnerthe (seq x) fails
23:54danlarkinI'm sure there's a way
23:55danlarkinyou could always do it manually
23:55arohneryeah, I'm surprised because set implements java.util.Collection
23:55arohneryeah
23:55arohnerI thought Collection was what seqs used