#clojure logs

2008-09-05

09:02parth_mHello, 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.
09:02rhickeyparth_m: (apply str ...)
09:02parth_mAh. Works perfectly. Thanks :)
11:21wwmorganwhat's the idiomatic way to produce an IPersistentMap from a java.util.Map?
11:22Chouserthe other direction has come up a couple times, with no clear right answer.
11:22rhickeywwmorgan: are you sure you need one? you can do a lot with Maps directly
11:23wwmorganyeah I can work with a Map if there's no easy way to get a clojure map from it
11:24rhickeywwmorgan: there is: (into {} amap)
11:26wwmorganthat looks like it's exactly what I need thanks
11:27Chouserfor the other direction, since PersistentMap doesn't implement java.util.Map, would it make sense to provide some kind of simple proxy wrapper?
11:28rhickeyChouser: I thought someone was doing that - (jmap m)
11:28Chouseryeah, I hadn't heard your opinion on it.
11:28rhickeythere was much discussion here a while back
11:28Chouseroh, ok. nm, then.
11:30rhickeyChouser: no search on clojure-log
11:30Chousernope, I rely on google for that, which unfortately lags by a week or two.
11:31rhickeyChouser: of course - http://clojure-log.n01se.net/date/2008-07-18.html
11:33rhickeyJavaMapOnPersistentMap class, implements Map and IPersistentMap
11:34Chouseroh dear -- pastebin pastes expire.
11:34DrewRlisppaste8: url
11:34lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
11:34DrewR:-)
11:35ChouserDrewR: do you know how long those stick around?
11:35DrewRI don't think they have any expiry.
11:35Chouserok, great.
11:36rhickeyiirc meredydd's version wasn't quite it
11:36DrewRRegarding the conversion from Clojure's data structures to Java's collections, in my case it seemed too problem-dependent to do generically.
11:36DrewRI would love to see a generic solution though.
11:37rhickeyDrewR: other than maps, Clojure's collections implement the corresponding Java interfaces and need no conversion
11:38ChouserDrewR: this was your solution, I believe: http://paste.lisp.org/display/65710
11:39lisppaste8drewr pasted "clojure-java data conversion" at http://paste.lisp.org/display/66351
11:39Chousersomeone else I think wrote a proxy that kinda worked, but I'm not finding it now.
11:39rhickeyimplementing Map is a bit of a pain, but the idea would be the wrapper wouldn't involve any copying
11:39Chouserright
11:40rhickeyalso not in the implementations of entrySet/keySet/values
11:40rhickeywhich means it is best written in Java using the Abstractxxx helper classes
11:40Chouserthe proxy code I'm thinking of proxied entries and such as well, I think.
11:41rhickeyChouser: I don't recall seeing that - I thought it copied
11:42rhickeyanyone have a problem with the rational? predicate including BigDecimals?
11:45ChouserI've never done much with either, so no objection here. :-)
11:48ChouserThis may be what I'm thinking of: https://gist.github.com/4212/268fbf9bb07cbd458f880fa6c1ca414c5ccc7ca8
11:49rhickeyChouser: lots of copying there
11:50Chouseroh. indeed.
11:50Chouser(set ...)
11:54rhickeyI've added a bunch of predicates to boot.clj
12:01Chousernice
12:02ChouserIt'd be nice if the inheritence chart showed those predicates at appropriate nodes.
13:16abrooksAh, hurrah! (even? ) and (odd? )! I can now remove those from my laundry-list-of-things-to-ask-rich-about-later library.
13:16abrooksrhickey: Thanks for the the predicates! ;-D
13:20abrooksrhickey: I defined even? and odd? differently so they can handle floats:
13:20abrooks(defn even? [n] (= 0 (rem n 2)))
13:20abrooks(defn odd? [n] (= 1 (rem n 2)))
13:20abrooksbit-and doesn't like floats.
13:21DrewRAre floats commonly queried for odd or evenness?
13:21DrewRI'm not sure I've ever needed to do that.
13:21rhickeyabrooks: you're welcome, although if people start saying (not (empty? x)) I'm taking it out :)
13:21abrooksDrewR: I don't know. I didn't want to stop other people from doing that. :)
13:22abrooksHeh.
13:22rhickeyChouser: ouch
13:22ChouserI'm lying. I'm happy to use (when (seq x)) like a good boy.
13:24abrooksDrewR: You're probably right. One should int/bigint before using odd?/even?
13:24DrewRChouser: Have you played with JAXP at all?
13:25ChouserDrewR: nope.
13:27rhickeyAnyone looked at GXP yet? http://code.google.com/p/gxp/
13:27rhickeyIt looks like it could be a useful part of a Clojure web pipeline
13:27Chouserrhickey: still have the browser tab open from last time you asked.
13:28rhickeyheh
13:28Chouserbut no.
13:28rhickeyI'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:30rhickeyget for free: structural validation, escaping, whitespace removal, internationalization
13:31rhickeyeasy to use resulting objects in a Clojure servlet
13:31rhickeycould gen gxp from Clojure
13:31Chouserso you don't have to write in xml
13:31DrewRHm, I seem to remember looking at this.
13:32rhickeyright, 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:33rhickeyPlus it does the right thing by not supporting arbitrary code in pages, IMO
13:34rhickeyeach page is a function, they understand Iterable, we could pass Clojure data structures and have gxp loop tags destructure them
13:35rhickeyUsed by Google Adwords/AdSense/Checkoput/Blogger/Analytics/Reader etc
13:36abrooksrhickey: How do you feel about "_" as numeric "comma" allowing thousands, or bytes/words/longwords (hex/octal) to be visually clear?
13:36abrooksI've been meaning to ask this in the group but I'm to lazy^H^H^H^Hbusy these days.
13:36rhickeyabrooks: dunno, aren't there international standards for this stuff too?
13:37abrooksIt's part of C99.
13:37abrooksOther languages (Ruby, IIRC) support this too
13:37abrooksI don't recall that Java does.
13:38Chouserooh, we could use unicode mini spaces.
13:38rhickey1 000 000 000
13:39rhickeyha
13:39abrooksohhereitis
13:39abrooksA mini-spacebar is notably different than a space mini-bar which they might enjoy on the ISS.
13:48Chouser1 000 000
13:48tomhickey1 000 000 000
13:48Chouserjinx?
13:48tomhickeyChouser: lol, good timing
13:49Chouserbut I can't tell with this client what you actually used.
13:49ChouserI used 0x2009 "thin space"
13:49tomhickeyhair space U+200A
13:50tomhickeyhttp://en.wikipedia.org/wiki/Space_character#Table_of_spaces
13:51Chousermaybe a no-break space would be more appropriate, like U+202F
13:51rhickeyyou guys are crazy
13:51rhickey:)
13:51tomhickey:)
13:51Chouser:(
13:54rhickeythe only reason Mathematica can get away with it is that when you copy 1 000 000 000 it pastes elsewhere as 1000000000
13:54ChouserBreaking 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:55rhickeythe copy paste issue is the biggie - not being able to copy and use what printed
13:56rhickeyi.e. it should only be in the render, not the text, so ask the Vi/emacs/enclojure guys...
13:56tomhickeyrhickey: definitely. you would need IDE (render) level support for this, seeing as most output your looking at is monospaced anyways
13:57rhickeyah FORTRAN
13:57abrooksI may be in GCC and misremembering that as being in C99.
13:57abrooksrhickey: FORTRAN lives...
13:58abrooksMuch of the code written by our customers is still FORTRAN.
13:59abrooks"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:01abrooksOh, interesting. The X11 compose sequence MULTI+SPACE+SPACE is hair space.
14:01abrooksOr his it "thin" space. I can't tell.
14:02abrooksThey don't look different. And /that/ really is the problem. They all look like space in a monospace font.
14:03abrooksAnd they look the same in the handful of proportional unicode fonts that I've checked.
14:04abrooksSo, rhickey, how about those underscores?? ;-)
14:04rhickeyyuck
14:04abrooksAnd thin/mini/tiny/hair/itsy-bitsy space is not yuck??
14:04Chouserno issues with infix notation, so how about dashes? 100-000-00
14:05rhickeyplease stop :)
14:05abrooksChouser: If you're going to do numeric spaceing, stick with the semi-standard.
14:05rhickeyreally, I think this is an editor issue
14:06Chousersyntax-highlight sets of three digits in alternating colors?
14:06rhickeyif you like
14:06ChouserI don't.
14:06abrooksActually, just changing the background color of thin/hair space is probably good.
14:07ChouserThen again, I don't really have a dog in this hunt. So I'll stop talking now.
14:07DrewRCommas are already whitespace. How hard would it be to read int-comma-int before stripping them out?
14:07DrewRuser> 23,000,000
14:07DrewR0
14:08rhickeyDrewR: already playing with that idea
14:08abrooksDrewR: [1,2,3] ?
14:08abrooksI thought of that previously but ruled it out as it's an easy trap.
14:08rhickeyabrooks: right, would refine the ws/comma rule
14:08abrooks[1, 2, 3,4] (oops)!
14:09DrewRUgh.
14:09abrooksI like the comma as it is.
14:09rhickeywho's writing [1,2,3,4]?
14:09rhickeyoh
14:09abrooksActually, I don't know that I ever have.
14:09DrewRI'll agree that there shouldn't be a difference between [1,2,3] and [1, 2, 3].
14:09DrewRThat's just asking for trouble.
14:11abrooks0x239F,2B00,F269,BB14 doesn't look right. 0x239F_2B00_F269_BB14 does.
14:12abrooksThe 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:12DrewRIf I say, "java -jar start.jar" how does java know what main() to execute?
14:12DrewRInside start.jar, obviously.
14:15ChouserThe mainfest file has a Main-Class line
14:15DrewRmainfest! All main() all the time!
14:15ChouserDrewR: http://java.sun.com/docs/books/tutorial/deployment/jar/appman.html
14:15DrewR(Thanks, Chouser.)
14:16Chouserheh. sorry.
14:17abrooksBTW, neither the thin space nor hair space work at the repl.
14:18rhickey1'000'000'000
14:18Chouserthis is a fun conversation
14:19rhickey0x239F'2B00'F269'BB14
14:19Chouser1:000/000*000
14:19Chouseroh, sorry, / is taken
14:19abrooks(println 1 '000' 000) (println 1'000'000)
14:20rhickey'000' ?
14:20abrooks' is interesting, but I think _ is more common. Is there any particular reason to reject the more common _?
14:20Chouserunderscores are icky
14:21abrooksrhickey: I was trying to show that a spacing error can cause a semantic change.
14:21rhickeybut '000' would have to be meaningful first
14:22abrooksIsn't it a string?
14:22rhickey[1 2 3 4] [1234]
14:22rhickeyno, "000"
14:22abrooksOh, is ' whitespace now?
14:22abrooksThat might be fine with me.
14:22Chouser' only has meaning at the begining of token
14:22Chouser(quote ...)
14:22rhickeyspacing errors often cause a change in Lisps, since the language is space delimited
14:23abrooksChouser: Right.
14:28rhickey, 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:29rhickeybut thousands sep is super low priority for me
14:57StartsWithKhi
14:57StartsWithKi am having problems with new 'ns' function
14:58Chouserhi? what's wrong?
14:58Chouserer. "hi!"
14:58StartsWithKi have one file with code (create-ns 'neman.ufo) (ns neman.ufo) (clojure/refer 'clojure :exclude '(new))
14:58StartsWithKif I load it from repl it works fine
14:59ChouserI don't think :exclude '(new) is going to do anything. But that may not be your point...
14:59StartsWithKnow i have another file (create-ns 'neman.web) (ns neman.web (:require [neman.ufo :as ufo])) (clojure/refer 'clojure :exclude '(print println))
14:59StartsWithKi have my own 'new'
14:59StartsWithKin ufo namespace
15:00StartsWithKnow when i call neman.ufo from another file i ger
15:00StartsWithKget*
15:00Chousernew is a special form, not a member of the clojure namespace.
15:00StartsWithKclojure.lang.Compiler$CompilerException: ufo.clj:11: Unable to resolve symbol: create-ns in this context
15:00StartsWithKbut that special form is in clojure namespace
15:01StartsWithKit worked before i upgraded to new 'ns' function
15:01StartsWithKso is '.' in clojure, no problem defining my own :)
15:01StartsWithKthis didn't happen before last upgrade and switching from contrib.lib to 'ns'
15:02StartsWithKso problem is when i have one file that has create-ns that refers to another file that has create-ns
15:03Chouseryeah, ns doesn't really work very well if you want to muck around with your (refer 'clojure).
15:04Chouserit's being worked out -- a patch is submitted and being mulled over, I think.
15:05Chouseryour 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:05StartsWithKheh, i shoud stay away from trunk :)
15:06Chouserwell, you should be able to in-ns, require, and refer from boot.clj (no lib.clj needed).
15:07StartsWithKyes, i removed lib.clj and started to switch.. no lib.clj in code anymore
15:07ChouserI think you may still be able to use ns ... mulling...
15:08Chouseroh, what if you just say clojure/create-ns in both files?
15:08Chouserinstead of just create-ns
15:08StartsWithKi removed (create-ns) from file that refers to ufo.clj, that works
15:08StartsWithKclojure/create-ns or/and clojure/ns have no effect
15:08StartsWithKbut now i dont have web/print :)
15:10StartsWithKalso, why :require [bla :as ble] and :import (pkg Class), vectors for require and lists for import?
15:12StartsWithKoh, and could we have :import (org.mortbay.jetty Server .. (handle AbstractHandler ..) (nio SelectChannelConnector))
15:12StartsWithKso there would be no need to do org.mortbay.jetty org.mortbay.jetty.handler org.mortbay.jetty.nio ..
15:12ChouserI think that last suggestion was already made and rejected as too complex
15:13StartsWithKi see
15:14Chouserhm, I'm getting different error for you example because my Clojure's already patched.
15:14StartsWithKis it in trunk?
15:14StartsWithKill pull
15:14Chouserah, there we go.
15:15Chouserno, my patch is local. rhickey didn't like it quite as-is.
15:16Chouserok, using clojure/create-ns and clojure/ns in ufo.clj works for me.
15:18StartsWithKit work for me too if i (load-file "src/neman/ufo/ufo.clj") from repl
15:18ChouserI'm pretty sure ":exclude '(new)" is a no-op, so all you really need in ufo.clj is just (clojure/ns neman.ufo)
15:18StartsWithKbut if there is another file that has (create-ns 'foo) (ns foo (:require [neman.ufo :as ufo))
15:18StartsWithKthen it breaks
15:19Chouserright. I'm loading web.clj, which enters the neman.web namespace (before refer'ing clojure there), and then loads ufo.clj.
15:20Chouserwhen 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:21StartsWithKjava.lang.Exception: Unable to resolve symbol: import in this context
15:21StartsWithKclojure.lang.Compiler$CompilerException: ufo.clj:12: Unable to resolve symbol: import in this context
15:22StartsWithK(clojure/create-ns 'neman.ufo)
15:22StartsWithK(clojure/ns neman.ufo
15:22StartsWithK (:import (java.util UUID)))
15:22StartsWithK(clojure/refer 'clojure :exclude '(new))
15:26StartsWithK(clojure/create-ns 'neman.ufo)
15:26StartsWithK(clojure/refer 'clojure)
15:26StartsWithK(clojure/ns neman.ufo
15:26StartsWithK (:import (java.util UUID)))
15:26StartsWithK(clojure/refer 'clojure :exclude '(new))
15:26StartsWithKworks if I add another (clojure/refer 'clojure)
15:27StartsWithKbut it looks funny
15:28StartsWithKno.. 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:33ppjtHi all. Anyone played with compojure recently?
15:41rhickeyanyone else bothered by plural-ness of defns?
15:41kotaraknot me. But I see that there might be some potential for confusion.
15:42abrooksrhickey: Is that def+ns ?
15:42rhickeyabrooks: yes
15:43abrooksOtherwise I might suggest def-ns. :)
15:43rhickeyno other defs have -, so starting to use them now will leave people wondering in every case
15:44abrooksWell, there's defn-
15:44abrooksBut that's differnt.
15:45rhickeyright
15:45abrooksIt's also different.
15:45rhickeyalternatives welcome for the next 10 minutes
15:45abrooksdef'ns
15:45rhickeyvery funny
15:46abrooksI'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:47StartsWithKdefns will be used instead of create-ns?
15:47DrewRabrooks: That's cold.
15:48abrooksOh, shoot. No, It's not a slam. I WANT to hang out here. I just have lots of stuff to do.
15:48abrooksDrewR: --^
15:48ozzileeppjt: I've played with compojure recently.
15:48DrewRabrooks: :-)
15:51abrooksrhickey: 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:52rhickeyabrooks: not verby enough
15:52abrooksOr actually, ns-def since we already have ns-name, ns-interns, etc.
15:52kotarakIt would invert the usual defn, defmethod, etc.
15:52rhickeyns-blahs are accessors
15:52abrooksYeah, I'm slowly realizing that. Good point.
15:53ozzileeWhat wrong with (lib foo.bar.mylib) ? I'm looking at the mailing list archives but I'm not clear on that.
15:53kotarakhow about defnamespace? It's a bit longish, but we have also defmethod...
15:53rhickeykotarak: one might wonder why it is ns in all the other functions
15:54rhickeysetup-ns?
15:54Chousermkns
15:54Chouserwhere mk is short for multi-key. sorry, nevermind.
15:54rhickeyyou guys are too much today :)
15:55kotarakHow does one pronounce mkns? ;) Similar to Skrnjk. (<- That's actually a name.)
15:55kotarakmake-ns?
15:55abrooksnewns
15:56ChouserI like how declaritive defns is.
15:57abrooksI guess defns is the best though you know every new Clojure programmer will trip on that twice when the first learn Clojure.
15:57Chouser...compared to setup-ns, make-ns, mkns, etc.
15:57Chouserabrooks: how, by assuming it's plural of defn when they read code?
15:57hoeck_but defns sounds much like the plural of defn
15:57abrooksChouser: Yes.
15:58Chouserinit-ns, initns
15:58abrooksChouser: Of course I have no idea what this will look like since I've not seen defns yet.
15:58Chouserdefns will look like ns does now
15:59abrooksOh, this is a rename of ns?
15:59abrooksDrat. I was just about to suggest plain "ns".
15:59Chouser(defns net.n01se (:refer-clojure ...) (:import ...))
15:59kotarakinit-ns or make-ns or setup-ns are all ok for me. Although I like defns for the consistency for the other defs...
16:00Chouserwell, if ns becomes defns, the new ns will be almost identical to in-ns.
16:00rhickeyChouser: right, just a macro shim
16:00ChouserSo 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:01Chouseror rename in-ns to something longer and make in-ns the macro shim.
16:06ChouserI 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:21ppjtozzilee: 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:22ozzileeppjt: Heh, nope, I've got no idea. I just added a line a boot.clj to load my files under app/
16:23ppjtozzilee: Did you glob somehow, or just call load-file on some, etc.?
16:23ozzileeppjt: Just called it on the file directly.
16:24ozzileeppjt: 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:25ppjtozzilee: 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:26ozzileeppjt: Yeah me either. I've just been hammering stuff together, figuring it's all going to be evolving anyway.
16:26ppjtozzilee: right, as is happening while we speak!
16:27ozzileeIndeed.
16:28ppjtozzilee: 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:28ozzileeppjt: 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:37ppjtozzilee: 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:37ozzileeppjt: np
16:39StartsWithKppjt: just looked at compojure, looks nice and simple to use
16:40StartsWithKi have something similar, but is much limited than that
16:40StartsWithKwhy didn't you write is as a lib?
16:42ppjtStartsWithK: yup, simply running script/repl & being ready to roll is a nice way to get acquainted
16:42ppjtStartsWithK: "write it as a lib" -- you mean the so-called app part?
16:42StartsWithKyes
16:43StartsWithKi have web.clj, design is copied from werkzeug (python lib)
16:43StartsWithKjust needs to be refered
16:43ppjtStartsWithK: sorry to say I'm not exactly sure what that means -- make its own ns, load multiple resources, etc.?
16:44ozzileeStartsWithK: ppjt didn't write Compojure, if that's what you're thinking...
16:44StartsWithKit looks like i have to include my code inside your boot.clj or something?
16:44StartsWithKups, sorry
16:44StartsWithK:)
16:45StartsWithKso ozzilee your the author?
16:45ozzileeNot me: http://github.com/weavejester/compojure/tree/master
16:47StartsWithKheh, files didn't have any copyright notice so i didn't catch authors name
16:47ppjtright, no, not me -- arohner, who's been active on the clojure group mailing list...
16:49ppjthe's done a nice job; & he's keeping up with the clojure head (added the new (ns) methods, e.g.)
16:50ppjtStartsWithK: ozzilee & I were just discussing how best to load your own code
16:50StartsWithKi tried to do the same, but my need are limited to serving json
16:50StartsWithKso no html generation and such
16:51ppjtwe've both just (load-file)'d our app/*.clj files
16:52ppjtWould it seem to heavyweight even if you eliminated the libs (under lib/compojure) you didn't need?
16:53StartsWithKi don't have problem with extra code
16:53wwmorganis there a reason that (prn #"foo") outputs foo and not #"foo" ?
16:57ppjtwwmorgan: #"foo" is a reader macro for a regex pattern
16:57StartsWithKwwmorgan: #"foo" will create java.util.regex.Pattern, i think prn will use Patten.tostirin
16:58rapidohttp://www.enchiladacode.nl. another language that has immutability at its core and sits on a jvm
16:58rapidothe documentation is still a little bit rough and unfinished
16:59DrewROooh, browser-based REPL. rhickey better get right on that.
16:59abrooksIt looks like enchilada is interpreted -- it's running in an applet.
17:00abrooksDrewR: You'd have to give up JVM bytecode compilation.
17:00rapidoDrewR: i nicked the browser-based REPL from http://will.thimbleby.net/misc/
17:00StartsWithKabrooks: why?
17:00DrewR"Economical: no need for all those parenthesis." What's wrong with parens?
17:01rapidoDrewR: it forces you to use shift 9 and 0 a lot! :)
17:01DrewRrapido: Not with a decent editor. :-)
17:02DrewRrapido: This is interesting. Thanks for posting.
17:02rapidoDrewR: to be honest, to use enchilada you need a lot of parenthesis: squared, brackets, etc.
17:03abrooksStartsWithK: 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:03abrooksThe bytecode needs to be part of the original signed jar for an applet.
17:03StartsWithKabrooks: i have clojure applet for a month now
17:04abrooksAn interpreter could be added to clojure but that would.. wha????
17:04StartsWithKhttp://kreso.moo.com/gears.html
17:04abrooksStartsWithK: Okay.. how?
17:04StartsWithKgears version in clojure
17:04abrooksStartsWithK: I'm not able to resolve kreso.moo.com
17:04StartsWithKabrooks: i am lazy, i promissed month ago to write up how to do it
17:05StartsWithKhttp://kreso.mooo.com/gears.html
17:05StartsWithKit works on xp with java and i think 32-bit linux if java is configured
17:05kotarakSay 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:05abrooksStartsWithK: Ah, you provide a separate signed loader, right?
17:07StartsWithKabrooks: 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:07StartsWithKuff.. me and my english :)
17:07abrooksStartsWithK: Cool -- It's running on x86_64 Linux in a 32-bit FireFox / Sun Java 1.6.
17:08abrooksStartsWithK: That's awesome. I really have to catch up with everything that's been going on with Clojure.
17:08StartsWithKhttp://kreso.mooo.com/ has some other examples
17:09StartsWithKso, who has swing repl code :)
17:09abrooksThere is some IIRC.
17:09abrooksHm. Maybe I'm thinking of the class browser.
17:12rapidoenchilada treats code (and continuations) as immutable data
17:12ChouserI'm just now comfortable with lisp syntax. I'm not ready for postfix.
17:12rapidoas such it is very hard to compile enchilada to the metal
17:12StartsWithKi was thinking of using http://prefuse.org/ to implement something like clojure.inspector in applet, but.. time is not on my side
17:14rapidoChouser: it is just syntax
17:15rapido although prefix would be more 'compatible' with lisp
17:15Chouserbut syntax matters
17:15rapidoChouser: i hear you, but isn't this exactly why people don't like lisp? because of the syntax?
17:16abrooksI've written enough postscript to know that postfix notation fricks with my head.
17:16rapido(+ (+ 1 2) (+ 3 4))
17:16rapidoor + + 1 2 + 3 4
17:16rapidoor 1 2 + 3 4 + +
17:16StartsWithKwell i can scan first, but not second or third (clojure is my first lisp)
17:16kotarakor (+ 1 2 3 4)
17:17rapidokotarak: yep, you can't have variable arguments in enchilada
17:18rapidoonly unary and binary operators
17:18Chouserhaving to keep the argument stack in my head while reading postfix is -- uncomfortable.
17:19rapidobut is the (operator arg1 arg2 arg3 ...) idiom much used in lisp?
17:19Chouser1 2 3 4 5 + / * /
17:19rapidoChouser: don't think stacks. think term rewriting
17:19rapidoand things get i little bit more convenient
17:20Chouserrapido: yes, arities of more than 2 are common in Clojure.
17:20rapidoby the way, you can have postfix lambdas
17:20Chouserand for what it's worth, clojure has a bit more syntax than other lisps, and is more comfortable for me as a result.
17:21ChouserI imagine there are many people who would be less bothered by postfix than I am. :-)
17:21rapido4 5 + rewrites to 9. so replace 4 5 + with 9
17:22rapidoChouser: i have chosen for postfix because of the property that concatenating expressions syntactically yields valid expressions
17:24rapidoa lot of enchilada magic comes from the combining of postfix expression in various ways
17:25Chouserinteresting. Do all functions really take exactly 1 or 2 args?
17:25rapidoyes
17:26rapidobut you can create expression dynamically
17:26kotarakI'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:26rapidofor instance: [1;2;3;4] [5;6;7;8] | [*] * yields
17:26rapido[1;2;3;4] [5;6;7;8] | [*] *
17:26rapidoyields: [1 5 *;2 6 *;3 7 *;4 8 *]
17:28rapidokotarak: if enchilada was impure, then term rewriting would have this equational property
17:29rapidokotarak: other than that, it is just about syntax
17:29rapidowould <- would not
17:31rhickeyrapido: I missed the beginning of this thread - was there a Clojure aspect originally?
17:31rapidorhickey: like clojure, enchilada has immutability at its core and is built on top of a jvm
17:32rapidoother than that, i'm afraid there is no resemblance
17:34rapidoi am a great supporter of clojure because it has immutability as the default
17:35rapidoenchilada is more radical in that *everything* is immutable
17:35kotarakAs in Haskell?
17:35rapidothat said, it is a research language. my goal is to see how far you can go with immutability
17:35rapidokotarak: unsafePerformIO?
17:37rapidokotarak: and haskell doesn't have call/cc nor does it treat code as data
17:37kotarakDon't know much about Haskell. Just some basics. But unsafePerformIO sounds like the dark side.
17:37kotarakrapido: Does it need call/cc or does it have to tread code as data?
17:37kotaraks/tread/treat/
17:38rapidoenchilada can be compared to 'pure lisp': http://en.wikipedia.org/wiki/Lispkit_Lisp
17:39kotarakIt 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:41rapidokotarak: alternatively, in clojure, you could pass the world in a immutable structure like vector or hashmap, instead of using monads
17:44ChouserClojure specically doesn't pretend the world is immutable. Instead it makes it easy to manage that mutability well.
17:44rapidoremember, you can 'change' worlds MVCC style
17:44rhickeyrapido: then everyone takes turns for their turn with the world, Clojure's reference and agent sets are essentially worlds with better concurrency
17:45rapidorhickey: no need to take turns. everyone can create new worlds
17:45rapidoand merge worlds to reach consensus
17:46rhickeymerge is same problem
17:46rhickeysingle coordination point
17:46rhickeynot practical
17:46rhickeydoesn't scale
17:46rapidorhickey: no, it does scale much better than locks
17:47rapidolook at git
17:48rapidoyou can reach consensus with different merging strategies, and optimistically
17:48rapidolet's say n threads create n worlds
17:49rapidothen 0.5n threads pair up independently and concurrently to merge their worlds
17:50rapidoafter that 0.25n threads pair up,... etc until consensus is reached
17:50rhickeyall that consensus is coordination
17:50rhickeyhaving a single world makes for larger-than-needed granularity
17:50rapidosure
17:50rhickeysplit upt the world and essentiall you've got Clojure's refs
17:51rhickeyassoc == merge
17:51rhickeycommute etc
17:51rhickeyfine granularity
17:51rhickeycoordinate only on conflict
17:52rhickeyI doubt you could put GIT's system into in-proc and compete with STM
17:52rhickeywithout it becoming STM
17:52rapidorhickey: but git would compete pretty good with distributed databases
17:53rapidoenchilada is more in the 'distributed database' hemisphere than in the 'multi core' hemisphere
17:54rapidoalthough enchilada gains some speed on multi cores because it is multi threaded
17:54rhickeyI 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:55rhickeytransaction in particular are a problem
17:56rapidorhickey: it is true that DHTs are document centric, but why do you need transactions?
17:58rhickeybecause that's how systems work - n-operations constitute one unit of work, the classic bank-account transfer problem etc
17:59rhickeyRDBMS, Mnesia, Scalaris - all recognize that need, not a DB without it
18:00rapidobut you can't you do transactions on top of MVCC and immutable structures?
18:01rapidothe only thing you need is the durability (D) guarantee
18:01rhickeyDistributing it is the problem
18:01rhickeyPostgresql and Oracle are MVCC
18:02rapidorhickey: are you referring to two phase commit?
18:03rhickeyThat's one technique, Scalaris has quite another
18:03rhickeyI'm not writing a distributed DB
18:04rhickeyClojure's STM could most easily get distributed with something like Terracotta
18:06rhickeyThe 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:07rapidorhickey: let me point you to a database that uses immutable structures: http://www.herodotus.biz/DB_Features.html
18:08rapidoi believe it is used for GIS applications. According to GIS the world is constantly changing! :)
18:10rhickeyI'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:11rhickeyor more specifically, online, since everyone logs their DB
18:11rhickeyupdate is not in the relational model
18:12rapidorhickey: herodotus doesn't use a log. you can jump instantly to the past and compare the past with other versions
18:13rapidolog transacted databases don't scale: the log will alway be the bottleneck
18:13rhickeythat'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:13rapidoalway <- always
18:16rapidobut log transacted databases *are* a different kind than databases such as herodotus
18:16rhickeynot really
18:18rapidothrowing away history is easy
18:19rapidojumping back in history is not
18:19rhickeykeeping it online is expensive, especially when it comes to indexing and queries
18:21rapidorhickey: that's why i have built enchilada: to show that keeping history (indexes, queries) can be done relatively 'cheaply'
18:21rhickeymany 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:23rapidorhickey: i know what you are saying: i work at a bank. we keep lots of (time-series) history. :)
18:23rhickeydon't get me wrong, I love the idea of keeping everything, but there are tradeoffs with keeping it online
18:24rapidoat the bank we are not allowed to throw away data because of SOX compliancy rules
18:24rapidowhat to do? :)
18:25rapidorhickey: good to know you like to keep things too.
18:26rapidorhickey: it has been nice chatting to you... i have to run.... later