Re: Array of pointer-to-functions
Scott Lurndal <email@example.com> wrote:
If you remove RAII from C++, you might just as well go back to C.
That's ridiculous. The class paradigm (data encapsulation) is enough
of a benefit, without RAII, without templates, without exceptions, to
make using C++ (or a subset thereof) useful for kernel development.
That would be such a crippled version of C++ that it would hardly be
No generic data containers, no smart pointers, no automatic memory
management of any kind, inefficient pseudo-generic data containers and
algorithms (such as the horrid qsort()). In fact, for such objects to be
even slightly usable you would in practice have to limit the objects to be
dynamically allocated only, with no possibility of creating stack-based
objects, no copying objects, no handling them by value (because all those
require RAII to work properly).
(Yes, you could allow copying objects and handling them by value,
effectively making them C structs with support for member functions.
But without constructors, destructors and assignment operators, and
especially without being able to forbid them, it would be really
error-prone. Instantiate eg. a string "pseudo-object", inadvertently
assign it to another such object, and you have a problem.)
This would in fact be similar to Objective-C (which likewise has no RAII,
no constructors, no destructors, no assignment, cannot handle objects by
value, no templates), except that in Objective-C you at least have a
useful messaging system (which allows all kinds of neat stuff that isn't
possible even in full-fledged C++).
I don't see all that much difference between that crippled C++ and just C
(using structs and free-floating functions).