<div dir="ltr"><div>Hello,</div><div><br></div><div>For a WebKit observer like me:<br></div><div>* "release" - has a well-known meaning in Mac/Objective-C world. It's expected to "free" the memory. Same as COM's IUnknown::Release, but different from auto_ptr::release or unique_ptr::release (which don't free the memory).</div><div>* "move" - has a well-known meaning in C++ 11 world. Different from "release" above. If I see methods "move" and "release" and they do the same, I will have to learn and understand that trick.</div><div>* "take" - a typical name for collections like a blocking queue, heap and some others (usually ordered). If it's a collection's method, it's logically expected to return an item. The key distinction between fred.takeCandy() and say bowl.takeCandy() is that bowl is passive. We treat bowl as a passive bag of data, and expect others to take from it. It's pretty easy to understand and remember, it makes intention more clear than say "bowl.removeCandy()".</div><div>Pure OOP style is always the right way when it comes to readability. A good example mentioned by Stroustrup once that it should be sqrt(5), not 5.sqrt(). Maybe "bowl.takeCandy" is a good compromise to keep it as a method (instead of a global "TakeCandyFromBowl(bowl)").</div><div><br></div><div>Naming is fun.</div><div><br></div><div>--</div><div>Daniel</div><div><a href="https://twitter.com/battlmonstr">https://twitter.com/battlmonstr</a></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Sep 5, 2016 at 9:00 PM, <span dir="ltr"><<a href="mailto:webkit-dev-request@lists.webkit.org" target="_blank">webkit-dev-request@lists.webkit.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Send webkit-dev mailing list submissions to<br>
<a href="mailto:webkit-dev@lists.webkit.org">webkit-dev@lists.webkit.org</a><br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
<a href="https://lists.webkit.org/mailman/listinfo/webkit-dev" rel="noreferrer" target="_blank">https://lists.webkit.org/<wbr>mailman/listinfo/webkit-dev</a><br>
or, via email, send a message with subject or body 'help' to<br>
<a href="mailto:webkit-dev-request@lists.webkit.org">webkit-dev-request@lists.<wbr>webkit.org</a><br>
<br>
You can reach the person managing the list at<br>
<a href="mailto:webkit-dev-owner@lists.webkit.org">webkit-dev-owner@lists.webkit.<wbr>org</a><br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than "Re: Contents of webkit-dev digest..."<br>
<br>
<br>
Today's Topics:<br>
<br>
1. Terminology for giving up ownership: take, release, move<br>
(Darin Adler)<br>
2. Re: Terminology for giving up ownership: take, release, move<br>
(Filip Pizlo)<br>
<br>
<br>
------------------------------<wbr>------------------------------<wbr>----------<br>
<br>
Message: 1<br>
Date: Mon, 05 Sep 2016 10:13:28 -0700<br>
From: Darin Adler <<a href="mailto:darin@apple.com">darin@apple.com</a>><br>
To: WebKit Development Mailing List <<a href="mailto:webkit-dev@lists.webkit.org">webkit-dev@lists.webkit.org</a>><br>
Subject: [webkit-dev] Terminology for giving up ownership: take,<br>
release, move<br>
Message-ID: <<a href="mailto:3AD4BD53-7CC2-4F26-8D3D-B3631413B796@apple.com">3AD4BD53-7CC2-4F26-8D3D-<wbr>B3631413B796@apple.com</a>><br>
Content-Type: text/plain; charset=utf-8<br>
<br>
Hi folks.<br>
<br>
WebKit has some critical functions that involve asking an object to give up ownership of something so the caller can take ownership.<br>
<br>
In the C++ standard library itself, this is called move, as in std::move.<br>
<br>
In WebKit smart pointers, we call this operation release, as in RefPtr::releaseNonNull and String::releaseImpl.<br>
<br>
In WebKit collections, we call this operation take, as in HashMap::take and ExceptionOr::takeReturnValue.<br>
<br>
The release vs. take terminology is distracting to my eyes. The verb ?take" states what the caller wishes to do, and the verb ?release? states what the caller wants the collection or smart pointer to do. My first thought was be to rename the take functions to use the word release instead, but I fear it might make them harder to understand instead of easier and clearly it would make them longer.<br>
<br>
Does anyone have other ideas on how to collapse WebKit project terminology down so we don?t have three different single words that are used to mean almost the same thing?<br>
<br>
? Darin<br>
<br>
------------------------------<br>
<br>
Message: 2<br>
Date: Mon, 05 Sep 2016 10:23:35 -0700<br>
From: Filip Pizlo <<a href="mailto:fpizlo@apple.com">fpizlo@apple.com</a>><br>
To: Darin Adler <<a href="mailto:darin@apple.com">darin@apple.com</a>><br>
Cc: WebKit Development <<a href="mailto:webkit-dev@lists.webkit.org">webkit-dev@lists.webkit.org</a>><br>
Subject: Re: [webkit-dev] Terminology for giving up ownership: take,<br>
release, move<br>
Message-ID: <<a href="mailto:8C068BFC-10D2-4388-919A-761CA9323EAB@apple.com">8C068BFC-10D2-4388-919A-<wbr>761CA9323EAB@apple.com</a>><br>
Content-Type: text/plain; charset=utf-8<br>
<br>
<br>
> On Sep 5, 2016, at 10:13 AM, Darin Adler <<a href="mailto:darin@apple.com">darin@apple.com</a>> wrote:<br>
><br>
> Hi folks.<br>
><br>
> WebKit has some critical functions that involve asking an object to give up ownership of something so the caller can take ownership.<br>
><br>
> In the C++ standard library itself, this is called move, as in std::move.<br>
><br>
> In WebKit smart pointers, we call this operation release, as in RefPtr::releaseNonNull and String::releaseImpl.<br>
><br>
> In WebKit collections, we call this operation take, as in HashMap::take and ExceptionOr::takeReturnValue.<br>
><br>
> The release vs. take terminology is distracting to my eyes. The verb ?take" states what the caller wishes to do, and the verb ?release? states what the caller wants the collection or smart pointer to do. My first thought was be to rename the take functions to use the word release instead, but I fear it might make them harder to understand instead of easier and clearly it would make them longer.<br>
><br>
> Does anyone have other ideas on how to collapse WebKit project terminology down so we don?t have three different single words that are used to mean almost the same thing?<br>
<br>
The use of "take" for these methods grinds my gears, for the same reason you were distracted: "take" describes the desires of the caller, but that doesn't work for me because I read "fred.makeCoffee()" as "makeCoffee()" being an imperative verb phrase and "fred" as being the subject that will make me the coffee. So, "HashMap::take" means to me that the HashMap is taking something from me, rather than releasing something to me.<br>
<br>
I wonder if there is anyone who is surprised more by release than by take, and who would find it strange to say ExceptionOr::<wbr>releaseReturnValue.<br>
<br>
I wouldn't want any words other than "release" used for this purpose, because I know exactly what to expect "release" to mean, since we use it so much already. I think that would be even worse than sometimes using "take", because even though "takeReturnValue" is annoying, I've learned to know what it means.<br>
<br>
If there isn't anyone who prefers take, maybe we should just rename "take" to "release" in these cases?<br>
<br>
-Filip<br>
<br>
<br>
><br>
> ? Darin<br>
> ______________________________<wbr>_________________<br>
> webkit-dev mailing list<br>
> <a href="mailto:webkit-dev@lists.webkit.org">webkit-dev@lists.webkit.org</a><br>
> <a href="https://lists.webkit.org/mailman/listinfo/webkit-dev" rel="noreferrer" target="_blank">https://lists.webkit.org/<wbr>mailman/listinfo/webkit-dev</a><br>
<br>
<br>
<br>
------------------------------<br>
<br>
______________________________<wbr>_________________<br>
webkit-dev mailing list<br>
<a href="mailto:webkit-dev@lists.webkit.org">webkit-dev@lists.webkit.org</a><br>
<a href="https://lists.webkit.org/mailman/listinfo/webkit-dev" rel="noreferrer" target="_blank">https://lists.webkit.org/<wbr>mailman/listinfo/webkit-dev</a><br>
<br>
<br>
End of webkit-dev Digest, Vol 136, Issue 3<br>
******************************<wbr>************<br>
</blockquote></div><br></div></div>