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

Hajime Morrita morrita at google.com
Tue Oct 4 18:45:45 PDT 2011


At least we already have some of such mehods like:
void Range::getBorderAndTextQuads(Vector<FloatQuad>&) const;
void VisiblePosition::getInlineBoxAndOffset(InlineBox*& inlineBox, int&
caretOffset) const;
void Posiiton::getInlineBoxAndOffset(EAffinity, InlineBox*&, int&
caretOffset) const;
void FrameView::getTickmarks(Vector<LayoutRect>&) const;
bool Editor::getCompositionSelection(unsigned& selectionStart, unsigned&
selectionEnd) const;


On Wed, Oct 5, 2011 at 10:14 AM, Eric Seidel <eric at webkit.org> wrote:

> Interesting.  I thought historical policy was universally against the
> word "get" in function names.  I guess you're suggesting that "get"
> should only be applied to function names which have an out-argument?
>

I once heard such a feed back on some review.
And at least we already have some of such mehods like:
void Range::getBorderAndTextQuads(Vector<FloatQuad>&) const;
void VisiblePosition::getInlineBoxAndOffset(InlineBox*& inlineBox, int&
caretOffset) const;
void Posiiton::getInlineBoxAndOffset(EAffinity, InlineBox*&, int&
caretOffset) const;
void FrameView::getTickmarks(Vector<LayoutRect>&) const;
bool Editor::getCompositionSelection(unsigned& selectionStart, unsigned&
selectionEnd) const;
...and more:
http://codesearch.google.com/codesearch#search/&exact_package=chromium&q=WebCore%20get.%2B%20file:h$

Personally prefer the get prefix for function with out-params
since it's hard to feel it like an attribute/member variable.
This is never a strong claim though.

Regards,
--
morrita


>
> -eric
>
> On Tue, Oct 4, 2011 at 6:00 PM, Darin Adler <darin at apple.com> wrote:
> > On Oct 4, 2011, at 2:06 PM, Ryosuke Niwa wrote:
> >
> >> It came to my attention that some people are using raw pointers to pass
> out-arguments (e.g. bug 69366). In my understanding, we use pass by
> reference for out arguments when they have to be modified in callees.
> >>
> >> If there's no objection, I'm going to file a bug & upload a patch to
> state this explicitly in the style guideline.
> >
> > If it’s not already in there, I think you might also want to mention the
> related rule that encourages the use of the word “get” at the starts of the
> names of these functions with out arguments.
> >
> >    -- Darin
> >
> > _______________________________________________
> > webkit-dev mailing list
> > webkit-dev at lists.webkit.org
> > http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
> >
> _______________________________________________
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
> http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
>



-- 
morrita
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20111005/8b0e26fb/attachment.html>


More information about the webkit-dev mailing list