Subject: Re: [PATCH] Git.pm: Don't return 'undef' in vector context.

From: Dan Zwell <[email-masked]>
Date: Fri, 16 Nov 2007 02:00:24 -0600

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