Leiningen plugins don't run in the project's environment, so they don't
have access to the project's code or dependencies.

In some cases you want to evaluate code in the project's environment, and
Leiningen provides the eval-in-project function, which evaluates a quoted
expression in the context of the project.

The functions in Lein-Ring that return syntax-quoted expressions are for
generating a form to be evaluated with eval-in-project. In this case, to
start a web server or to compile a war file.

- James


On 13 June 2013 07:08, James Xu <xumingmi...@gmail.com> wrote:

>  Let me translate:
>
> Hi all,
> I am reading lein-ring's source code, and I find that the many
> functions(defn) uses the syntax quote(`), e.g.
>
> (defn load-namespaces
> [& syms]
> `(require
> ~@(for [s syms :when s]
> `'~(if-let [ns (namespace s)]
> (symbol ns)
> s))))
>
>
> My intuition is that syntax quote better be used in macros which is invoke
> during compiling. What's reason/benefit to use syntax quote in functions
> which will are invoked at runtime?
>
> --
> xumingmingv
> Github: https://github.com/xumingming
> Weibo: http://weibo.com/64398966
> Sent with Sparrow <http://www.sparrowmailapp.com/?sig>
>
>  On 2013年6月13日Thursday at 下午12:39, stream wrote:
>
> Hi all
> 我在看 lein-ring插件源码时,发现很多 语法引用符号 ` 都用在defn里。
> `(do ~(start-nrepl-expr project) ~(start-server-expr project))
>
> (defn load-namespaces
>  [& syms]
> `(require
> ~@(for [s syms :when s]
> `'~(if-let [ns (namespace s)]
> (symbol ns)
> s))))
>
>
> 我的直觉是这些最好是用在编译期的宏里。
>
> 用在运行期的的函数里是什么意思呢, 比较愚笨,希望高手解答。谢谢
>
> --
> --
> 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
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>  --
> --
> 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
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to