Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.

Inside-Out Objects my %OBJECT_REGISTRY; sub Perl 5.10 for People Who Aren't Totally Insane

140.048 visualizaciones

Publicado el

Inside-Out Objects
my %OBJECT_REGISTRY; sub CLONE {
my %size; my $class = shift;
sub size {
my $self = shift; my @properties = map { values %$_ }
my $id = refaddr $self; values %PROP_DATA_FOR;

$self->register_object; for my $old_id ( keys %OBJECT_REGISTRY )
{
if (@_) {
return $size{ $self } = shift; my $object =
} else { $OBJECT_REGISTRY{ $old_id };
return $size{ $self }; my $new_id = refaddr $object;
}
} for my $prop ( @properties ) {
next unless exists $prop-
sub DESTROY { >{ $old_id };
my $id = refaddr $_[0]; $prop->{ $new_id } = $prop-
delete $size{ $id }; >{ $old_id };
delete $OBJECT_REGISTRY{ $id }; delete $prop->{ $old_id };
} }

sub register_object { weaken ( $OBJECT_REGISTRY{ $new_id } =
my ($self) = @_; $object );
my $id = refaddr $self; delete $OBJECT_REGISTRY{ $old_id };
$OBJECT_REGISTRY{ $id } = $self; }
} }




Hash::Util::FieldHash

Publicado en: Empresariales, Tecnología

×