|please explain where and why to use var-quote||limux||8/4/10 12:32 AM|
|Re: please explain where and why to use var-quote||Meikel Brandmeyer (kotarak)||8/4/10 12:42 AM|
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.
|Re: please explain where and why to use var-quote||limux||8/4/10 8:53 AM|
Thanks for your very very helpful help.
Another question is:
defmacro defmodel [model-name]
`(let [sym-model-name ~(symbol (str "app.model." model-name))]
|Re: please explain where and why to use var-quote||limux||8/4/10 9:17 AM|
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))]
;; create the namespace according to model name
;; define some relevant functions in the ns created
(defn find  (prn "hello"))
It doesn't work, any advice?
|Re: please explain where and why to use var-quote||Nicolas Oury||8/4/10 9:24 AM|
2010/8/4 limux <liumen...@gmail.com>:
This is not what you want.
You likely want
Is it working better?
You might want to have a look to already existing Rails like framework