From: Matt Kraai <kraai@ftbfs.org>
To: demerphq <demerphq@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: [PATCH] gitweb: merge boolean feature subroutines
Date: Sun, 4 Jan 2009 07:58:58 -0800 [thread overview]
Message-ID: <20090104155858.GC4205@ftbfs.org> (raw)
In-Reply-To: <9b18b3110901040341n5ff5fa09s878228131d11d2a6@mail.gmail.com>
On Sun, Jan 04, 2009 at 12:41:14PM +0100, demerphq wrote:
> 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/
next prev parent reply other threads:[~2009-01-04 16:00 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-03 15:31 [PATCH] gitweb: merge boolean feature subroutines Matt Kraai
2009-01-03 15:31 ` [PATCH] gitweb: pass the key to the " Matt Kraai
2009-01-03 16:18 ` [PATCH] gitweb: merge boolean " demerphq
2009-01-03 16:40 ` Matt Kraai
2009-01-03 16:51 ` demerphq
2009-01-03 17:13 ` Matt Kraai
2009-01-03 17:41 ` demerphq
2009-01-04 5:30 ` Junio C Hamano
2009-01-04 11:41 ` demerphq
2009-01-04 15:58 ` Matt Kraai [this message]
2009-01-04 22:07 ` Jakub Narebski
2009-01-04 21:25 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090104155858.GC4205@ftbfs.org \
--to=kraai@ftbfs.org \
--cc=demerphq@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.