in reply to RFC: Data::Taxonomy::Tags

Since you asked for any type of feedback, and since I'm not really into this domain, I'll just pick a nit on the first thing I saw ;-)

use overload '""' => sub { shift->as_string }, fallback => 1;
I'm curious why this isn't just the simpler:
use overload '""' => \&as_string, fallback => 1;
There may be a reason, but, if so, I'm missing it :-) Thanks.

Replies are listed 'Best First'.
Re^2: RFC: Data::Taxonomy::Tags
by Jenda (Abbot) on Jun 23, 2005 at 00:59 UTC
    package base; use overload '""' => sub { shift->as_string }, # '""' => \&as_string, fallback => 1; sub as_string { "this is a base class" } package child; @ISA = qw(base); sub as_string { "this is a child class" } package main; $obj = bless {}, "child"; print "\$obj=$obj\n";
    Try both versions. Do you see the difference? The original version calls the as_string method of the object (which may be either an instance of the base class or a child) while the second calls always the as_string subroutine in the base class.

    Jenda
    XML sucks. Badly. SOAP on the other hand is the most powerfull vacuum pump ever invented.

Re^2: RFC: Data::Taxonomy::Tags
by The Mad Hatter (Priest) on Jun 23, 2005 at 01:03 UTC
    It was the first time I'd used overload and it seemed like the natural thing to do for an OO module. ; ) For this case, it doesn't really matter since I'm not doing inheritance, but it does have a difference like Jenda pointed out.