Open Lercher opened 7 months ago
In this case the name of the result tells you the meaning of the result. This is one of the cases where it is useful to name a result parameter: for documentation.
There's no reason for this to be a proposal, taking it out of the proposal process.
Change https://go.dev/cl/572179 mentions this issue: sync/atomic: add clarifying sentence to comment for *Bool.CompareAndSwap
Proposal Details
This is the current documentation for
atomic.Bool
CompareAndSwap
:This only happens for the special case
Bool
: From reading only the typesbool * bool -> bool
it is not clear if the return value is the first or second parameter, or some other bool value. The documentation comment just states the obvious (CompareAndSwap does compare-and-swap) andswapped
is ambiguous IMHO b/c it could mean the swapped-in value new, the swapped-out value old, or that the swap operation was done.The proposal is to clarify the doc comment as e.g. (assuming this is even correct)
I'm not native English speaking, so, there is probably better wording.
References