#clojure log - Sep 05 2008

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

9:02 parth_m: Hello, I want to convert (interpose \, [1 2 3 "hello"]) into a string "1,2,3,hello". Whats the best way to do this. I tried str but that gives me something "clojure.lang.LazyCons@20885a6e". I am not sure how to force it.

9:02 rhickey: parth_m: (apply str ...)

9:02 parth_m: Ah. Works perfectly. Thanks :)

11:21 wwmorgan: what's the idiomatic way to produce an IPersistentMap from a java.util.Map?

11:22 Chouser: the other direction has come up a couple times, with no clear right answer.

11:22 rhickey: wwmorgan: are you sure you need one? you can do a lot with Maps directly

11:23 wwmorgan: yeah I can work with a Map if there's no easy way to get a clojure map from it

11:24 rhickey: wwmorgan: there is: (into {} amap)

11:26 wwmorgan: that looks like it's exactly what I need thanks

11:27 Chouser: for the other direction, since PersistentMap doesn't implement java.util.Map, would it make sense to provide some kind of simple proxy wrapper?

11:28 rhickey: Chouser: I thought someone was doing that - (jmap m)

11:28 Chouser: yeah, I hadn't heard your opinion on it.

11:28 rhickey: there was much discussion here a while back

11:28 Chouser: oh, ok. nm, then.

11:30 rhickey: Chouser: no search on clojure-log

11:30 Chouser: nope, I rely on google for that, which unfortately lags by a week or two.

11:31 rhickey: Chouser: of course - http://clojure-log.n01se.net/date/2008-07-18.html

11:33 JavaMapOnPersistentMap class, implements Map and IPersistentMap

11:34 Chouser: oh dear -- pastebin pastes expire.

11:34 DrewR: lisppaste8: url

11:34 lisppaste8: To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.

11:34 DrewR: :-)

11:35 Chouser: DrewR: do you know how long those stick around?

11:35 DrewR: I don't think they have any expiry.

11:35 Chouser: ok, great.

11:36 rhickey: iirc meredydd's version wasn't quite it

11:36 DrewR: Regarding the conversion from Clojure's data structures to Java's collections, in my case it seemed too problem-dependent to do generically.

11:36 I would love to see a generic solution though.

11:37 rhickey: DrewR: other than maps, Clojure's collections implement the corresponding Java interfaces and need no conversion

11:38 Chouser: DrewR: this was your solution, I believe: http://paste.lisp.org/display/65710

11:39 lisppaste8: drewr pasted "clojure-java data conversion" at http://paste.lisp.org/display/66351

11:39 Chouser: someone else I think wrote a proxy that kinda worked, but I'm not finding it now.

11:39 rhickey: implementing Map is a bit of a pain, but the idea would be the wrapper wouldn't involve any copying

11:39 Chouser: right

11:40 rhickey: also not in the implementations of entrySet/keySet/values

11:40 which means it is best written in Java using the Abstractxxx helper classes

11:40 Chouser: the proxy code I'm thinking of proxied entries and such as well, I think.

11:41 rhickey: Chouser: I don't recall seeing that - I thought it copied

11:42 anyone have a problem with the rational? predicate including BigDecimals?

11:45 Chouser: I've never done much with either, so no objection here. :-)

11:48 This may be what I'm thinking of: https://gist.github.com/4212/268fbf9bb07cbd458f880fa6c1ca414c5ccc7ca8

11:49 rhickey: Chouser: lots of copying there

11:50 Chouser: oh. indeed.

11:50 (set ...)

11:54 rhickey: I've added a bunch of predicates to boot.clj

12:01 Chouser: nice

12:02 It'd be nice if the inheritence chart showed those predicates at appropriate nodes.

13:16 abrooks: Ah, hurrah! (even? ) and (odd? )! I can now remove those from my laundry-list-of-things-to-ask-rich-about-later library.

13:16 rhickey: Thanks for the the predicates! ;-D

13:20 rhickey: I defined even? and odd? differently so they can handle floats:

13:20 (defn even? [n] (= 0 (rem n 2)))

13:20 (defn odd? [n] (= 1 (rem n 2)))

13:20 bit-and doesn't like floats.

13:21 DrewR: Are floats commonly queried for odd or evenness?

13:21 I'm not sure I've ever needed to do that.

13:21 rhickey: abrooks: you're welcome, although if people start saying (not (empty? x)) I'm taking it out :)

13:21 abrooks: DrewR: I don't know. I didn't want to stop other people from doing that. :)

13:22 * Chouser will use (when-not (empty? x))

13:22 abrooks: Heh.

13:22 rhickey: Chouser: ouch

