[cfe-dev] Don't help the compiler!

Jiří Zárevúcky zarevucky.jiri at gmail.com
Mon Jan 26 01:51:31 PST 2015


On 26 January 2015 at 10:15, David Chisnall <David.Chisnall at cl.cam.ac.uk>
wrote:

> On 23 Jan 2015, at 16:32, Csaba Raduly <rcsaba at gmail.com> wrote:
> >
> > STL (Stephan T. Lavavej) in his talk at Going Native 2013, gave this
> > example of an attempt to "help the compiler", which is at best
> > superfluous:
> >
> >    auto p = std::make_pair<int, double>(42, 3.1415);
> >
> > and recommended
> >
> >    auto p = std::make_pair             (42, 3.1415);
>
> The latter form seems less readable.  The fact that a floating point
> literal is a double unless suffixed with f is something that is rarely
> important for developers to remember, so this extra piece of information
> increases the cognitive burden when reading the code.
>
> The goal of the former form is not to 'help the compiler', it is to help
> the poor sap who has to maintain this code in a couple of years.
>
>
If you really need to think about whether it is float or double, then the
unnecessary cognitive burden is somewhere else entirely.


-- J. Z.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150126/018a0df7/attachment.html>


More information about the cfe-dev mailing list