Re: [PATCH v3 07/28] git-remote-mediawiki: Rewrite unclear line of instructions
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:57:42
Célestin Matte [off-list ref] writes:
Le 11/06/2013 20:09, Junio C Hamano a écrit :quoted
Matthieu Moy [off-list ref] writes:quoted
quoted
my ($namespace) = @_; my $namespace = shift; My impression has been that both are equally common,The second is the most common in git-remote-mediawiki (but I don't have any preference nor know what is recommended elsewhere).I wasn't implying I prefer the former. I was just being curious, and if the latter is more prevalent in the code _and_ Perlcritique does not have any issue with it, it is perfectly fine.Perlcritic doesn't have an issue with any of both cases.
OK. As this topic is about matching the opinion of Perlcritique, I think it is fine either way (which was the primary thing that I wanted to find out).
I think the second method is clearer when there is only one argument, because it makes it clear that there is only one.
Hmm, from the maintenance point of view, the second one invites the next person to extend this function like this: my $namespace = shift; + my $newargument = shift; + my $anotherargument = shift; If your original were in the first style, instead you would likely to get this: - my ($namespace) = @_; + my ($namespace, $newargument, $anotherargument) = @_; When there is only one argument, it is clear that there is only one argument in either style. It is not a strong factor to pick one style over the other. Once you start taking more than one argument, however, I think "it makes it clear what arguments the function takes" would actually favor the style to split @_ into a list of local variables. But as I said earlier, this patch is about following Perlcritique's advice, and because it does not have opinion on these styles, it is outside the scope of this patch. Thanks for checking.