From d79e56f2ef9754e2d9c3ff6b55e60c96f9b46f6b Mon Sep 17 00:00:00 2001 From: Csilla Nagyne Martinak Date: Sat, 17 Oct 2015 13:32:01 +0200 Subject: [PATCH] docs/tutorial: Add a short (require) example Adds a short (require) example, along with a few words on why macros can't be imported. Closes #966. Signed-off-by: Csilla Nagyne Martinak --- docs/tutorial.rst | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/tutorial.rst b/docs/tutorial.rst index cf76538..c78fa83 100644 --- a/docs/tutorial.rst +++ b/docs/tutorial.rst @@ -557,10 +557,21 @@ characters that soon): => #↻(1 2 3 +) 6 -Macros are useful when one wished to extend the Hy or write their own +Macros are useful when one wishes to extend the Hy or write their own language on top of that. Many features of Hy are macros, like ``when``, ``cond`` and ``->``. +To use macros defined in a different module, it is not enough to +``import`` the module, because importing happens at run-time, while we +would need macros at compile-time. Instead of importing the module +with macros, it must be ``require``d: + +.. code-block:: clj + + => (require tutorial.macros) + => (rev (1 2 3 +)) + 6 + Hy <-> Python interop =====================