You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Any map that gets added to a workflow must be either a blocking map or an async map. This choice determines whether or not the world execution will be blocked while waiting for the mapping to finish (with some subtle advantages and disadvantages for each). This choice is expressed through map_block and map_async functions, which both funnel into a map function that is able to process either but requires the incoming map to be wrapped in an appropriate newtype.
Unfortunately the word map is often used throughout the std Rust library and many others to refer to what is effectively map_block. Because of this, users are likely to naturally mistakenly call our map function when they meant to use map_block. In many cases the compiler should be able to guide users to correct this mistake, but as workflows get very complex and the user leans heavily on type inference, it's possible for them to receive a very misleading error from the compiler which masks the real problem and makes them think there's an error somewhere else in their code.
To fix this, I think we should rename all uses of map to map_generic to make its role more clear. Having a longer name and containing the word generic should discourage users from reaching for this function unless they really know what they're doing.
We could also consider renaming map_block to map, but this would make it less explicit to the user that map_block will be blocking the entire world update loop until it's finished, which might influence them to inappropriately use it for long-running functions, not realizing the extent of its blockiness.
We can start on this now by deprecating map and introducing map_generic, but we cannot remove map entirely until it's time for the next major release.
The text was updated successfully, but these errors were encountered:
Any map that gets added to a workflow must be either a blocking map or an async map. This choice determines whether or not the world execution will be blocked while waiting for the mapping to finish (with some subtle advantages and disadvantages for each). This choice is expressed through
map_block
andmap_async
functions, which both funnel into amap
function that is able to process either but requires the incoming map to be wrapped in an appropriate newtype.Unfortunately the word
map
is often used throughout the std Rust library and many others to refer to what is effectivelymap_block
. Because of this, users are likely to naturally mistakenly call ourmap
function when they meant to usemap_block
. In many cases the compiler should be able to guide users to correct this mistake, but as workflows get very complex and the user leans heavily on type inference, it's possible for them to receive a very misleading error from the compiler which masks the real problem and makes them think there's an error somewhere else in their code.To fix this, I think we should rename all uses of
map
tomap_generic
to make its role more clear. Having a longer name and containing the wordgeneric
should discourage users from reaching for this function unless they really know what they're doing.We could also consider renaming
map_block
tomap
, but this would make it less explicit to the user thatmap_block
will be blocking the entire world update loop until it's finished, which might influence them to inappropriately use it for long-running functions, not realizing the extent of its blockiness.We can start on this now by deprecating
map
and introducingmap_generic
, but we cannot removemap
entirely until it's time for the next major release.The text was updated successfully, but these errors were encountered: