Re: RFC 254 (v1) Class Collections: Provide the ability to overload classes

[email protected] (Damian Conway) Thu, 21 Sep 2000 06:30:36 +1100 (EST)
Newsgroups perl.perl6.language.objects
Message-ID <[email protected]>
I haven't (and won't) have time to go into this in detail :-(

I feel that this proposal is solving the wrong problem. The issue is
that the original Forest and Frog (or DBI and DBI::st) classes are not
*designed* for user-definable Frogs (DBI::st's). If that functionality
is widely needed, the Forest should be redesigned with *configurable*
Frogs.

But even if you can't redesign the forest, Perl still makes it easy to
impose a Japanese accent on Frogs wherever you need to:

        my $forest = Forest->new();

        if (can_see_Mt_Fuji()) {
                local *Frog::speak = sub { "kerokero" };
		# or:
		# local *Frog::speak = \&Frog::Japanese::speak;

                print $forest->make_noise();    # "kerokero"
        }

        print $forest->make_noise();            # "ribbit-ribbit"

Damian