#clojure logs

2008-09-11

07:47StartsWithKi was just reading results of latest poll
07:47StartsWithKone of the thing metioned was cpan like repository
07:47StartsWithKthat sounds like realy good idea
07:47StartsWithKso, to share how i started to build my own app
07:48StartsWithKfirst i was using ant, but that didn't work that great, no dependancies to extrenal jar.. i had to download them all to lib/ and sync them manualy
07:49StartsWithKthen i moved for short time to buildr (ruby make like system for java, part of apache incubator)
07:49StartsWithKit supports maven repositories, so that worked great
07:49StartsWithKbut you have to install ruby/jruby and buildr, and that could be a pain for most users
07:50StartsWithKso now i am at ant+ivy, ivy is dependancy tracker (part of apache)
07:51StartsWithKwhy i like it is, it just resolves dependanicies, it supports its own repository format, maven repositories, or general urlresolvers
07:51StartsWithKalso, there is no need to install ivy manualy, it can be done from ant build
07:52StartsWithKonly thing missing at the moment is maven/ivy repository with clojure and clojure-contrib, then you wouldn't need to distribute clojure.jar with your own lib
07:54cemerickYeah, we use ant+ivy as well. Although, we only use our own internal repo, and we'll always distribute a "full stack", with all dependencies included.
08:00StartsWithKi think ivy would be a good choice
08:01StartsWithKmaven looks to much java orientated, and that didn't fit that well for genclass and similar thing for me
10:32achim_phi! is there an easy way of turning a java.util.Enumeration object into a (lazy) seq?
10:33rhickey_achim_p: enumeration-seq
10:34rhickey_(find-doc "Enumeration") finds it
10:36achim_poh, embarrassing ;-) thanks for the pointer!
10:36leafwrhickey_: I really like the 'new' way of calling static methods and fields. You have finally captured what they really are: unbound functions within a namespace. Calling them like other clojure namespaces, with '/', is just brilliant.
10:37leafwit's easier to explain to a novice that a static method is by using clojure, than by using java itself.
10:37leafws/that/what/
10:38rhickey_leafw: just need to get everyone to transition to the new style...
10:38leafwI will update my wikis.
10:47leafwit's done/
10:56Chouserrhickey_: were you serious about gen'ing JS just like AOT JVM bytecode? Or would macroexpand still be a useful approach.
10:57rhickey_AOT Java/JavaScript _source_
10:57Chouseroh, Java source?
10:58rhickey_Right, like I used to do. But that is less compelling than JS
10:59blackdog_that sounds really good to me, finally client and server code in one decent language :)
10:59Chousernaw, there are lots of people who want AOT Java. They'd probably be content with Java source.
10:59rhickey_as I said before, AOT Java for what purpose? For startup speed, I have ideas that won't require AOT
11:00Chouseranyway, my real question is how you'd recommend doing the macroexpand of interior expressions, assuming macroexpand is a useful approach.
11:01rhickey_the idea is cal Compiler.analyze as done now - that does all of the heavy lifting. Then just to emitJS per expression type
11:01rhickey_just do
11:02blackdog_and if Chouser has finished the clojure persistent structures by then we're good to go ;)
11:05Chousermy goal (dream?) is to get boot.clj auto-gen'ing to JS.
11:06ChouserThat will require some stubs/wrappers for a few Java classes. StringBuffer, for example.
11:09ChouserCompiler/analyze is private
11:13rhickey_Chouser: so are all of the expression classes, this will require some cooperation from Clojure :)
11:30Chouserdoesn't analyze do too much? like looking up vars?
11:31rhickey_Chouser: I don't know how you compile without resolving names
11:33ChouserI was imagining a literal translation from symbols, and then allowing the JS to do resolving.
11:34rhickey_what a var becomes in the generated output is still open
11:35Chouser(Compiler/analyze Compiler$C/STATEMENT '(def map "test"))
11:36Chouserthat throws an exception. Hm, maybe I just need to make sure I'm in the 'clojure namespace like it expects.
12:05ChouserIt's also doing static method resolution. I was assuming I'd want host syntax to access JS classes and methods.
15:19Chouserwould it be inappropriate for me to put half-baked non-functional peices of clojurescript into the clojure-contrib repo?
15:19Chouseror even pieces?
15:23rhickey_Chouser: sure, go ahead - have to start somewhere!
15:26Chouserwell, I just didn't know if clojure-contrib was the right place to dump it.
15:27ChouserDon't want to scare the newbies. ;-)
15:27rhickey_People pick and choose from contrib right? Not one bundle?
15:28ChouserI dunno about other, but I "svn up" the whole thing, and use (ns (:require ...)) to pick out what I want to use.
15:28Chousers/other/other people/
15:29rhickey_Ok, well, just put work-in-progess comments in there. I don't think we need another project
15:31Chouserok
15:35cemerickfwiw, we bundle all of clojure.contrib into our jars. I suppose it's only a matter of time before we need to establish exactly what we use and what we don't.
15:36cemerickit certainly seems silly to have separate projects at this point
15:36rhickey_cemerick: trusting souls :)
15:37cemerickrhickey_: I've been standing on the shoulders of giants forever; I'd be fiddling with microcode if I didn't trust others implicitly. :-)
15:38ChouserI'll put it in src/clojurescript, so if you're bundling src/clojure/contrib you're already set to skip this stuff.
15:39Chouseror maybe I'll put it in clojurescript right at the top level (instead of in src)
15:42cemerickwow, defvar and friends put the docstring *last*
15:42StartsWithK_maybe you could create your own branch?
15:47rhickey_no branches please
15:50abrooksBranching in Subversion is just as convenient as maintaining another family on the side. I recommend against it.
15:51abrooksrhickey_: I've been thinking of writing up a plan to use Mercurial (or git) for Clojure. Is that a waste of time or something that would be helpful.
15:51rhickey_abrooks: for me to use mercurial?
15:51abrooksWell, yes, you would be part of that. :)
15:53rhickey_I don't think so. there's nothing wrong with the SVN at present, and those that want to see it via git can
15:53abrooksWe get the most benefit when the main repo (rather than just a mirror) is Mercurial.
15:53rhickey_how so?
15:54abrooksRight now we have a single, linear history. If people are tracking changes on the side, rebasing and other activities are a lot more annoying. Particularly if some of their changes are accepted upstream and some aren't.
15:54abrooksPart of the writup would be a rationale of why it would be beneficial.
15:55Chouserabrooks: you'll be fighting a relative derth of IDE integration, compared to svn.
15:56abrooksWhen I say Mercurial, I also mean git. I think either would be fine (having used both) though I think Mercurial is sufficiently easier for Clojure's usage.
15:56rhickey_abrooks: feel free to write it up, but I am strongly inclined to stick with large hosts like SF or Google code, and I care about IDE support
15:56abrooksChouser: tortiose-hg is out there.
15:56abrooksI'll be most inclined to spend the time if I think the chances are good.
15:57StartsWithK_netbeans also has mercurial support now
15:57abrooksIDE/GUI tools -- noted. That's not something I generally care about but I think the state of the world is good. I'll have to check in detail.
16:02cemerickAre any super-automagic yet reliable ways to have a svn repo mirror a git repo? If clojure goes to git/hg (and yes, I know rhickey_'s not super-interested, but still), I'll need to put together something to keep me in the sane (for me) world of svn.
16:07abrooksProviding a flat svn mirror of git/hg is not a problem -- you just lose some information that Subversion has no way of storing.
16:07abrooksTailor works quite well from what I hear: http://progetti.arstecnica.it/tailor
16:07abrooksYou just want to keep the svn changes flowing out from git or flowing into git. Bi-directional sync gets nasty.
16:31Chouserbi-directional sync with git when the canonical repo is svn is not a problem.
16:35abrooksTrue but I think that's an odd way to do things. Can you properly publish a git-svn repo? I've not tried.
16:35arohnerit's pretty straight forward as long as your git history isn't too complicated
16:35abrooksWell, you're still missing out on all the merge history from the canonical svn repo, anyways.
16:35arohnerwhen using git-svn, bidirectional works well both ways. just treat git like svn
16:35arohner:-)
16:36arohnerthe svn merge history is represented in git too, IIRC
16:37abrooksarohner: But manual merges done on the Subversion side of things aren't shown with merge history (at least for Subversion 1.4). They're just ugly checkins.
16:39arohnerhuh. I either haven't run into that, or haven't noticed
16:39arohnerI do know that complicated merges on the git side before going into svn are messy
19:55Chouserclojurescript macros get expanded by the JVM
19:55ozzileeSo, today I notice that the half-assed site I put up ages ago is the number one google result for "scheme clojure". Apparently the scheme people aren't too interested in clojure :-)
19:56rhickeyChouser: is that a question? (just arrived)
19:57Chousermacros can call any functions defined so far, which means all functions must be defined in the JVM, doesn't it?
19:57Chouserbut of course some functions are going to refer to JavaScript objects, so those function will fail to compile on the JVM
20:01rhickeyno, the only functions that run at compile time are the ones needed to _expand_ the macro, not the ones it expands into. The former are likely to already exist in Clojure
20:02rhickeyparenscript works the same way - macros are written in and run in CL, but expand into JS
20:04ChouserI'm trying to process boot.clj, but of course it defines functions and then defines macros that use them.
20:04rhickeyprocess boot.clj how?
20:05Chouserrunning each top-level form through Compiler/analyze and then translating the results into JavaScript.
20:07Chouserfor now I'm eval'ing each in a 'tmp namespace as well as translating to JavaScript. That should work for all of boot.clj.
20:08ChouserI guess for user-provided forms I'll rely on the user deciding which will be for the JVM and which will be run through formtojs.
20:09rhickeyI'm not sure what your objective is. I;d shoot for having a fully-loaded Clojure 'compile' a file to JS on demand. It's not at all like the bootstrap of Clojure. I wouldn't expect to have compilation capabilities at all in JS
20:09rhickeythat compile could ignore macros
20:11rhickeyall you need are emitJS functions for all of the expr types (ok, not all, but that's the essence) If we want to end up with a shareable boot.clj there will need to be more wrapping of Java, so everything goes through RT or something
20:11ChouserHere's the kind of expression I'd expect to translate to JS: (let [[a b] foo] (.getElementById document "x"))
20:11rhickeyno problem
20:13rhickeya simple flag could keep the compiler from trying to resolve types - all calls look reflective and instance
20:13Chouserah, ok, that's one set of problems. That's a flag that doesn't exist, I assume?
20:14rhickeyyeah, you're not going to be able to glom on a JS compiler without some support :)
20:14rhickeyunless you write a full compiler, which would be a lot of work...
20:14Chouseroh, clearly. I've already got a giant patch on Compiler.java
20:15ChouserFor now all I've had to do is make a bunch of classes public, final fields public, and added some final accessors.
20:15rhickeyare you adding emitJS methods to the Exprs?
20:16Chouserno, I've got a multimethod named tojs
20:16rhickeythat's fine
20:17ChouserActually, I've got it working through boot.clj up to the first recur.
20:17rhickeydoes JS have the comma operator?
20:17Chouseryes
20:18ChouserI haven't needed it yet. I guess that would be a alternate way to do BodyExpr
20:18rhickeyright, that's good. dropping that from C was a huge mistake for Java/C#, makes using them as compilation targets much harder
20:18rhickeyIt seem the way to do BodyExpr, no?
20:19Chouserit would have been easier: return e1,e2,e3; But I just did: e1;e2;return e3;
20:19rhickeyYou realize by doing this you are going to completely understand Clojure...
20:20Chouserexcept for the Magical STM part :-)
20:20rhickeyChouser: what if it's in an expression position?
20:20rhickeyyou can't say return
20:21Chouseryeah, I may need to change BodyExpr. so far it's only been used as the body of what has ended up a JS function.
20:21Chouserbut recur's tricky.
20:21rhickeyyou need to pay attention to the context stuff, it deals with the expr/statement dichotomy
20:21rhickeyesp. important when generating source
20:22ChouserMy only thought so far is to put a function in a while loop, and have the function return an array of args to be supplied to the next function call.
20:24rhickeyno, you emit a function that has the while loop in it, preceded by locals, and it just sets the locals each iteration
20:24rhickeyat least JS has closures
20:25rhickeyor resets the args
20:26Chouserbut the args are set in parallel -- the inits for the next iteration all refer to the old values.
20:27rhickeyuse temps
20:27Chouserok
20:29Chouseryeah, I'm using JS closures for let blocks
20:29rhickeyjust have to be careful about JS broken block scope
20:30rhickeyClojure uses stack as temp area for recur
20:31Chousercareful about JS broken block scope when choosing temp names?
20:32rhickeyand local names
20:32rhickeylet names
20:38Chouserah, bother. I can't use a JS function for let blocks, because recur needs to pop right past them.
20:39rhickeywhat's wrong with block + locals for let?
20:48ChouserJS doesn't give me a new scope for a block, but locals in a let need to be able to shadow any outer scope
20:49rhickeyshadowing is a compilation detail, just rename
20:49rhickeythat's what I was talking about before
20:49lisppaste8jamii pasted "cells" at http://paste.lisp.org/display/66688
20:50lisppaste8jamii pasted "cells java" at http://paste.lisp.org/display/66689
20:52Chouseroh, you mean keep track of any names that will be shadowed, store the old values in temps, and restore them after leaving the let?
20:53rhickeyif the clojure source says x, the JS could say fred (or more likely x1), a nested x would be x2, etc
20:54rhickeyso the nested refs target different js locals
20:55Chouseroh, I see.
20:55ChouserYou can probably guess at this point that I've never written a compiler.
20:56rhickeyyou don't need to track anything, the compiler already 'unique-izes' locals
20:56Chouserok, great.
20:56rhickeyjust give each LocalBinding a unique name
21:09Chouseroh, ignore the name field in LocalBinding and make up my own for each?
21:11rhickeyChouser: you might want to base it on name for debugging purposes
21:11rhickeybut yes, make each unique
21:13ChouserI'll need to store that mapping somewhere -- I guess I may need to pass that along as context as I process the tree.