Re: [PATCH v3 07/28] git-remote-mediawiki: Rewrite unclear line of instructions
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 11, 2013, 21:55 UTC
- Message-ID
- <7vwqq08g7u.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <51B784E8.8020700@ensimag.fr>
Célestin Matte <celestin.matte@ensimag.fr> writes:
Show 16 quoted lines
> Le 11/06/2013 20:09, Junio C Hamano a écrit : >> Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes: >> >>>> 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.