diff options
author | Dmitrii Kuznetsov <torgeek@gmail.com> | 2021-02-22 18:42:33 +0300 |
---|---|---|
committer | Dmitrii Kuznetsov <torgeek@gmail.com> | 2021-02-22 18:42:33 +0300 |
commit | e09fefaa3e78c645c720c86391e3f96d257be8a9 (patch) | |
tree | 0ff8b235e3e707125e2b11d5268ad085832355cb /clojure-macros.html.markdown | |
parent | f4c740839d78f797e9cbcfa1eb0483ac0ea45501 (diff) | |
parent | bc8bd2646f068cfb402850f7c0f9b1dbfe81e5a0 (diff) |
Merge branch 'master' of https://github.com/torgeek/learnxinyminutes-docs
Diffstat (limited to 'clojure-macros.html.markdown')
-rw-r--r-- | clojure-macros.html.markdown | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/clojure-macros.html.markdown b/clojure-macros.html.markdown index d74f77cf..6154d570 100644 --- a/clojure-macros.html.markdown +++ b/clojure-macros.html.markdown @@ -99,13 +99,13 @@ You'll want to be familiar with Clojure. Make sure you understand everything in (list x) ; -> (4) ;; You can use # within ` to produce a gensym for each symbol automatically -(defmacro define-x-hygenically [] +(defmacro define-x-hygienically [] `(do (def x# 2) (list x#))) (def x 4) -(define-x-hygenically) ; -> (2) +(define-x-hygienically) ; -> (2) (list x) ; -> (4) ;; It's typical to use helper functions with macros. Let's create a few to @@ -131,7 +131,7 @@ You'll want to be familiar with Clojure. Make sure you understand everything in ; However, we'll need to make it a macro if we want it to be run at compile time (defmacro inline-2 [form] - (inline-2-helper form))) + (inline-2-helper form)) (macroexpand '(inline-2 (1 + (3 / 2) - (1 / 2) + 1))) ; -> (+ (- (+ 1 (/ 3 2)) (/ 1 2)) 1) @@ -142,11 +142,8 @@ You'll want to be familiar with Clojure. Make sure you understand everything in ### Further Reading -Writing Macros from [Clojure for the Brave and True](http://www.braveclojure.com/) -[http://www.braveclojure.com/writing-macros/](http://www.braveclojure.com/writing-macros/) +[Writing Macros](http://www.braveclojure.com/writing-macros/) -Official docs -[http://clojure.org/macros](http://clojure.org/macros) +[Official docs](http://clojure.org/macros) -When to use macros? -[http://dunsmor.com/lisp/onlisp/onlisp_12.html](http://dunsmor.com/lisp/onlisp/onlisp_12.html) +[When to use macros?](https://lispcast.com/when-to-use-a-macro/) |