swift-async-algorithms icon indicating copy to clipboard operation
swift-async-algorithms copied to clipboard

`Task.select` naming

Open filip-sakel opened this issue 3 years ago • 5 comments

Task.select seems too general and doesn't really indicate that the first task to complete is chosen. I've seen (and have used myself) Task.race on the forums, which I think more aptly represents the underlying action.

filip-sakel avatar Mar 25 '22 21:03 filip-sakel

Task.race was one of the first considerations; but even though that is a term of art, it infers a race-condition which it explicitly avoids. select was chosen to its similarity to the C api select. That particular API is one that we feel is perhaps (from a functionality standpoint) something that belongs a bit lower than this package. I would like to see it be pitched as an addition to the _Concurrency library - and of course naming should most certainly be part of that discussion.

phausler avatar Mar 25 '22 21:03 phausler

Historically speaking another consideration was Task.first.

phausler avatar Mar 25 '22 21:03 phausler

Right, race does have a more negative connotation, but select still feels unclear. Task.first, though, seems like a great name.

filip-sakel avatar Mar 25 '22 22:03 filip-sakel

I’d like to suggest Task.winner

malhal avatar Mar 26 '22 08:03 malhal

Hi everyone

Task.select: is not super explicit on what it does (regarding selecting the first task that finished) Task.first: could be misleading because it takes several tasks as parameters, and first could refer to the first arg. Task.winner: is explicit and well suited. I vote for this one.

twittemb avatar Apr 03 '22 15:04 twittemb

We removed Task.select since it encouraged the usage of unstructured concurrency; hence, closing this issue.

FranzBusch avatar Jun 15 '23 09:06 FranzBusch