Re: attack of silly coding standard?
On Dec 7, 4:29 am, =D6=F6 Tiib <oot...@hot.ee> wrote:
On Dec 6, 7:08 pm, James Kanze <james.ka...@gmail.com> wrote:
C is a low-level procedural language, yes. How it deals with
low-level resource management is up to the programmer, however.
And the SESE structured programming idiom has very little to do
with it, having been developed for entirely different reasons.
Yes SESE and other structured programming idioms were developed to get
rid of wild goto spaghetti in multi-thousand-lines functions. When did
you last see such code passing review anyway?
Yesterday:-). (OK, it wasn't multi-thousand lines. But there
was a loop spanning 150 lines.)
Without going to the extreme of thousand line functions, Ian
posted an example here which really should have been two
functions. An example which probably would have passed review
as well.
So these reasons are not that actual anymore.
It is certain that the importance of SESE goes down when the
functions become smaller and more succinct. But given the
choice of writing something in a way very easy to prove correct,
or in a way slightly less easy (even if still not difficult),
why not chose very easy.
The only reason
left for SESE in C is to ease the cleanup phase of resource
management. Are there other reasons left?
The initial reason: reasoning about program correctness.
[...]
With C++ most of us expect RAII (OOP) idiom to be used to let
destructors to deal with releasing resources instead of
explicit resource management of C. That is most robust and
simple way.
And? What does that have to do with the original question? Or
OO?
Resources are therefore always bound and handled as objects/parts of
objects. Not something external managed outside of objects manually.
So my impression is that RAII means that C++ style OOP is used for
resource management.
OO generally implies dynamic polymorphism. At least according
to the classical texts (Booch, etc.).
--
James Kanze