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

Re: [PATCH] gitweb: merge boolean feature subroutines

From
MKMatt Kraai <kraai@ftbfs.org>
Date
Jan 4, 2009, 15:58 UTC
Message-ID
<20090104155858.GC4205@ftbfs.org>
In-Reply-To
<9b18b3110901040341n5ff5fa09s878228131d11d2a6@mail.gmail.com>
On Sun, Jan 04, 2009 at 12:41:14PM +0100, demerphq wrote:
Show 25 quoted lines
> Why execute more opcodes, and return a slightly surprising false, when
> you dont have to?
> 
> Is it really deep perl magic to do:
> 
>   return $val eq 'true';
> 
> instead of
> 
>   return $val eq 'true' ? 1 : 0;
> 
> or the actual use:
> 
>    if ($val eq 'true') {
>       return 1
>    } else {
>       return 0
>    }
>
> Isn't the former superior just on pure minimalism metrics? Theres less
> code to understand, less code to go wrong, and as a bonus it returns a
> true boolean. Isn't that just a win-win-win? I mean most perl
> programmers I know would instantly convert the latter two to the first
> just on the grounds that the first version is the clearest expression
> of the desired intent.

I agree that what you suggest is better than the alternatives you present. Unfortunately, none of them match the current behavior. Here's the current code:

	if ($val eq 'true') {
		return 1;
	} elsif ($val eq 'false') {
		return 0;
	}
	return $_[0];

Is there a way to use the form you suggest while falling back to the default if $val isn't set to 'true' or 'false'?

-- 
Matt                                                 http://ftbfs.org/
Previous: demerphqNext: Jakub Narebski
Message 10 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.