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
        ))

It doesn't work, any advice?

Limux,
Regards

On 8月4日, 下午11时53分, limux <liumengji...@gmail.com> wrote:
> Thanks for your very very helpful help.
>
> Another question is:
>
> defmacro defmodel [model-name]
>   `(let [sym-model-name ~(symbol (str "app.model." model-name))]
>       (do
>
> On 8月4日, 下午3时42分, Meikel Brandmeyer <m...@kotka.de> wrote:
>
>
>
> > Hi,
>
> > On Aug 4, 9:32 am, limux <liumengji...@gmail.com> wrote:
>
> > > i very confused var-quote, hope someone explain it more detailed than
> > > the clojure.org's, thks.
>
> > Global values are stored in so-called Vars. Symbols are used in
> > program code to link to those Vars, ie. to basically give them a name.
> > So the addition function is stored in a Var named +. So whenever the
> > compiler sees the symbol + it looks up the Var + refers to and gets
> > its value, the actual addition function. Now, if you actually want to
> > access the Var itself, not the function it holds, you need to somehow
> > tell the compiler this intent. And this is exactly what #' does. When
> > you write #'+ in your code, you tell the compiler: "Look. I want the
> > Var named +, not its contents."
>
> > This is useful to extract metadata about the value in the function,
> > like docstrings, argument lists, type hints, etc.
>
> > Hope this helps.
>
> > Sincerely
> > Meikel

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