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

Re: [PATCH] git-mv.perl: use stderr for error output and cleanup

From
Junio C Hamano <junkio@cox.net>
Date
Jan 6, 2006, 22:38 UTC
Message-ID
<7vek3lq8wu.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<81b0412b0601050349s6bec1a36jc410fd315fbbc4c@mail.gmail.com>
Alex Riesen <raa.lkml@gmail.com> writes:
> It is cleaned up in the "Perl' meaning" of process: trivial loops
> replaced with map{}

I agree with dies and warns, but I am slightly negative about this one.

> -	foreach my $fileName (@deletedfiles) {
> -		print H "$fileName\0";
> -	}
> +	print H map {"$_\0"} @deletedfiles;

Although there is always one more way to do the same thing in Perl, and there are good idioms that make well written Perl programs very compact and clear, I tend to value readability for (competent) programmers whose native language happens to be something other than Perl.

I think using map{} to build a list to be printed without inter-element spaces is far less intuitive than how the code was originally written for non Perl readers. Using join("\0", @df) might be easier to read but you would then need terminating NUL, and either one of the following are worse:

  do { local ($") = "\0"; print "@deletedfiles\0" } # this one is buggy
  do { local ($\) = "\0"; print for (@deletedfiles); } # impossible to read
So I'd prefer not touching for (@df) { print H "$_\n" } loops.
Previous: Alex RiesenNext: Randal L. Schwartz
Message 2 of 14 in “git-mv.perl: use stderr for error output and cleanup”
  1. git-mv.perl: use stderr for error output and cleanupAlex Riesen, Jan 5, 2006
  2. Junio C HamanoJan 6, 2006
  3. Randal L. SchwartzJan 6, 2006
  4. Linus TorvaldsJan 6, 2006
  5. Randal L. SchwartzJan 6, 2006
  6. Linus TorvaldsJan 7, 2006
  7. Junio C HamanoJan 7, 2006
  8. Alex RiesenJan 7, 2006
  9. Junio C HamanoJan 7, 2006
  10. Alex RiesenJan 10, 2006
  11. Randal L. SchwartzJan 7, 2006
  12. Junio C HamanoJan 7, 2006
  13. Andreas EricssonJan 8, 2006
  14. Alex RiesenJan 10, 2006

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.