Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: RFC: Data::Taxonomy::Tags

by Tanktalus (Canon)
on Jun 22, 2005 at 23:01 UTC ( [id://469235]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://469235]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2024-07-23 18:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.