Nathan Wigner in the guise of Perl6 RFC Librarian <[EMAIL PROTECTED]> writes:
> You can use facilities such as C<tie> to help fix this issue, but
> C<tie> is limited and slow. You can also overload operators, but
> this is not flexible enough for many applications since it applies
> to a package (and not individual objects).

If you *really* want to do that, consider:

    package Customstringify;
    use Symbol;

    my %obj2str;
    my $symbol = 'CSM0000000';
    use overload '""' => sub {$obj2str{$_[0]}};

    sub register {
        my $self = shift;
        my $obj  = shift;

        $obj2str{$obj} = join '', @_;

        my $pkg = $symbol++;
        no strict 'refs';
        @{$pkg . "::ISA"} =  ('Customstringify', ref $obj);
        bless $obj => $pkg;
    }

But frankly I can't really think of an occasion when you'd *want* to
specify such behaviour on an object by object basis.

And the RFC then proceeds to ignore this point and proposes something
that looks remarkably similar to the current overloading scenario. Or
am I missing something? I really can't see where the win is with this
proposition.

--
Piers

Reply via email to