Re: Binding dynamically created symbols in the lexical context.

2008-08-29 Thread budu
Well, I just find out there was an obvious bug in the code I posted previously. Here's the correct expand-parser-body: (defn- expand-parser-body [body s] (let [rec (fn [r p xs] `(let [~r (~p ~s) ~s (second (first ~r))] (if (= 0 (count ~r)) ~r

Re: Binding dynamically created symbols in the lexical context.

2008-08-29 Thread budu
Thank you very much! Your trick worked and it even made me realize that the match-forms function is not even required. I've replaced it by a much more simple is-match? function and completely overhauled the match macro. Here's the new code with your corrections, some other improvements and an exa

Re: Binding dynamically created symbols in the lexical context.

2008-08-26 Thread Chouser
On Sun, Aug 24, 2008 at 6:02 PM, budu <[EMAIL PROTECTED]> wrote: > > Well, for now only the value s used by the parser macro is really > needed. I think you misunderstood me, but I'm not too sure. Anyway, here's an attempt: (defn match-forms [p s] (if (= '_ p) [] (loop [p p s s vars []]

Re: Binding dynamically created symbols in the lexical context.

2008-08-24 Thread budu
Well, for now only the value s used by the parser macro is really needed. But then it will be less general, the parser macro will not be able to access the lexical scope. I'm still not sure if I really need that, but I like writing code that have some orthogonality. Let's say I use only a simple

Re: Binding dynamically created symbols in the lexical context.

2008-08-24 Thread Chouser
On Sun, Aug 24, 2008 at 1:33 PM, budu <[EMAIL PROTECTED]> wrote: > > Here is the match-forms function: Thanks. Now that I can see some concrete examples, ... I'm stumped. Your binding form isn't computed until runtime, by which time the macros are all expanded. There may be a way to have the b

Re: Binding dynamically created symbols in the lexical context.

2008-08-24 Thread budu
Here is the match-forms function: (defn match-forms [p s] (if (= '_ p) [] (loop [p p s s vars []] (cond (and (= 0 (count p)) (= 0 (count s))) vars (= 0 (count s)) false true (let [fp (first p) rp (rest p) fs (first s) r

Re: Binding dynamically created symbols in the lexical context.

2008-08-24 Thread Chouser
On Sun, Aug 24, 2008 at 12:46 PM, budu <[EMAIL PROTECTED]> wrote: > > Hi, I've been having a great time using Clojure in the last few month. > But this week I've come accross something that is blocking me. I'm > trying to write a very simple pattern matching macro to use in other > macros for matc

Re: Binding dynamically created symbols in the lexical context.

2008-08-24 Thread Parth Malwankar
budu wrote: > Hi, I've been having a great time using Clojure in the last few month. > But this week I've come accross something that is blocking me. I'm > trying to write a very simple pattern matching macro to use in other > macros for matching forms. I've based my macro on one posted in this

Binding dynamically created symbols in the lexical context.

2008-08-24 Thread budu
Hi, I've been having a great time using Clojure in the last few month. But this week I've come accross something that is blocking me. I'm trying to write a very simple pattern matching macro to use in other macros for matching forms. I've based my macro on one posted in this group by James Reeves