13:22 Chouser: I'm lying. I'm happy to use (when (seq x)) like a good boy.

13:24 abrooks: DrewR: You're probably right. One should int/bigint before using odd?/even?

13:24 DrewR: Chouser: Have you played with JAXP at all?

13:25 Chouser: DrewR: nope.

13:27 rhickey: Anyone looked at GXP yet? http://code.google.com/p/gxp/

13:27 It looks like it could be a useful part of a Clojure web pipeline

13:27 Chouser: rhickey: still have the browser tab open from last time you asked.

13:28 rhickey: heh

13:28 Chouser: but no.

13:28 rhickey: I've looked at it a bit more - seems to be a well designed _functional_ template engine, delivered a la carte so no ties to a bigger framework

13:30 get for free: structural validation, escaping, whitespace removal, internationalization

13:31 easy to use resulting objects in a Clojure servlet

13:31 could gen gxp from Clojure

13:31 Chouser: so you don't have to write in xml

13:31 DrewR: Hm, I seem to remember looking at this.

13:32 rhickey: right, but makes the job of the Clojure 'template' engine much simpler. It's unlikely a homemade engine will do all of those things anytime soon

13:33 Plus it does the right thing by not supporting arbitrary code in pages, IMO

13:34 each page is a function, they understand Iterable, we could pass Clojure data structures and have gxp loop tags destructure them

13:35 Used by Google Adwords/AdSense/Checkoput/Blogger/Analytics/Reader etc

13:36 abrooks: rhickey: How do you feel about "_" as numeric "comma" allowing thousands, or bytes/words/longwords (hex/octal) to be visually clear?

13:36 I've been meaning to ask this in the group but I'm to lazy^H^H^H^Hbusy these days.

13:36 rhickey: abrooks: dunno, aren't there international standards for this stuff too?

13:37 abrooks: It's part of C99.

13:37 Other languages (Ruby, IIRC) support this too

13:37 I don't recall that Java does.

13:38 * rhickey likes Mathematica, which actually prints mini spaces

13:38 Chouser: ooh, we could use unicode mini spaces.

13:38 rhickey: 1 000 000 000

13:38 * abrooks looks for the mini-space bar on his keyboard...

13:39 rhickey: ha

13:39 abrooks: ohhereitis

13:39 A mini-spacebar is notably different than a space mini-bar which they might enjoy on the ISS.

13:48 Chouser: 1 000 000

13:48 tomhickey: 1 000 000 000

13:48 Chouser: jinx?

13:48 tomhickey: Chouser: lol, good timing

13:49 Chouser: but I can't tell with this client what you actually used.

13:49 I used 0x2009 "thin space"

13:49 tomhickey: hair space U+200A

13:50 http://en.wikipedia.org/wiki/Space_character#Table_of_spaces

13:51 Chouser: maybe a no-break space would be more appropriate, like U+202F

13:51 rhickey: you guys are crazy

13:51 :)

13:51 tomhickey: :)

13:51 Chouser: :(

13:52 * rhickey is still looking for the U+200A key...

13:54 rhickey: the only reason Mathematica can get away with it is that when you copy 1 000 000 000 it pastes elsewhere as 1000000000

13:54 Chouser: Breaking up a numeric literal would be optional. If you have an out-of-date keyboard with no U+200A, you can just skip it.

13:55 rhickey: the copy paste issue is the biggie - not being able to copy and use what printed

13:56 i.e. it should only be in the render, not the text, so ask the Vi/emacs/enclojure guys...

13:56 tomhickey: rhickey: definitely. you would need IDE (render) level support for this, seeing as most output your looking at is monospaced anyways

13:57 * abrooks has found _ in Ruby and FORTRAN but not C99.

13:57 rhickey: ah FORTRAN

13:57 abrooks: I may be in GCC and misremembering that as being in C99.

13:57 rhickey: FORTRAN lives...

13:58 Much of the code written by our customers is still FORTRAN.

13:59 "But my keyboard doesn't _have_ a thin-space key!" http://groups.google.com/group/comp.lang.python/browse_thread/thread/93dc57f9190b93bc/a9adb78560888739?lnk=raot

14:01 Oh, interesting. The X11 compose sequence MULTI+SPACE+SPACE is hair space.

14:01 Or his it "thin" space. I can't tell.

14:02 They don't look different. And /that/ really is the problem. They all look like space in a monospace font.

14:03 And they look the same in the handful of proportional unicode fonts that I've checked.

14:04 So, rhickey, how about those underscores?? ;-)

14:04 rhickey: yuck

14:04 abrooks: And thin/mini/tiny/hair/itsy-bitsy space is not yuck??

