Skip to content

Commit

Permalink
Improve docs of implicit return with async gen.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kodiologist authored and scauligi committed Oct 27, 2023
1 parent 878a85b commit dd1ba62
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion NEWS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Bug Fixes
already did.
* `nonlocal` now works for top-level `let`-bound names.
* `hy -i` with a filename now skips shebang lines.
* Async generators no longer try to return final expressions.
* Implicit returns are now disabled in async generators.

0.27.0 (released 2023-07-06)
=============================
Expand Down
5 changes: 4 additions & 1 deletion docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ base names, such that ``hy.core.macros.foo`` can be called as just ``foo``.
forms, and the first of them is a string literal, this string becomes the
:term:`py:docstring` of the function. The final body form is implicitly
returned; thus, ``(defn f [] 5)`` is equivalent to ``(defn f [] (return
5))``.
5))``. There is one exception: due to Python limitations, no implicit return
is added if the function is an asynchronous generator (i.e., defined with
:hy:func:`defn/a` or :hy:func:`fn/a` and containing at least one
:hy:func:`yield` or :hy:func:`yield-from`).

``defn`` accepts a few more optional arguments: a bracketed list of
:term:`decorators <py:decorator>`, a list of type parameters (see below),
Expand Down

0 comments on commit dd1ba62

Please sign in to comment.