Skip to Content.
Sympa Menu

devel - Re: [sympa-developpers] Working on repository

Subject: Developers of Sympa

List archive

Chronological Thread  
  • From: Guillaume Rousse <address@concealed>
  • To: address@concealed
  • Subject: Re: [sympa-developpers] Working on repository
  • Date: Mon, 24 Feb 2014 14:29:08 +0100

Le 18/02/2014 04:33, IKEDA Soji a écrit :
Mandatory parameter(s) are put on the beginning of argument list
as unnamed values, then optional parameter(s) follow as named
values.

sub foo {
my $a = shift;
my $b = shift;
my %params = @_;

do_something($a, $b, $params{'c'});
}
Which introduce yet another style, mixing named and positional parameters...

So basically, we have three different style for parameters:
A) positional parameters
sub foo {
my ($a, $b, $c) = @_;
}
foo($a, $b, $c);

B) named parameters
sub foo {
my (%params) = @_;
}
foo(arg1 => $a, arg2 => $b, option => $c);

C) mixed parameters
sub foo {
my ($a, $b, %params) = @_;
}
foo($a, $b, option => $c);

I guess everyone here will agree than enforcing consistent style is
desirable. Can we have a quick poll on prefered style among other
developpers ?

I'm strongly in favor of B, as the most self-describing one. Then A
(simplest), then C.
David, Etienne, Marc, any opinion in this topic before it turns out into yet another ping-pong discussion between Soji and myself ?

How about use of "shift"?
I don't really care about using 'shift', 'pop', 'push' or any other way to retrieve subroutine parameters, this is mostly an implementation detail. What matters here is enforcing consistant subroutines prototypes.

--
Guillaume Rousse
INRIA, Direction des systèmes d'information
Domaine de Voluceau
Rocquencourt - BP 105
78153 Le Chesnay
Tel: 01 39 63 58 31

Attachment: smime.p7s
Description: Signature cryptographique S/MIME




Archive powered by MHonArc 2.6.19+.

Top of Page