alan.gauld at bt.com
Mon Mar 12 15:50:21 CET 2001
Werner Schiendl wrote:
> Unsafe is somewhat the same topic I think: It's a question
> of disciplined use.
I think one problem with C++ is the number of temporary objects
it creates. Calling a seemingly innocuous function with some
object references as paramrters may or may not involve the
creation of many temporary objects. Since these objects may be
subclasses the programmer may not be able to determine how
much memory will be alloocated by the function call mechanism
and in a minimalist memory system it can cause a crash which
appears inermittent and non deterministic.
In C, by virtue of its fixed primitive types, is much easier
to gurantee what will happen by way of memory allocation etc.
> > There's the feeling that you never quite know what it's
> > going to do.
Temporary objects being one such case. Others include the use of
operator overloading, function overloading vv default parameters
etc etc. C++ is a maintenance nightmare compared to C - I speak
from 18 months painful experience maintaining a large C++ system!
> You can have the same in C++ (using one or more static objects,
> or construct the objects just once when booting)
Even here the compiler will cause tempoiray object copies to
occur when passing object references around. Static objects are
not as 'static' as we might like to think!
> This is nothing more difficult than in C.
Sorry but it is. There's just so much less lurking under
the hood in C.
> > One of the particular unsafe things in C is error handling,
> C++ exceptions at least make sure the error _is_ handled
This bit I tend to agree with. I'm not sure what the original
poster had in mind here...
More information about the Python-list