Re: On Lisp => Clojure

2009-07-18 Thread Meikel Brandmeyer
Hi, Am 19.07.2009 um 06:06 schrieb Rowdy Rednose: (defn db-push ([key val] (db-push key val *default-db*)) ([key val db] (swap! db assoc key (cons val (@db key) But I think it's broken in the face of concurrency, as I capture the value of @db at the time of the call to the function s

Re: Bug in VimClojure indentation logic?

2009-07-18 Thread Meikel Brandmeyer
Hi, Am 19.07.2009 um 01:20 schrieb James Reeves: You should fine that indentation is messed up. I suspect this is because the GetClojureIndentWorker function in indent/clojure.vim uses "normal w" amongst other commands. Anyone who has altered keys like w or l from their default bindings will ru

Re: On Lisp => Clojure

2009-07-18 Thread Rowdy Rednose
On Jul 19, 12:53 pm, Richard Newman wrote: > > * Can the body of the db-push function be simplified? > > I think so. Untested: > > (defn db-push >   ([key val] (db-push key val *default-db*)) >   ([key val db] >      (swap! db assoc key (cons val (db key)) If I add an @ it runs: (defn db-pu

clojure plugin for grails

2009-07-18 Thread Wilson MacGyver
Jeff Brown has released a clojure plugin for grails. http://grails.org/plugin/clojure So you can now write clojure code in grails app. -- Omnem crede diem tibi diluxisse supremum. --~--~-~--~~~---~--~~ You received this message because you are subscribed to t

Re: On Lisp => Clojure

2009-07-18 Thread Richard Newman
> * Is "function overloading" the idiomatic way to implement default > params in clojure? Typically, I think so. You could also use multimethods, but that might be unnecessary flexibility. Another approach is to emulate keyword arguments: (defn foo [x y & args] (let [{:keys [baz bar]} (app

On Lisp => Clojure

2009-07-18 Thread Rowdy Rednose
Hi all, in my quest to learn clojure (and lisp in general), I'm currently trying to translate some the "On Lisp" code to clojure. The first couple of functions and macros in Chapter 19 "A Query Compiler" read: (defun make-db (&optional (size 100)) (make-hash-table :size size)) (defvar *defau

Re: "let" a variable number of bindings

2009-07-18 Thread Rowdy Rednose
As I said, the example was stripped down for simplicity, and that simple version doesn't make much sense other than for communicating my problem. My real val-fn is not a map, it's indeed a couple of functions, applied to some data that's passed in. But the result of that acts like a map: it retur

Re: Bug in VimClojure indentation logic?

2009-07-18 Thread James Reeves
On Jul 18, 6:47 pm, Meikel Brandmeyer wrote: > I don't see this here. > > Which vim are you using? > Which VimClojure? > Does it happen also in a different file? > Can you send me an example file where this happens? I cleared down my Vim settings back to the defaults, and indentation started wor

Re: Bug in VimClojure indentation logic?

2009-07-18 Thread Richard Newman
> Is this just me, or does anyone else have this issue? I haven't had your exact problem, but sometimes it seems to incorrectly maintain depth at the top level, so I'll end up with something like (defn foo [x y] ...) (defn bar [a] ...) (defn baz [...] ...) | < cursor goe

Re: "let" a variable number of bindings

2009-07-18 Thread Meikel Brandmeyer
Hi Jarkko, Am 18.07.2009 um 22:02 schrieb Jarkko Oranen: That looks a lot like map destructuring, though: (let [{:keys [a b c]} {:a 1 :b 2 :c 3}] (list a b c)) -> (1 2 3) Yes. But val-fn might also be exactly that: a function which gets the value by some others means than a map. I'm not su

Re: "let" a variable number of bindings

2009-07-18 Thread Jarkko Oranen
> user=> (macroexpand-1 '(let-coll [a b c] {:a 1 :b 2 :c 3} (println a b   > c))) > (clojure.core/let [val-fn__23 {:a 1, :b 2, :c 3} >                     a          (val-fn__23 :a) >                     b          (val-fn__23 :b) >                     c          (val-fn__23 :c)] >    (println a

Re: Loop, Recur, and Binding

2009-07-18 Thread Meikel Brandmeyer
Hi Tim, the issue is already in the tracker: http://www.assembla.com/spaces/clojure/tickets/31 Sincerely Meikel smime.p7s Description: S/MIME cryptographic signature

Re: Loop, Recur, and Binding

2009-07-18 Thread Stuart Sierra
Hi, Tim, I'm not 100% certain what is going on here, but I do know that, in general, binding and loop/recur should not be mixed. "recur" is not true recursion -- it's more like a GOTO. The "binding" macro establishes thread-local bindings using the static methods clojure.lang.Var/pushThreadBind

Re: "let" a variable number of bindings

2009-07-18 Thread Meikel Brandmeyer
Hi Rowdy, Am 18.07.2009 um 20:35 schrieb Rowdy Rednose: your negative answer actually helped me analyze my problem better and get the distinction run time / expansion time straight. I figured that the names of the bindings are already there at expansion time and it's only the values that I need

Re: "let" a variable number of bindings

2009-07-18 Thread Rowdy Rednose
Thanks Meikel, your negative answer actually helped me analyze my problem better and get the distinction run time / expansion time straight. I figured that the names of the bindings are already there at expansion time and it's only the values that I need to retrieve at run time. So this version

Re: Bug in VimClojure indentation logic?

2009-07-18 Thread Meikel Brandmeyer
Hi, Am 18.07.2009 um 18:07 schrieb James Reeves: On Jul 18, 4:54 pm, James Reeves wrote: Does anyone else suffer from occassional incorrect indentations in VimClojure? It looks like VimClojure is preferring the indentation layer of a previous set of [] over the current set of (). A quick u

Re: Bug in VimClojure indentation logic?

2009-07-18 Thread James Reeves
On Jul 18, 4:54 pm, James Reeves wrote: > Does anyone else suffer from occassional incorrect indentations in > VimClojure? It looks like VimClojure is preferring the indentation > layer of a previous set of [] over the current set of (). A quick update; it looks like it's doing it even without t

Bug in VimClojure indentation logic?

2009-07-18 Thread James Reeves
Hi folks, Does anyone else suffer from occassional incorrect indentations in VimClojure? It looks like VimClojure is preferring the indentation layer of a previous set of [] over the current set of (). For example: (defn foo [x] (+ x 1)) When I hit enter after the se

Re: clojure-contrib

2009-07-18 Thread Wilson MacGyver
Thanks, started tracking the 1.0 compat branch of clojure.contrib On 7/17/09, Meikel Brandmeyer wrote: > > Hi, > > On Jul 17, 6:21 am, Wilson MacGyver wrote: > >> Can clojure-contrib be used with clojure-1.0? Or in order to use it, I >> also >> need to build clojure from github? > > There is a

Re: VimClojureBox

2009-07-18 Thread Meikel Brandmeyer
Hi, Am 15.07.2009 um 05:12 schrieb e: i vote for zero config, option 1. I'm not a big fan of option 1, because you have to duplicate all efforts to install Vim on the different systems. The Windows installers and MacVim show, that this is not trivial, especially if you want to provide python,

Re: VimClojureBox

2009-07-18 Thread Meikel Brandmeyer
Hi, Am 14.07.2009 um 22:35 schrieb Justin Johnson: That sounds reasonable to me. I would only be able to work on the Windows installer but I'd be willing to collaborate with others to incorporate other installers into the project. I can try on a Mac installer. I'm not that something like

Slime - Clojure Installation

2009-07-18 Thread Glen Foy
Hi, I'm trying to set up Clojure, Slime and Aquamacs on a powerbook. I obtained http://github.com/technomancy/clojure-mode M-x clojure-install produces this error: Checking out source... this will take a while... Loading cl-macs...done Initialized empty Git repository in /Users/gef/src/clojure/

Re: "let" a variable number of bindings

2009-07-18 Thread John Harrop
On Sat, Jul 18, 2009 at 1:22 AM, Meikel Brandmeyer wrote: > Using eval is not really a solution. > > (def foo '[a 1 b 2]) > (let-coll foo ...) > > will probably work with eval, but > > (let [foo '[a 1 b 2]] > (let-coll foo ...)) > > will not. > No, for that you need to make the "macro" run-time

Re: "let" a variable number of bindings

2009-07-18 Thread John Harrop
On Fri, Jul 17, 2009 at 11:52 PM, Rowdy Rednose wrote: > > How can I lexically bind names like "let" does in a macro, when names > and values for those bindings are passed in? > > This here works fine when I pass a literal collection: > > (defmacro let-coll > [coll & body] > `(let ~(vec coll) ~.