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: IKEDA Soji <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: Thu, 20 Dec 2012 11:21:25 +0900

Marc and all,

On Wed, 19 Dec 2012 14:46:30 +0100
Marc Chantreux <address@concealed> wrote:

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

There are no serious reasons. I'd been making efforts not using
modules stir Perl internals (this is not an absolute rule). That's
why I used simple Perl idiom to generate dynamic methods instead
using external module.

If it is possible that current AUTOLOAD approach bumps against
any difficulties, module to solve them must be introduced (closure
is also used in current code). Would you please explain me what
problem(s) Package::Stash will solve?

> 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

Regards,

--- Soji

--
株式会社 コンバージョン セキュリティ&OSSソリューション部 池田荘児
〒231-0004 神奈川県横浜市中区元浜町3-21-2 ヘリオス関内ビル7F
e-mail address@concealed TEL 045-640-3550
http://www.conversion.co.jp/



Archive powered by MHonArc 2.6.19+.

Top of Page