Re: AUTOLOAD method

Dave Rolsky <[email protected]>
Newsgroups gmane.comp.web.mason.devel
Message-ID <[email protected]>
On Sat, 5 Jun 2004, Vadim O. Ustiansky wrote:

> I would like Mason to have the possibility to handle non-existent
> methods in a way, similar to perl's AUTOLOAD. In particular one
> may want to be able to write components like the following:
>
>   ...
> % $m->comp('SELF:foo');
> % $m->comp('SELF:bar');
>   ...
> <%method AUTOLOAD>
> <%perl>
>   my $method_name = $m->autoload();
>   if($method_name eq 'foo'){
>     # handle call SELF:foo
>   }elsif($method_name eq 'bar'){
>     # handle call SELF:bar
>   }
> </%perl>
> </%method>
>
> The attached patch seems to implement this feature.
>
> I would like to here your opinion on this topic.

I'm not really a big fan of Perl's AUTOLOAD, so I don't really like this
idea.

Of course, with Perl itself, I usually just generate code during compile
time, with something like this:

 foreach my $f (@fields)
 {
     *{$f} = sub { $_[0]->{$f} }
 }

You can't really do that so easily with Mason, I guess.


-dave

/*=======================
House Absolute Consulting
www.houseabsolute.com
=======================*/


-------------------------------------------------------
This SF.Net email is sponsored by the new InstallShield X.
From Windows to Linux, servers to mobile, InstallShield X is the one
installation-authoring solution that does it all. Learn more and
evaluate today! http://www.installshield.com/Dev2Dev/0504
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.