https://discourse.julialang.org/t/and-or-bitwise-or-shortcircuit-what-we-get-searching-docs/46263/25
Since people coming from some languages expect and
and or
to be keywords, we could add docstrings for these as keywords so that ?and
and ?or
in the REPL give help strings indicating that the correct short-circuit boolean operators in Julia are &&
and ||
.
can you show an example where we document non-existing stuff? I can work on this
You probably want to add it here: https://github.com/JuliaLang/julia/blob/master/base/docs/basedocs.jl
Generally I don't think we should be adding documentation for syntax in other languages, there is just too much of it. Once we do this, it is reasonable to ask that (
mentions [
(Matlab), etc.
Specifically, AFAICT Python is the outlier with using and
and or
among modern programing languages. Pretty much everyone else uses &&
and ||
, including C/C++, Matlab, R. We should mention this difference in the Python section of Noteworthy differences....
@tpapp Note this is just incidentally documentation for syntax in other languages, and
and or
are the pronounceable names of the operators, words people associate with them, and search them by. We do not even need to mention Python (or any other language) in such entries.
Nothing against also mentioning them in the aforementioned section of the manual.
@henriquebecker91: asking the same question I asked on discourse: if
this is just incidentally documentation for syntax in other languages, and and or are the pronounceable names of the operators, words people associate with them
then should ?plus
take you to the docstring for +
? Is this something we really want to do? If not, can you explain why not?
Also, currently ?
looks up docstrings for symbols, and does not do search. That's what eg apropos
is for.
Incidentally, apropos("boolean and")
(or even "boolean"
) does not turn up &&
or ||
. I think that simply fixing that would be enough.
I think to have ?and
and, say, not ?plus
is due to the same reason why we mention "Significant difference from C++/Python/MATLAB" but not, for example, Java/JavaScript/C# -- we have some ~ target audience / popular language switching target here. (this is only my personal take)
I must admit that I rarely found apropos
to be particularly useful, especially for common words like this. apropos("and")
just turns up basically everything and I would argue that users that have heard of "boolean logic" before, have probably also seen code in other languages that use ||
and &&
, so I don't think a lot of people looking for this would know to search for apropos("boolean and")
.
I like @Moelf take. My argument however, is that our target public is exactly people who are searching something they do now know how to express. If this happened often with +
, then I would suggest adding ?plus
. However, +
for plus
is (afaik) universal, and nobody ever had this doubt. &&
and ||
are much more arbitrary symbols (specially the fact they are doubled and not just &
and |
) and not shared by all programming languages while, at the same time, are very basic concepts implemented by all programming languages, and needed often for the most basic programs.
And, the same target audience for this improvement will be the people that know about ?
but not about apropos
.
On a related note, I added some clarification to the manual in #37489.
&&
and||
are much more arbitrary symbols (specially the fact they are doubled and not just&
and|
) and not shared by all programming languages while
Not all, but most languages use these symbols nowadays, especially in the niche Julia targets (again, Python is an exception).
While I recognize that these operators are new for some people, I am not convinced that
I don't feel very strongly about this particular operator, but I am concerned about the following pattern:
I don't doubt that everyone means well, but I think that this is a vicious cycle.
I propose the following to remedy this:
I think that this is a vicious cycle.
All of us here know what e.g. ||
does (and doesn't do, string concatenation) or *
vs. +
, so the REPL help isn't for us. I think simply documenting a bit more would help beginners, and avoid discussions on discourse, so I would opt to document a bit more, not less "on the safe side".
but I think that this is a vicious cycle.
And I think this is a slippery slope.
I am arguing in favor of including ?and
and ?or
, not of any changes in the manual, keep this in mind.
You say that "I am not convinced that [...] the docstrings are the best place to address this (as opposed to a clarification like #37489)". You do not further discuss why they would not be the best place to address this, nor why the clarification of #37489 replaces the dosctrings instead of complementing them.
You say that "I am not convinced that [...] the manual/docstrings should be going in this direction" but the only negative outcome you arrive is that "even fewer people read through them".
I do not believe the docstrings were created with the purpose of being exhaustively read. The purpose of a reference (different from a manual) is to be queried on demand, to elucidate specific points the user is confused about. The docstrings are not automatically added to the manual. And, to my knowledge, there is no easy way of just listing all of them to read them exhaustively. Someone doing that is already going out of their way to do so.
While I think your argument makes some sense when applied to the manual, I fail to see how it applies to the docstrings, and this left me unconvinced. Seems to me you are just repeating an argument you already made many times before, without adjusting to what I am actually saying.
Most helpful comment
@tpapp Note this is just incidentally documentation for syntax in other languages,
and
andor
are the pronounceable names of the operators, words people associate with them, and search them by. We do not even need to mention Python (or any other language) in such entries.Nothing against also mentioning them in the aforementioned section of the manual.