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
document return nothing
convention in Functions man page
#27286
Conversation
and add some links to the style guide and Methods chapters.
Is it documented somewhere that |
I just learnt this shortcut from ScottPJones' reply on the forum. |
Could be added to the |
Yes it would be good to mention the equivalence of |
In the Functions page of the manual, I've added the equivalence of Also, I've expanded the doc the |
There is a build error because of a trailing whitespace in
The problem comes from the blank line, where I indeed put one space character. If I remove it, the resulting html file will not contain a blank line, which makes this example pointless. Now, on Github, blank lines are correctly displayed:
Now this is the screenshot of the built doc, where the blank line is missing: I've looked at the html code, but it's not so clear to me whether is an html or a css problem [...] the REPL does not print anything for it:</p><pre><code class="language-julia-repl hljs"><span class="hljs-meta">julia></span><span class="julia"> <span class="hljs-literal">nothing</span>
</span></code></pre> For comparison, this is the source of the Github-rendered html: <pre lang="jldoctest"><code>julia> nothing
</code></pre> There is indeed one extra blank line. Maybe a bug with Documenter.jl ? |
Neither, it's Documenter.jl: |
Ok, so it's Documenter.jl. Next question: is this a feature or a bug? And side question: if it's a bug and gets fixed, how much other doc pages will break ?!! |
Probably just that no one thought about it before, shouldn't break anything. |
Is there any change needed on the PR? |
Is my doc update fine for merging or is there more work left (e.g. rebase) ? Best, Pierre |
@@ -333,6 +333,10 @@ function compare(a, b) | |||
a < b ? "less than" : "greater than" | |||
end | |||
``` | |||
|
|||
If the returned value is omitted, `return` returns the value [`nothing`](@ref) | |||
(quite similar to C). |
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.
I think we can remove the c comparison. It is a bit different imo since in c you explicitly declare the return type.
|
||
There are two possible shortened forms for the `return nothing` expression. | ||
On the one hand, the `return` keyword implicitly returns `nothing`, so it can be used alone | ||
(similar in that sense to `return;` in C). |
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.
same here
alone is a subjective matter of coding style. Some people prefer explicitness | ||
(always specifying the returned value), while some others favor compactness. | ||
|
||
As a side note on functions with side effects, the [style guide](@ref man-style-exclam) |
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.
Does this fit under the return nothing
header?
After one year, the codebase has changed making part of my PR unrelevant. Still the core of the change would be useful I think. Since I'm not good at cherrypicking git commits, I'll close the PR and reopen a new one, with a reduced set of changes. |
Hi,
This short PR is a follow-up on a forum discussion about where
return nothing
convention should be documented.As discussed, I documented this convention at the end of the section on
return
.I also added some links to the style guide (the
!
convention) and Methods chapters.Somehow unrelated, I added two lines to explicitate the very first function example, because for a Julia newcomer like me, the implicit return is not self-evident.
Also, there was a URL typo in the Documentation README.