14:04 Chouser: no issues with infix notation, so how about dashes? 100-000-00

14:05 rhickey: please stop :)

14:05 abrooks: Chouser: If you're going to do numeric spaceing, stick with the semi-standard.

14:05 rhickey: really, I think this is an editor issue

14:06 Chouser: syntax-highlight sets of three digits in alternating colors?

14:06 rhickey: if you like

14:06 Chouser: I don't.

14:06 abrooks: Actually, just changing the background color of thin/hair space is probably good.

14:07 Chouser: Then again, I don't really have a dog in this hunt. So I'll stop talking now.

14:07 DrewR: Commas are already whitespace. How hard would it be to read int-comma-int before stripping them out?

14:07 user> 23,000,000

14:07 0

14:08 rhickey: DrewR: already playing with that idea

14:08 abrooks: DrewR: [1,2,3] ?

14:08 I thought of that previously but ruled it out as it's an easy trap.

14:08 rhickey: abrooks: right, would refine the ws/comma rule

14:08 abrooks: [1, 2, 3,4] (oops)!

14:09 DrewR: Ugh.

14:09 abrooks: I like the comma as it is.

14:09 rhickey: who's writing [1,2,3,4]?

14:09 * abrooks looks around nervously.

14:09 rhickey: oh

14:09 abrooks: Actually, I don't know that I ever have.

14:09 DrewR: I'll agree that there shouldn't be a difference between [1,2,3] and [1, 2, 3].

14:09 That's just asking for trouble.

14:11 abrooks: 0x239F,2B00,F269,BB14 doesn't look right. 0x239F_2B00_F269_BB14 does.

14:12 The problem is that when looking at code, I parse "," as a list of things: 100_238_998 in my mind is a single number. 100,238,998 looks like three numbers.

14:12 DrewR: If I say, "java -jar start.jar" how does java know what main() to execute?

14:12 Inside start.jar, obviously.

14:15 Chouser: The mainfest file has a Main-Class line

14:15 DrewR: mainfest! All main() all the time!

14:15 Chouser: DrewR: http://java.sun.com/docs/books/tutorial/deployment/jar/appman.html

14:15 DrewR: (Thanks, Chouser.)

14:16 Chouser: heh. sorry.

14:17 abrooks: BTW, neither the thin space nor hair space work at the repl.

14:18 rhickey: 1'000'000'000

14:18 Chouser: this is a fun conversation

14:19 rhickey: 0x239F'2B00'F269'BB14

14:19 Chouser: 1:000/000*000

14:19 oh, sorry, / is taken

14:19 abrooks: (println 1 '000' 000) (println 1'000'000)

14:20 rhickey: '000' ?

14:20 abrooks: ' is interesting, but I think _ is more common. Is there any particular reason to reject the more common _?

14:20 Chouser: underscores are icky

14:21 abrooks: rhickey: I was trying to show that a spacing error can cause a semantic change.

14:21 rhickey: but '000' would have to be meaningful first

14:22 abrooks: Isn't it a string?

14:22 rhickey: [1 2 3 4] [1234]

14:22 no, "000"

14:22 abrooks: Oh, is ' whitespace now?

14:22 That might be fine with me.

14:22 Chouser: ' only has meaning at the begining of token

14:22 (quote ...)

14:22 rhickey: spacing errors often cause a change in Lisps, since the language is space delimited

14:23 abrooks: Chouser: Right.

14:28 rhickey: , could change from ", is whitespace" to ", is ignored" - if people are doing 1,2,3,4 or a,b,c,d in Lisp that's ugly

14:29 but thousands sep is super low priority for me

14:35 * abrooks had no idea the digit separator query would generate such a conversation.

14:57 StartsWithK: hi

14:57 i am having problems with new 'ns' function

14:58 Chouser: hi? what's wrong?

14:58 er. "hi!"

14:58 StartsWithK: i have one file with code (create-ns 'neman.ufo) (ns neman.ufo) (clojure/refer 'clojure :exclude '(new))

14:58 if I load it from repl it works fine

14:59 Chouser: I don't think :exclude '(new) is going to do anything. But that may not be your point...

14:59 StartsWithK: now i have another file (create-ns 'neman.web) (ns neman.web (:require [neman.ufo :as ufo])) (clojure/refer 'clojure :exclude '(print println))

14:59 i have my own 'new'

14:59 in ufo namespace

15:00 now when i call neman.ufo from another file i ger

15:00 get*

15:00 Chouser: new is a special form, not a member of the clojure namespace.

15:00 StartsWithK: clojure.lang.Compiler$CompilerException: ufo.clj:11: Unable to resolve symbol: create-ns in this context

15:00 but that special form is in clojure namespace

15:01 it worked before i upgraded to new 'ns' function

15:01 so is '.' in clojure, no problem defining my own :)

15:01 this didn't happen before last upgrade and switching from contrib.lib to 'ns'

15:02 so problem is when i have one file that has create-ns that refers to another file that has create-ns

15:03 Chouser: yeah, ns doesn't really work very well if you want to muck around with your (refer 'clojure).

