2010/8/4 limux <liumengji...@gmail.com>:
> Thanks for your very very helpful help.
>
>  I want to do something like rails's activerecord orm,
> The following is the primary idea:
>
> (defmacro defmodel [model-name]
>   `(let [temp# ~(symbol (str "app.model." model-name))]
>       (do
>           ;; create the namespace according to model name
>           (ns temp#)
>           ;; define some relevant functions in the ns created
> previously.
>           (defn find [] (prn "hello"))
>           ;; over
>        ))
>

This is not what you want.
On a model named thing it evaluates to :
(let [tempXXX app.model.things]
 (ns temp#).....
This is not good.

You likely want
(let [ns-symbol (symbol ....)] ; I have my symbol, I can return a term
 `(do
    (ns ~ns-symbol)
    (defn hello [] ....))))

Is it working better?

You might want to have a look to already existing Rails like framework
in Clojure.
(I don't know well which parto of any is the ActiveRecord part, so I
won't tell any name, but there is a thread about web development
on this maling list that could be a could place to start.)

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to