Malcolm J Harwood wrote:
> On Wednesday 25 January 2006 11:29 pm, Philip M. Gollucci wrote:
>
>
>>>- if(0 == strncasecmp(arg, "+inherit", 8)) {
>>>+ if (0 == strncasecmp(arg, "+inherit", 8)) {
>>> modperl_cmd_options(parms, mconfig, "+InheritSwitches");
>>> }
>>> else {
>>
>>Isn't the normal c idiom
>>if (!strncasecmp(....) ?
>
>>I don't think I've ever seen that form.... (though correct)
>
> It's somewhat more common with C++. The logic is this:
> if you typo:
> if (var == 0) ...
> as
> if (var = 0) ...
> it will compile, often without even a warning (though more recent versions of
> gcc do complain), but not do what you expect and the bug can be very hard to
> spot. However if you typo:
> if (0 == var) ...
> as
> if (0 = var) ...
> you'll get a compile time error, as you can't assign to a constant. So whilst
> it reads strangely to most people, some get in the habit of using that form.
> It wouldn't make a difference in this case, as far as I can tell though.
Yes! That's also another _very_ good reason to type comparaisons with the
constant
on the left side. I always try to write it in that order, and by now, my brain
is fully adjusted to it.
if ("Inherit" eq $var) {
elsif ("Enable" eq $var) {
elsif ("Disable" eq $var) {
Also puts the things being looked for first, making the statement somewhat
clearer
to me.
--------------------------------------------------------------------------------
Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID : 88C3A5A5
http://gozer.ectoplasm.org/ F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3A5A5
signature.asc
Description: OpenPGP digital signature
