Combined SE-0366 (third review) and SE-0377 (second review): rename `take`/`taking` to `consume`/`consuming`

No, for a copyable type you don’t; an implicit copy of the argument will be passed to be consumed if needed. The behavior for non-copyable types will be determined in another proposal.

+1 for "consumed". When people ask questions, the specific words and formulation they use can help to guide their thinking. If I consider a question like:

"why is x being retained? It's a consumed parameter" vs
"why is x being retained? It's a consuming parameter"

I feel that the latter is less clear about what is going on, to the point that it may mislead or cause confusion. It sounds like x is consuming something, when in fact, it is itself being consumed.

It may be a slight initial obstacle for programmers less fluent in English, but inevitably as they work with Swift, they will pick up some amount of English - almost every Swift API, and certainly all of the standard library APIs, are in English, including grammatical nuances such as String.append (mutating) vs String.appending (non-mutating, returns a new String). So it's already the case that less fluent developers would benefit from a basic understanding of English grammar, because they will be able to more quickly understand what APIs do, form expectations about mutating and return types, and select the right API for a given situation, just by looking at a function's base name.

And once they do pick it up, I think they will also benefit from the additional clarity of "consumed", just as more proficient English speakers can.

6 Likes

This line has been aired quite a bit upthread, but since it's still with us…

I think it's a terrible idea to slice (English) grammar so finely as to choose the keywords the grammatical and semantic difference between consumed and consuming in natural language. The Swift context isn't natural language. Make an argument from which spelling you prefer, of course, but arguing from grammar risks blinding you to the preconceptions that developers will actually bring — what's clarifying for you is not guaranteed to be clarifying for others.

I also don't think the discussion has paid enough attention to the difference between understanding the modifier in the calling context vs. the called context. If we're mired in participles and gerundives, then for the caller, the function is consuming its argument; for the callee, the function has consumed its parameter. Which of these the modifier should mean depends on where you're standing.

This suggestion didn't trigger much discussion, but I think it's an excellent compromise. It doesn't bother too much with the overall grammar of the function call (read as a pseudo-sentence), and it works just as well for the caller as for the callee.

consumes Foo states directly that something does something consumption-like to the Foo at the time of the call, and just bypasses the excursion into English grammar.

Really, isn't the goal here to be clear-as-a-keyword, not clear-as-English (which, in regard to the superficial syntax of its grammar, isn't what you could call "clear" anyway)?

3 Likes

Thank you everyone for participating in this review! SE-0366 is accepted with the name consume:

And SE-0377 is accepted with the names consuming and borrowing:

Holly Borla
Review Manager

11 Likes