[bind10-dev] suggested team call agenda
Michal 'vorner' Vaner
michal.vaner at nic.cz
Tue Dec 11 09:09:50 UTC 2012
Hello
On Tue, Dec 11, 2012 at 08:59:11AM +0000, Francis Dupont wrote:
> > If this is allowed depends on the type of `pointer`:
> >
> > if (pointer) {
> >
> > }
> >
> > If pointer is bare pointer, it is not allowed, if it is int, it is not
> > allowed,
> > if it is smart pointer or other class, it is allowed.
>
> => allowed or not it is bad style: the test in the if construct is a boolean!
Actually, I used:
if (pointer != shared_ptr<Type>()) {
in the test and it was pointed out in a review this can be shortened.
<flame>
Many people say it's a bad style to eat pizza with knife and fork. Still, that's
what many other people do and nobody gets hurt or insulted. So, why the hell
should that be a bad style?
</flame>
My view is, pointer either points to something or does not point to anything.
That is very intuitive meaning in a conditional statement, that is generally
used in many projects and that's why each smart pointer has a bool operator so
it can be checked that way. I believe it is more readable than using
if (pointer != NULL)
and that the readability should be the primary criterion about style (with
obviously avoiding some pitfalls of language).
And these together make me want to know the reason why it should be considered
bad style in the first place and if we want to either change that or make it
consistent with the shared pointers somehow.
With regards
--
ASHes to ASHes, DOS to DOS.
Michal 'vorner' Vaner
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <https://lists.isc.org/pipermail/bind10-dev/attachments/20121211/fc04d44b/attachment.bin>
More information about the bind10-dev
mailing list