15:04 it's being worked out -- a patch is submitted and being mulled over, I think.

15:05 your problem is that ns currently generates a few commands that expect some of clojure to be refer'ed already, but the way your pair of files is set up thay may not have happened.

15:05 StartsWithK: heh, i shoud stay away from trunk :)

15:06 Chouser: well, you should be able to in-ns, require, and refer from boot.clj (no lib.clj needed).

15:07 StartsWithK: yes, i removed lib.clj and started to switch.. no lib.clj in code anymore

15:07 Chouser: I think you may still be able to use ns ... mulling...

15:08 oh, what if you just say clojure/create-ns in both files?

15:08 instead of just create-ns

15:08 StartsWithK: i removed (create-ns) from file that refers to ufo.clj, that works

15:08 clojure/create-ns or/and clojure/ns have no effect

15:08 but now i dont have web/print :)

15:10 also, why :require [bla :as ble] and :import (pkg Class), vectors for require and lists for import?

15:12 oh, and could we have :import (org.mortbay.jetty Server .. (handle AbstractHandler ..) (nio SelectChannelConnector))

15:12 so there would be no need to do org.mortbay.jetty org.mortbay.jetty.handler org.mortbay.jetty.nio ..

15:12 Chouser: I think that last suggestion was already made and rejected as too complex

15:13 StartsWithK: i see

15:14 Chouser: hm, I'm getting different error for you example because my Clojure's already patched.

15:14 StartsWithK: is it in trunk?

15:14 ill pull

15:14 Chouser: ah, there we go.

15:15 no, my patch is local. rhickey didn't like it quite as-is.

15:16 ok, using clojure/create-ns and clojure/ns in ufo.clj works for me.

15:18 StartsWithK: it work for me too if i (load-file "src/neman/ufo/ufo.clj") from repl

15:18 Chouser: I'm pretty sure ":exclude '(new)" is a no-op, so all you really need in ufo.clj is just (clojure/ns neman.ufo)

15:18 StartsWithK: but if there is another file that has (create-ns 'foo) (ns foo (:require [neman.ufo :as ufo))

15:18 then it breaks

15:19 Chouser: right. I'm loading web.clj, which enters the neman.web namespace (before refer'ing clojure there), and then loads ufo.clj.

15:20 when run that way, ufo.clj starts off in neman.web with no clojure refer'ed, so you have to say clojure/create-ns and clojure/ns in ufo.clj

15:21 StartsWithK: java.lang.Exception: Unable to resolve symbol: import in this context

15:21 clojure.lang.Compiler$CompilerException: ufo.clj:12: Unable to resolve symbol: import in this context

