On Tue, Jun 2, 2015 at 1:59 PM, L. David Baron <dba...@dbaron.org> wrote:
>
> My assumption was that this would be for cases where neither the
> reader nor writer is likely to care about which integral type it is,
> and also cases that are near the threshold for whether to repeat (in
> source code or perhaps only in execution) an expression or to put
> the result of that expression in a variable.
>
> For example:
>   auto display = mStyleDisplay->mDisplay;
>   if (frame->IsFrameOfType(nsIFrame::eLineParticipant) ||
>       nsStyleDisplay::IsRubyDisplayType(display) ||
>       mFrameType == NS_CSS_FRAME_TYPE_INTERNAL_TABLE ||
>       display == NS_STYLE_DISPLAY_TABLE ||
>       display == NS_STYLE_DISPLAY_TABLE_CAPTION ||
>       display == NS_STYLE_DISPLAY_INLINE_TABLE) {
> ... where most users would explicitly write mStyleDisplay->mDisplay,
> but in this case it seems nicer to stick it in a variable than write
> mStyleDisplay->mDisplay four times over.
>
> Remember that if 'auto' is forbidden, people might get around it by
> not using a variable at all (and instead repeating the expression)
> rather than by writing the type explicitly on the variable... and
> this doesn't provide type information.  The cases I'm talking about
> are ones where we're near the threshold between repeating the
> expression or putting its value in a variable.

Your full example is better.  Context matters.  And it highlights a
combination of other factors: the type of mDisplay is adequately
signaled by its usage (in this case), and the type of mDisplay might
reasonably be understood by the reader of the code.  I initially
hadn't caught on that you were talking about CSS here, but it's
perhaps reasonable to expect that someone reading CSS code would know
what is used for something as fundamental as style.display.
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to