documentation for require

working on documenting macros
This commit is contained in:
Tuukka Turto 2013-07-22 23:36:59 +03:00
parent a786577a8b
commit ec76c6bee0

View File

@ -38,6 +38,14 @@ Hy features a number special forms that are used to help generate
correct Python AST. The following are "special" forms, which may have correct Python AST. The following are "special" forms, which may have
behavior that's slightly unexpected in some situations. behavior that's slightly unexpected in some situations.
->
--
->>
---
and and
--- ---
@ -129,6 +137,10 @@ the user enters `k`.
(print "Try again"))) (print "Try again")))
cond
----
continue continue
-------- --------
@ -223,6 +235,10 @@ below:
Meow Meow
defn / defun
------------
defmacro defmacro
-------- --------
@ -233,7 +249,7 @@ Following example defines a macro that can be used to swap order of elements in
code, allowing the user to write code in infix notation, where operator is in code, allowing the user to write code in infix notation, where operator is in
between the operands. between the operands.
.. codeblock:: clj .. code-block:: clj
=> (defmacro infix [code] => (defmacro infix [code]
... (quasiquote ( ... (quasiquote (
@ -256,6 +272,14 @@ eval-when-compile
----------------- -----------------
first / car
-----------
for
---
foreach foreach
------- -------
@ -442,6 +466,10 @@ function is defined and passed to another function for filtering output.
Dave Dave
let
---
list-comp list-comp
--------- ---------
@ -533,6 +561,20 @@ the `print` form is used to output on screen. Example usage:
require require
------- -------
`require` is used to import macros from a given namespace. It takes at least one
parameter specifying the namespace which macros should be imported. Multiple
namesspaces can be imported with a single `require`.
The following example will import macros from `namespace-1` and `namespace-2`:
.. code-block:: clj
(require namespace-1 namespace-2)
rest / cdr
----------
slice slice
----- -----
@ -613,6 +655,14 @@ be executed. If no errors are raised the `else` block is executed. Regardless
if an error was raised or not, the `finally` block is executed as last. if an error was raised or not, the `finally` block is executed as last.
unless
------
when
----
while while
----- -----