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: Marc Chantreux <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 14:46:30 +0100

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.

regards


--
Marc Chantreux
Université de Strasbourg, Direction Informatique
14 Rue René Descartes,
67084 STRASBOURG CEDEX
☎: 03.68.85.57.40
http://unistra.fr
"Don't believe everything you read on the Internet"
-- Abraham Lincoln



Archive powered by MHonArc 2.6.19+.

Top of Page