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

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

From
DZDan 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
Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 8 in “Git.pm: Don't return 'undef' in vector context.”
  1. Git.pm: Don't return 'undef' in vector context.Dan Zwell, Nov 16, 2007
  2. Junio C HamanoNov 16, 2007
  3. Dan ZwellNov 16, 2007
  4. Junio C HamanoNov 17, 2007
  5. Sebastian HarlNov 16, 2007
  6. Jakub NarebskiNov 16, 2007
  7. Dan ZwellNov 17, 2007
  8. Jakub NarebskiNov 17, 2007

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.