Merge pull request #1834 from Kodiologist/let-ns

Document gotcha with unintentional recursion in `let`
This commit is contained in:
Ryan Gonzalez 2019-11-15 15:40:16 -06:00 committed by GitHub
commit 50b34dd727
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -240,7 +240,8 @@ The ``let`` macro takes two parameters: a list defining *variables*
and the *body* which gets executed. *variables* is a vector of
variable and value pairs.
``let`` executes the variable assignments one-by-one, in the order written.
Like the ``let*`` of many other Lisps, ``let`` executes the variable
assignments one-by-one, in the order written::
.. code-block:: hy
@ -249,4 +250,8 @@ variable and value pairs.
... (print x y))
5 6
Unlike them, however, each ``(let …)`` form uses only one
namespace for all its assignments. Thus, ``(let [x 1 x (fn [] x)]
(x))`` returns a function object, not 1 as you might expect.
It is an error to use a let-bound name in a ``global`` or ``nonlocal`` form.