[Development] when to Extract Method (was Re: commas in ctor-init-lists)
Thiago Macieira
thiago.macieira at intel.com
Fri Jun 3 15:19:26 CEST 2016
On sexta-feira, 3 de junho de 2016 13:10:42 BRT Edward Welbourne wrote:
> Thiago Macieira
>
> > Another thing to be very, VERY careful is about nested function call
> >
> > chains, as in:
> > if (foo(bar(), baz(quux()), variable, xyz()) == variable)
> >
> > Can you tell me if bar, baz, quux, or xyz modify variable? If so, what
> > is the call order?
>
> If any of bar, baz, quux or xyz plausibly might modify variable, then
> this code has undefined behaviour - because the call order is undefined.
Exactly!
> (... except for quux() being called before baz; and baz, bar and xyz
> being called before foo, of course; the point in all that at which
> variable's value gets read is indeterminate, any which way.)
>
> Not that I see how this bears on whether that complex call to foo()
> should be extracted as a separate method,
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
More information about the Development
mailing list