git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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.

Previous: Jakub Narebski
Message 12 of 12 in “gitweb: merge boolean feature subroutines”
  1. gitweb: merge boolean feature subroutinesMatt Kraai, Jan 3, 2009
  2. gitweb: pass the key to the feature subroutinesMatt Kraai, Jan 3, 2009
  3. demerphqJan 3, 2009
  4. Matt KraaiJan 3, 2009
  5. demerphqJan 3, 2009
  6. Matt KraaiJan 3, 2009
  7. demerphqJan 3, 2009
  8. Junio C HamanoJan 4, 2009
  9. demerphqJan 4, 2009
  10. Matt KraaiJan 4, 2009
  11. Jakub NarebskiJan 4, 2009
  12. Junio C HamanoJan 4, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.