[webkit-dev] Lets use PassRefPtr for arguments less; lets use RefPtr for locals and data members more
levin at chromium.org
Mon Jun 20 21:29:39 PDT 2011
On Mon, Jun 20, 2011 at 6:11 PM, Alexey Proskuryakov <ap at webkit.org> wrote:
> 20.06.2011, в 17:25, Maciej Stachowiak написал(а):
> >> Yet it's the latter where PassRefPtr is beneficial. Why base the rule on
> something that's disconnected from actual benefit?
> > Because it's simpler to read the source of your own function than to
> visit all call sites, and it's more obvious that when you change what the
> function does you may need to change the signature.
> I do not see how you are describing a practical coding situation here. I do
> not start with a dozen call sites all over the code base, and then write a
> function they all call. On the other hand, when adding a new call site that
> wants to pass ownership away, and the called function doesn't take a
> PassRefPtr, it's immediately obvious that it's not going to work.
> Even when following a cargo cult rule is easier (not uncommon!), the
> problem of it being disconnected from the actual benefit still remains.
Here's a few benefits:
1. It makes the code more self-documenting. It clearly indicates that this
function intends to take a reference to the item.
2. It is consistent with the rules for PassOwnPtr. It is nice to have one
set of things in mind that are consistent.
3. Just like one shouldn't document a function based on who calls it because
that may change, it makes sense to base the argument types on the how the
function uses them not on the callers.
> - WBR, Alexey Proskuryakov
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the webkit-dev