[Israel.pm] bless and AUTOLOAD

Yuval Kogman nothingmuch at woobling.org
Wed Sep 26 02:52:48 PDT 2007


On Wed, Sep 26, 2007 at 06:22:51 +0200, Yona Shlomo wrote:

> Way cool!! :-)
> This actually defines the subs automatically in the BEGIN
> block.
> 
> Now the question is what is more ugly: to use AUTOLOAD or to
> use this.

It is common practice to mix them actually ;-)

Traditionally AUTOLOAD will inject an entry to the symbol table, and
not so much work as a catch-all (i suppose that's why it's got
"load" in it's name).

Either way, what is uglier relates to the task at hand - if these
are cases AUTOLOAD should ignore personally I feel that injecting
sub { } entries is cleaner (lets subclass AUTOLOADs worry less as
well, etc). If, on the other hand, the AUTOLOAD implementation has
much to do with the symbol table, e.g. accessor generation or
something like that, then having a skip regex makes more sense.

For the record, Gaal's version is exactly the same type of cool but
with more perceived pretty. Someone was listening to my talk (even
though he didn't attend ;-), point being "ugly/funky code should be
packaged cleanly".

Anyway, enough philosophising

-- 
  Yuval Kogman <nothingmuch at woobling.org>
http://nothingmuch.woobling.org  0xEBD27418




More information about the Perl mailing list