All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Zwell <dzwell@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Dan Zwell <dzwell@gmail.com>, Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH] Git.pm: Don't return 'undef' in vector context.
Date: Fri, 16 Nov 2007 02:00:24 -0600	[thread overview]
Message-ID: <473D4E18.3060006@zwell.net> (raw)
In-Reply-To: <7vfxz61yox.fsf@gitster.siamese.dyndns.org>

Junio C Hamano wrote:
> I did not examine the callers but my gut feeling is that it
> would be simpler and cleaner to always return () without
> checking the context.  In scalar context:
> 
> 	sub null {
>         	...
>                 return ();
> 	}
> 	my $scalar = null();
> 
> would assign undef to $scalar anyway.
> 
> I generally try to stay away from functions that changes their
> return values depending on the context, because they tend to
> make reading the callers to find bugs more difficult.
> <snip>

That's reasonable. I'll resend this as part of the git-add--interactive 
color patches. This can be cherry-picked out, but some of the other 
stuff I want to do depends on it (a helper function that I wrote, 
config_with_default($repo, $key, $default)).

Dan

  reply	other threads:[~2007-11-16  8:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-16  6:15 [PATCH] Git.pm: Don't return 'undef' in vector context Dan Zwell
2007-11-16  6:39 ` Junio C Hamano
2007-11-16  8:00   ` Dan Zwell [this message]
2007-11-17  0:39     ` Junio C Hamano
2007-11-16 12:47   ` Sebastian Harl
2007-11-16  8:43 ` Jakub Narebski
2007-11-17  3:20   ` Dan Zwell
2007-11-17 15:19     ` Jakub Narebski

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=473D4E18.3060006@zwell.net \
    --to=dzwell@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.