Skip to Content.
Sympa Menu

devel - Re: [sympa-developpers] [sympa-commits] sympa[8261] branches/sympa-6.2-branch/src/lib: [dev] split AUTOLOAD of Site to Site and Robot,

Subject: Developers of Sympa

List archive

Chronological Thread  
  • From: Guillaume Rousse <address@concealed>
  • To: address@concealed
  • Subject: Re: [sympa-developpers] [sympa-commits] sympa[8261] branches/sympa-6.2-branch/src/lib: [dev] split AUTOLOAD of Site to Site and Robot,
  • Date: Wed, 19 Dec 2012 15:44:37 +0100

Le 19/12/2012 14:46, Marc Chantreux a écrit :
On Tue, Dec 18, 2012 at 03:42:05PM +0100, Guillaume Rousse wrote:
Le 18/12/2012 15:35, David Verdin a écrit :

Le 18/12/12 14:50, Guillaume Rousse a écrit :
Le 18/12/2012 14:35, David Verdin a écrit :
I'm also quite found of the getters / setters. But we have to deal with
legacy. What Soji proposes is a good compromise for the 6.2 version. It
gives us accessors without having to rewrite large parts of the code.
However, using get_* and set_* methods implemented looks like a good aim
for 6.3 on my opinion.
Turning those automatically-generated 'foo()' accessors into
'get_foo()' is just a matter or changing the regexp used to parse
AUTOLOAD value:

$AUTOLOAD =~ m/^(.*)::(.*)/;
to
$AUTOLOAD =~ m/^(.*)::get_(.*)/;

The same statement, with a stricter regexp and error handling:
croak "no such method" unless $AUTOLOAD =~ m/^(\S+)::get_(\S+)/;
Croak again, darn... ;-)

I'm sorry i haven't found the thread on the archive
(https://listes.renater.fr/sympa/arc/sympa-developpers/2012-11/)
so maybe this is answer is irrelevant. Just ignore me if it is :)

I had some bad experiences with $AUTOLOAD which is pain to debug in
some cases. why not use Package::Stash and closures to manipulate those
kind if symbols?

something like

my $things = Package::Stash->new('Sympa::Things');

for my $sym (qw< owner subscribers editors >) {
$things->add_symbol
( "\&get_$sym" => sub { some_code_to_get $sym }
);
}

Package::Stash is XS and PP, heavily used in Class::MOP AFAIK.
We could as well switch to Moose directly :)

More seriously, that's that's just trading one way to dynamically generate code at runtime for another, which is my main issue here.

Also, an additional native package dependency seems way to heavy given audience target. Older pure-perl alternative solutions, such as Class::Maker for instance, despite heavily outdated according to modern perl considerations, would be far better suited to the context.

--
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