-
Notifications
You must be signed in to change notification settings - Fork 368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Documentation improvements #2314
Conversation
docs/api.rst
Outdated
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))``. By contrast, the ``defn`` form itself always returns ``None``. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does "the defn
form itself" mean? I'm not quite sure what you're trying to get at here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(defn f [] 3)
returns None
, whereas (f)
returns 3
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... I feel like explaining that distinction only serves to confuse more than elucidate, personally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that the return value of defn
has to be documented somewhere, particularly since it's a chief difference from fn
. If you don't think this is the right way to document it, what do you think is the right way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have any documentation for setv
saying it evaluates to None
, only that setx
is the "expression" form of setv
; I think we can document defn
/fn
similarly.
If you feel strongly that we should mention it though, I think it'll be less confusing up near the top, a la something like the following:
``defn`` compiles to a :ref:`function definition <py:function>` (or possibly
to an assignment of a :ref:`lambda expression <py:lambda>`). Unlike ``fn`` however,
the ``defn`` form itself evaluates to ``None``. It requires two arguments...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have any documentation for
setv
saying it evaluates toNone
We absolutely should. setv
is among the many core macros whose documentation needs a rewrite.
If you feel strongly that we should mention it though, I think it'll be less confusing up near the top
Okay, how's this?
Fixes #2313.