Hello,

FRIGN wrote:
>> tests (boolean)
>> ===============
>> do not test against NULL explicitly (e.g.   if (!p)  instead of if (p == 
>> NULL))
>> do not test against 0 explicitly (e.g.  if (!strcmp(p, q)) instead of
>> if (strcmp(p, q) == 0)) (discuss)
>
> Yes, yes, yes. See the patches I sent in a few days ago.

By default I read  if (!functioncall()) as 'if the function call
failed'.  I like the (strcmp(p, q) == 0) idiom because I don't fall
into the trap of reading the statement as 'if the string comparison
failed'.  It is the one case I can think of where I prefer an explicit
comparison to zero.


>> early returns/exits
>> ===================
> I have no problem with goto. It often simplifies things dramatically
> and there's no reason to regulate it or punish its use.

Agreed - goto's for cleanup when there is local state or allocations
to roll back are a godsend - otherwise use an early return.

Everything else I agree with well enough.

yours,
Bobby

Reply via email to