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
- RFC 159 (v1) True Polymorphic Objects Perl6 RFC Librarian
- Re: RFC 159 (v1) True Polymorphic Objects Nathan Wiger
- Re: RFC 159 (v1) True Polymorphic Objects David L. Nicol
- Re: RFC 159 (v1) True Polymorphic Objects Tom Christiansen
- Re: RFC 159 (v1) True Polymorphic Objects Jonathan Scott Duff
- Re: RFC 159 (v1) True Polymorphic Objects Nathan Wiger
- Re: RFC 159 (v1) True Polymorphic Objects Tom Christiansen
- Re: RFC 159 (v1) True Polymorphic Obj... Nathan Wiger
- Re: RFC 159 (v1) True Polymorphic Objects Piers Cawley
- Re: RFC 159 (v1) True Polymorphic Objects Nathan Wiger
- Re: RFC 159 (v1) True Polymorphic Objects Damian Conway
- Re: RFC 159 (v1) True Polymorphic Objects Tom Christiansen
- Re: RFC 159 (v1) True Polymorphic Objects Damian Conway
- Re: RFC 159 (v1) True Polymorphic Objects Tom Christiansen
- Re: RFC 159 (v1) True Polymorphic Objects Jeremy Howard
- Re: RFC 159 (v1) True Polymorphic Objects Bennett Todd
- Re: RFC 159 (v1) True Polymorphic Objects Nick Ing-Simmons
