[webkit-dev] Add explicit style guideline: should use type& instead of type* for out arguments

Darin Adler darin at apple.com
Tue Oct 4 17:57:37 PDT 2011


On Oct 4, 2011, at 2:14 PM, James Robinson wrote:

> Could you explain why? Is it to document the nullity of the out-param?

Sure, one reason is to document the non-nullity of the out parameter.

> I personally find pointers for out parameters to be appropriate in many situations. It makes the side effects of manipulating the parameter more obvious, and it provides a clear way for the caller to indicate that they don't care about a certain out parameter. It sounds like you have reasons to prefer the opposite behavior.

For an optional out parameter, our style has been to use a pointer. For a non-optional, our style has been to use a reference.

There are hundreds of these in WebCore and JavaScriptCore. It’s largely an arbitrary guideline, but one that has been around for years and I’d prefer not to change style unless there is a strong reason.

    -- Darin



More information about the webkit-dev mailing list