Re: [PATCH] Git.pm: Don't return 'undef' in vector context.
- From
- Dan Zwell <dzwell@gmail.com>
- Date
- Nov 16, 2007, 08:00 UTC
- Message-ID
- <473D4E18.3060006@zwell.net>
- In-Reply-To
- <7vfxz61yox.fsf@gitster.siamese.dyndns.org>
Junio C Hamano wrote:
Show 16 quoted lines
> 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