15:22 (clojure/create-ns 'neman.ufo)

15:22 (clojure/ns neman.ufo

15:22 (:import (java.util UUID)))

15:22 (clojure/refer 'clojure :exclude '(new))

15:26 (clojure/create-ns 'neman.ufo)

15:26 (clojure/refer 'clojure)

15:26 (clojure/ns neman.ufo

15:26 (:import (java.util UUID)))

15:26 (clojure/refer 'clojure :exclude '(new))

15:26 works if I add another (clojure/refer 'clojure)

15:27 but it looks funny

15:28 no.. not working, now if i uncomment my print and println in web.clj i get that they refer to clojure/print and clojure/println

15:33 ppjt: Hi all. Anyone played with compojure recently?

15:41 rhickey: anyone else bothered by plural-ness of defns?

15:41 kotarak: not me. But I see that there might be some potential for confusion.

15:42 abrooks: rhickey: Is that def+ns ?

15:42 rhickey: abrooks: yes

15:43 * abrooks has already used his quota of contrarian for today...

15:43 abrooks: Otherwise I might suggest def-ns. :)

15:43 rhickey: no other defs have -, so starting to use them now will leave people wondering in every case

15:44 abrooks: Well, there's defn-

15:44 But that's differnt.

15:45 rhickey: right

15:45 abrooks: It's also different.

15:45 rhickey: alternatives welcome for the next 10 minutes

15:45 * abrooks marches in the zombie ranks of allergy sufferers today

15:45 abrooks: def'ns

15:45 rhickey: very funny

15:46 abrooks: I'm sorry. I'd ACTUALLY contribute if I were able to think clearly today. Of course if I could think clearly, I'd be doing work, not hanging out here...

15:47 StartsWithK: defns will be used instead of create-ns?

15:47 DrewR: abrooks: That's cold.

15:48 abrooks: Oh, shoot. No, It's not a slam. I WANT to hang out here. I just have lots of stuff to do.

15:48 DrewR: --^

15:48 ozzilee: ppjt: I've played with compojure recently.

15:48 DrewR: abrooks: :-)

15:51 abrooks: rhickey: I know it's a bit different (and I've really not seen much of any of the recent ns details) but what about: nsdef ?

15:52 rhickey: abrooks: not verby enough

15:52 abrooks: Or actually, ns-def since we already have ns-name, ns-interns, etc.

15:52 kotarak: It would invert the usual defn, defmethod, etc.

15:52 rhickey: ns-blahs are accessors

15:52 abrooks: Yeah, I'm slowly realizing that. Good point.

15:53 ozzilee: What wrong with (lib foo.bar.mylib) ? I'm looking at the mailing list archives but I'm not clear on that.

15:53 kotarak: how about defnamespace? It's a bit longish, but we have also defmethod...

15:53 rhickey: kotarak: one might wonder why it is ns in all the other functions

15:54 setup-ns?

15:54 Chouser: mkns

15:54 where mk is short for multi-key. sorry, nevermind.

15:54 rhickey: you guys are too much today :)

