Martin said:
A C++0x compiler must provide garbage
collection, which the programmer can
use on request
The garbage collection could be, as option.
Some time ago i have beleived, that garbage collection is only way to
support OO paradigm - dynamically created objects.
Fortunatelly, exploring moveable semantics, i have realized, that the same
(support of ownership) can be done with auto memory, at compile time,
without any overhead (in comparison with garbage collection).
With moveable, any dynamically created objects will have in fact the same
performance and reliability, as ordinary statically created in auto memory
objects.
The only differences between "garbage collection" and "auto owners with
moveable semantics", that:
- with moveable, user must exlicitly declare scope, in with his object
will be alive, in other words, user must explicitly tell to compiler: does
he want to destroy the object just now or does not;
- with garbage collection user just drops object in hope, that compiler
will delete it somehow.
The "dropping" leads to valueable overhead, especially in the places,
where auto owners with moveable semantics can be successfully used.
Moveable semantics requires compile time support (a trivial kind of
metaprogramming), that temporary can be done for C++ with the help of
"compile time attributes". The better way can be "protocols (states)" -
meta properties of classes. The "protocols" requires too many changes to
C++
.
Maksim A. Polyanin
http://grizlyk1.narod.ru/cpp_new