Skip to content
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

Merged
merged 6 commits into from
Jul 8, 2022
Merged

Documentation improvements #2314

merged 6 commits into from
Jul 8, 2022

Conversation

Kodiologist
Copy link
Member

Fixes #2313.

docs/api.rst Show resolved Hide resolved
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``.
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member Author

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?

Copy link
Member

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...

Copy link
Member Author

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

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?

@Kodiologist Kodiologist merged commit d175c5c into hylang:master Jul 8, 2022
@Kodiologist Kodiologist deleted the dox branch May 30, 2023 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error in lfor docs, using if instead of when.
2 participants