15:55 kotarak: How does one pronounce mkns? ;) Similar to Skrnjk. (<- That's actually a name.)

15:55 make-ns?

15:55 abrooks: newns

15:56 Chouser: I like how declaritive defns is.

15:56 * rhickey does read mk as multikey, due to a MKMap library C# library I wrote and use

15:57 abrooks: I guess defns is the best though you know every new Clojure programmer will trip on that twice when the first learn Clojure.

15:57 Chouser: ...compared to setup-ns, make-ns, mkns, etc.

15:57 abrooks: how, by assuming it's plural of defn when they read code?

15:57 hoeck_: but defns sounds much like the plural of defn

15:57 abrooks: Chouser: Yes.

15:58 Chouser: init-ns, initns

15:58 abrooks: Chouser: Of course I have no idea what this will look like since I've not seen defns yet.

15:58 Chouser: defns will look like ns does now

15:59 abrooks: Oh, this is a rename of ns?

15:59 Drat. I was just about to suggest plain "ns".

15:59 Chouser: (defns net.n01se (:refer-clojure ...) (:import ...))

15:59 kotarak: init-ns or make-ns or setup-ns are all ok for me. Although I like defns for the consistency for the other defs...

15:59 * abrooks needs to catch up with the Google Group.

16:00 Chouser: well, if ns becomes defns, the new ns will be almost identical to in-ns.

16:00 rhickey: Chouser: right, just a macro shim

16:00 Chouser: So one option would be to leave ns as it is, and if you want to re-enter an existing namespace, use (in-ns 'foo)

16:01 or rename in-ns to something longer and make in-ns the macro shim.

16:06 I think the most common case will be one file per namespace, so to have a declaritive (ns ...) at the top seems nice. Then other files or at the repl you could say (in-ns ...) which could come to imply the namespace already exists and is set up.

16:21 ppjt: ozzilee: thanks. Stupid question, then -- do you know the canonical way to load one's own code from the app/ directory? There was a bit in the compojure docs about config/boot.clj loading any *.clj file under app/, but clearly that's not happening.

16:22 ozzilee: ppjt: Heh, nope, I've got no idea. I just added a line a boot.clj to load my files under app/

16:23 ppjt: ozzilee: Did you glob somehow, or just call load-file on some, etc.?

16:23 ozzilee: ppjt: Just called it on the file directly.

16:24 ppjt: I'm not particularly enamored of the layout myself, I'd prefer it if compojure was just a library I could load and use.

16:25 ppjt: ozzilee: Okay, thanks. I haven't yet digested the new namespace infrastructure, so I'm a little uncertain of how to do it correctly, or in a way I won't regret once I study up...

16:26 ozzilee: ppjt: Yeah me either. I've just been hammering stuff together, figuring it's all going to be evolving anyway.

16:26 ppjt: ozzilee: right, as is happening while we speak!

16:27 ozzilee: Indeed.

16:28 ppjt: ozzilee: file layout aside, d'you have any luck with compojure? Superficially, at least, it seems further along & more ready than another web framework I've happened across -- webjure.

16:28 ozzilee: ppjt: Yeah, I think webjure's dead. Compojure seems to work fine, I don't have anything in production on it though. I've been using it to screw around with Comet and CouchDB.

16:37 ppjt: ozzilee: Okay, cool. Myself, I'm just looking for an easy way to put clojure functions at the other end of HTTP requests, & that's its reason for being. So I shd be good. Don't know Comet; off to Wkp. Thanks!

16:37 ozzilee: ppjt: np

16:39 StartsWithK: ppjt: just looked at compojure, looks nice and simple to use

16:40 i have something similar, but is much limited than that

16:40 why didn't you write is as a lib?

16:42 ppjt: StartsWithK: yup, simply running script/repl & being ready to roll is a nice way to get acquainted

16:42 StartsWithK: "write it as a lib" -- you mean the so-called app part?

16:42 StartsWithK: yes

16:43 i have web.clj, design is copied from werkzeug (python lib)

16:43 just needs to be refered

16:43 ppjt: StartsWithK: sorry to say I'm not exactly sure what that means -- make its own ns, load multiple resources, etc.?

16:44 ozzilee: StartsWithK: ppjt didn't write Compojure, if that's what you're thinking...

16:44 StartsWithK: it looks like i have to include my code inside your boot.clj or something?

16:44 ups, sorry

16:44 :)

16:45 so ozzilee your the author?

16:45 ozzilee: Not me: http://github.com/weavejester/compojure/tree/master

16:47 StartsWithK: heh, files didn't have any copyright notice so i didn't catch authors name

16:47 ppjt: right, no, not me -- arohner, who's been active on the clojure group mailing list...

16:49 he's done a nice job; & he's keeping up with the clojure head (added the new (ns) methods, e.g.)

16:50 StartsWithK: ozzilee & I were just discussing how best to load your own code

16:50 StartsWithK: i tried to do the same, but my need are limited to serving json

16:50 so no html generation and such

16:51 ppjt: we've both just (load-file)'d our app/*.clj files

16:52 Would it seem to heavyweight even if you eliminated the libs (under lib/compojure) you didn't need?

16:53 StartsWithK: i don't have problem with extra code

16:53 wwmorgan: is there a reason that (prn #"foo") outputs foo and not #"foo" ?

16:57 ppjt: wwmorgan: #"foo" is a reader macro for a regex pattern

16:57 StartsWithK: wwmorgan: #"foo" will create java.util.regex.Pattern, i think prn will use Patten.tostirin

16:58 rapido: http://www.enchiladacode.nl. another language that has immutability at its core and sits on a jvm

16:58 the documentation is still a little bit rough and unfinished

16:59 DrewR: Oooh, browser-based REPL. rhickey better get right on that.

16:59 abrooks: It looks like enchilada is interpreted -- it's running in an applet.

17:00 DrewR: You'd have to give up JVM bytecode compilation.

17:00 rapido: DrewR: i nicked the browser-based REPL from http://will.thimbleby.net/misc/

17:00 StartsWithK: abrooks: why?

17:00 DrewR: "Economical: no need for all those parenthesis." What's wrong with parens?

17:01 rapido: DrewR: it forces you to use shift 9 and 0 a lot! :)

17:01 DrewR: rapido: Not with a decent editor. :-)

17:02 rapido: This is interesting. Thanks for posting.

17:02 rapido: DrewR: to be honest, to use enchilada you need a lot of parenthesis: squared, brackets, etc.

17:03 abrooks: StartsWithK: In order to run JVM bytecode that you've generated you need an alternate loader. The applet loader is one of the main security mechanisms of applets so you can't run created bytecode.

17:03 The bytecode needs to be part of the original signed jar for an applet.

17:03 StartsWithK: abrooks: i have clojure applet for a month now

17:04 abrooks: An interpreter could be added to clojure but that would.. wha????

17:04 StartsWithK: http://kreso.moo.com/gears.html

17:04 abrooks: StartsWithK: Okay.. how?

17:04 StartsWithK: gears version in clojure

17:04 abrooks: StartsWithK: I'm not able to resolve kreso.moo.com

17:04 StartsWithK: abrooks: i am lazy, i promissed month ago to write up how to do it

17:05 http://kreso.mooo.com/gears.html

17:05 it works on xp with java and i think 32-bit linux if java is configured

17:05 kotarak: Say I do: (let [[f-lines r-lines] (split-with some-pred (line-seq some-rdr))] (process f-lines) (process r-lines)) Are the f-lines loaded completely into memory or only as I process them or access r-lines?

17:05 abrooks: StartsWithK: Ah, you provide a separate signed loader, right?

17:07 StartsWithK: abrooks: no, i just added all persmission to my applet, (there is small base java class, same as the one used for web start clojure app that is presented on google groups)

17:07 uff.. me and my english :)

17:07 abrooks: StartsWithK: Cool -- It's running on x86_64 Linux in a 32-bit FireFox / Sun Java 1.6.

17:08 StartsWithK: That's awesome. I really have to catch up with everything that's been going on with Clojure.

17:08 StartsWithK: http://kreso.mooo.com/ has some other examples

17:09 so, who has swing repl code :)

17:09 abrooks: There is some IIRC.

17:09 Hm. Maybe I'm thinking of the class browser.

17:12 rapido: enchilada treats code (and continuations) as immutable data

17:12 Chouser: I'm just now comfortable with lisp syntax. I'm not ready for postfix.

17:12 rapido: as such it is very hard to compile enchilada to the metal

17:12 StartsWithK: i was thinking of using http://prefuse.org/ to implement something like clojure.inspector in applet, but.. time is not on my side

17:14 rapido: Chouser: it is just syntax

17:15 although prefix would be more 'compatible' with lisp

17:15 Chouser: but syntax matters

17:15 rapido: Chouser: i hear you, but isn't this exactly why people don't like lisp? because of the syntax?

17:16 abrooks: I've written enough postscript to know that postfix notation fricks with my head.

17:16 rapido: (+ (+ 1 2) (+ 3 4))

17:16 or + + 1 2 + 3 4

17:16 or 1 2 + 3 4 + +

17:16 StartsWithK: well i can scan first, but not second or third (clojure is my first lisp)

17:16 kotarak: or (+ 1 2 3 4)

17:17 rapido: kotarak: yep, you can't have variable arguments in enchilada

17:18 only unary and binary operators

17:18 Chouser: having to keep the argument stack in my head while reading postfix is -- uncomfortable.

17:19 rapido: but is the (operator arg1 arg2 arg3 ...) idiom much used in lisp?

17:19 Chouser: 1 2 3 4 5 + / * /

17:19 rapido: Chouser: don't think stacks. think term rewriting

17:19 and things get i little bit more convenient

17:20 Chouser: rapido: yes, arities of more than 2 are common in Clojure.

17:20 rapido: by the way, you can have postfix lambdas

17:20 Chouser: and for what it's worth, clojure has a bit more syntax than other lisps, and is more comfortable for me as a result.

17:21 I imagine there are many people who would be less bothered by postfix than I am. :-)

17:21 rapido: 4 5 + rewrites to 9. so replace 4 5 + with 9

17:22 Chouser: i have chosen for postfix because of the property that concatenating expressions syntactically yields valid expressions

17:24 a lot of enchilada magic comes from the combining of postfix expression in various ways

17:25 Chouser: interesting. Do all functions really take exactly 1 or 2 args?

17:25 rapido: yes

17:26 but you can create expression dynamically

17:26 kotarak: I'm not sure, whether I get the idea. 4 5 + f -> 9 f -> something. What is the difference to f + 4 5 -> f 9 -> something?

17:26 rapido: for instance: [1;2;3;4] [5;6;7;8] | [*] * yields

17:26 [1;2;3;4] [5;6;7;8] | [*] *

17:26 yields: [1 5 *;2 6 *;3 7 *;4 8 *]

17:28 kotarak: if enchilada was impure, then term rewriting would have this equational property

17:29 kotarak: other than that, it is just about syntax

17:29 would <- would not

17:31 rhickey: rapido: I missed the beginning of this thread - was there a Clojure aspect originally?

17:31 rapido: rhickey: like clojure, enchilada has immutability at its core and is built on top of a jvm

17:32 other than that, i'm afraid there is no resemblance

17:34 i am a great supporter of clojure because it has immutability as the default

17:35 enchilada is more radical in that *everything* is immutable

17:35 kotarak: As in Haskell?

17:35 rapido: that said, it is a research language. my goal is to see how far you can go with immutability

17:35 kotarak: unsafePerformIO?

17:37 kotarak: and haskell doesn't have call/cc nor does it treat code as data

17:37 kotarak: Don't know much about Haskell. Just some basics. But unsafePerformIO sounds like the dark side.

17:37 rapido: Does it need call/cc or does it have to tread code as data?

17:37 s/tread/treat/

17:38 rapido: enchilada can be compared to 'pure lisp': http://en.wikipedia.org/wiki/Lispkit_Lisp

17:39 kotarak: It was my understanding, that Haskell does use the IO monad stuff, to work around the immutability because you get the "world" as a parameter. But this is maybe some naive view. As I said: still learning.

17:41 rapido: kotarak: alternatively, in clojure, you could pass the world in a immutable structure like vector or hashmap, instead of using monads

17:44 Chouser: Clojure specically doesn't pretend the world is immutable. Instead it makes it easy to manage that mutability well.

17:44 rapido: remember, you can 'change' worlds MVCC style

17:44 rhickey: rapido: then everyone takes turns for their turn with the world, Clojure's reference and agent sets are essentially worlds with better concurrency

17:45 rapido: rhickey: no need to take turns. everyone can create new worlds

17:45 and merge worlds to reach consensus

17:46 rhickey: merge is same problem

17:46 single coordination point

17:46 not practical

17:46 doesn't scale

17:46 rapido: rhickey: no, it does scale much better than locks

17:47 look at git

17:48 you can reach consensus with different merging strategies, and optimistically

17:48 let's say n threads create n worlds

17:49 then 0.5n threads pair up independently and concurrently to merge their worlds

17:50 after that 0.25n threads pair up,... etc until consensus is reached

17:50 rhickey: all that consensus is coordination

17:50 having a single world makes for larger-than-needed granularity

17:50 rapido: sure

17:50 rhickey: split upt the world and essentiall you've got Clojure's refs

17:51 assoc == merge

17:51 commute etc

17:51 fine granularity

17:51 coordinate only on conflict

17:52 I doubt you could put GIT's system into in-proc and compete with STM

17:52 without it becoming STM

17:52 rapido: rhickey: but git would compete pretty good with distributed databases

17:53 enchilada is more in the 'distributed database' hemisphere than in the 'multi core' hemisphere

17:54 although enchilada gains some speed on multi cores because it is multi threaded

17:54 rhickey: I looked into DHT at your suggestion and didn't find anything with fine enough granularity to be a distributed DB - all had document granularity, lots of caveats etc

17:55 transaction in particular are a problem

17:56 rapido: rhickey: it is true that DHTs are document centric, but why do you need transactions?

17:58 rhickey: because that's how systems work - n-operations constitute one unit of work, the classic bank-account transfer problem etc

17:59 RDBMS, Mnesia, Scalaris - all recognize that need, not a DB without it

18:00 rapido: but you can't you do transactions on top of MVCC and immutable structures?

18:01 the only thing you need is the durability (D) guarantee

18:01 rhickey: Distributing it is the problem

18:01 Postgresql and Oracle are MVCC

18:02 rapido: rhickey: are you referring to two phase commit?

18:03 rhickey: That's one technique, Scalaris has quite another

18:03 I'm not writing a distributed DB

18:04 Clojure's STM could most easily get distributed with something like Terracotta

18:06 The only thing non-overlapping STM transactions share is a single timestamp, which is just a CAS in-proc, but difficult to scale on the wire

18:07 rapido: rhickey: let me point you to a database that uses immutable structures: http://www.herodotus.biz/DB_Features.html

18:08 i believe it is used for GIS applications. According to GIS the world is constantly changing! :)

18:10 rhickey: I'm not what that means in the case of DBs - any MVCC makes the past seem immutable, it's simply a matter of how much of it you keep around.

18:11 or more specifically, online, since everyone logs their DB

18:11 update is not in the relational model

18:12 rapido: rhickey: herodotus doesn't use a log. you can jump instantly to the past and compare the past with other versions

18:13 log transacted databases don't scale: the log will alway be the bottleneck

18:13 rhickey: that's my point, they keep more online, but at some point that's impractical and you want something like GC, or spool off, these are all differences of degree, not kind

18:13 rapido: alway <- always

18:16 but log transacted databases *are* a different kind than databases such as herodotus

18:16 rhickey: not really

18:18 rapido: throwing away history is easy

18:19 jumping back in history is not

18:19 rhickey: keeping it online is expensive, especially when it comes to indexing and queries

18:21 rapido: rhickey: that's why i have built enchilada: to show that keeping history (indexes, queries) can be done relatively 'cheaply'

18:21 rhickey: many times you use a table in 'append-only' mode, even in a RDBMS, but it's a choice you make trading off the query perf for the history

18:23 rapido: rhickey: i know what you are saying: i work at a bank. we keep lots of (time-series) history. :)

18:23 rhickey: don't get me wrong, I love the idea of keeping everything, but there are tradeoffs with keeping it online

18:24 rapido: at the bank we are not allowed to throw away data because of SOX compliancy rules

18:24 what to do? :)

18:25 rhickey: good to know you like to keep things too.

18:26 rhickey: it has been nice chatting to you... i have to run.... later

Logging service provided by n01se.net