Document map
, separate map
and collect
#39628
Labels
docs
This change adds or pertains to documentation
map
, separate map
and collect
#39628
This might be better as two separate issues, since on one hand I want to document what
map
is now, and on the other hand I want behavior formap
that might need to wait until a breaking release. But I don't know where the boundary between those two are.Regarding documentation, there is currently one docstring defined for
map
:julia/base/abstractarray.jl
Lines 2305 to 2328 in 4f854b4
This docstring does not capture the behavior of
map
on e.g.NamedTuple
. It does not describe what is done with the result of applyingf
to each element. (As an aside, it is worth clarifying that the meaning of "each element" is defined by theiterate
interface.)Where possible, I think we should document behavior in terms of properties such as
See #38150 (comment) . As that thread indicates, that property doesn't currently hold, because
map
is conflated withcollect
. To relate the behavior ofmap
andcollect
, I expect the following propertyOne example where the property doesn't hold is with
Generator
s:That property could hold with the following definitions:
This will break code that was using
map
for itscollect
behavior. Some examples (with some false positives from splatting arguments from a generator intomap
) can be found with the regexmap\([^,]*,\s*\(.*for.*in
.The text was updated successfully, but these errors were encountered: