Re: [PATCH] gitweb: merge boolean feature subroutines
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jan 4, 2009, 21:25 UTC
- Message-ID
- <7v8wpqu5k1.fsf@gitster.siamese.dyndns.org>
- In-Reply-To
- <9b18b3110901040341n5ff5fa09s878228131d11d2a6@mail.gmail.com>
demerphq <demerphq@gmail.com> writes:
Show 7 quoted lines
> Is it really deep perl magic to do: > > return $val eq 'true'; > > instead of > > return $val eq 'true' ? 1 : 0;
No, neither are magicky. But your argument to favor the former over the latter that goes down to XS level was all about deep magic, and you wrote yourself:
> ... It is not a good idea to use 0 as a replacement for perls false, as > the two have different behaviour.
My point is that any caller that cares about the differences of "Perl's true false" and 0 when talking about a function that returns a yes/no value is already soaked too deep in Perl's deep magic. I would want the code to be maintainable by people who does not care the deep voodoo, and for that reason, I do not want the callers to care.
Having said that, I think it is perfectly fine to favor returning "$val eq 'true'" over returning "$val eq 'true ? 1 : 0". But that is not because it is truer way to say false from Perl experts' point of view, but because it is shorter and more to the point.