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
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
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 []]
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
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
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
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
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
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