[Moscow.pm] Прокомментируйте, плиз
Dmitriy T.
403rus на gmail.com
Чт Мар 13 03:59:01 PDT 2008
Alex Kapranoff wrote:
Ну вообще вроде уничтожаются - хотя может я не так понял чего-то...
Вот из доки по Class::Std
DESTROY()
Every class that loads the Class::Std module automatically has a
|DESTROY()| destructor, which automatically cleans up any attributes
declared with the |:ATTR()| trait (see below).
It is almost always an error to write your own |DESTROY()| in any
class that uses Class::Std. You almost certainly want to write your
own |DEMOLISH()| instead. See below.
В Object::InsideOut тоже вроде всё хорошо:
Object::InsideOut exports a |DESTROY| method to each class that deletes
an object's data from the object field arrays (hashes). If a class
requires additional destruction processing (e.g., closing filehandles),
then it must provide a subroutine labeled with the |:Destroy| attribute.
This subroutine will be sent the object that is being destroyed:
sub _destroy :Destroy
{
my $obj = $_[0];
# Special object destruction processing
}
The |:Destroy| subroutine only needs to deal with the special
destruction processing: The |DESTROY| method will handle all the other
details of object destruction.
По поводу скорости не скажу ничего - не мерял, замечу только что один из
плюсов который прописан для Object::InsideOut:
Object::InsideOut offers all the capabilities of other inside-out object
modules with the following additional key advantages:
* Speed
When using arrays to store object data, Object::InsideOut objects
are as much as 40% faster than /blessed hash/ objects for fetching
and setting data, and even with hashes they are still several
percent faster than /blessed hash/ objects.
Врут? Или лукавят?
>
> Например, пишете деструкторы, так как inside-out objects не умеют уничтожаться автоматически.
>
> Например, пишете медленные программы, так как PBP требует полной инкапсуляции всех
> атрибутов, а цена вызова функции высока :)
>
> --
> Moscow.pm mailing list
> moscow-pm на pm.org | http://moscow.pm.org
> http://mail.pm.org/mailman/listinfo/moscow-pm
Подробная информация о списке рассылки Moscow-pm