Date: Mon, 16 Feb 2009 10:57:12 +0200 From: Andriy Gapon <avg@icyb.net.ua> To: Andrew Reilly <andrew-freebsd@areilly.bpc-users.org> Cc: Christoph Mallon <christoph.mallon@gmx.de>, Marcel Moolenaar <xcllnt@mac.com>, Bruce Simpson <bms@incunabulum.net>, freebsd-current@freebsd.org Subject: Re: weeding out c++ keywords from sys/sys Message-ID: <49992A68.8010702@icyb.net.ua> In-Reply-To: <20090216055602.GA70145@duncan.reilly.home> References: <4995BB1B.7060201@icyb.net.ua> <20090213231513.GA20223@duncan.reilly.home> <4997F105.5020409@icyb.net.ua> <499811DF.6030905@incunabulum.net> <20090215151318.0d17bfb9@ernst.jennejohn.org> <499835BE.3000705@gmx.de> <8EF8771C-76D8-4556-96B2-B97B35573CBD@mac.com> <49986ABB.5040207@gmx.de> <20090216055602.GA70145@duncan.reilly.home>
next in thread | previous in thread | raw e-mail | index | archive | help
on 16/02/2009 07:56 Andrew Reilly said the following: > The problem with C++ isn't really the functions that it > provides, it's the functions that it doesn't. Personally, I'd > like C++ a *lot* better if it required a garbage collecting > runtime. The problem with the way it works at the moment is > that object creation interacts with argument promotion and > constructors (and C++'s ability to grab references inside the > guts of objects, whch it inherited from C) in such a way that > you can have temporary object creation inserted by the compiler > in the middle of an expression, with no way to ensure that > the resulting object is reaped at the right time. And that's > because the compiler can't, in general, know what is the right > thing to do: if the called function retains the reference in a > long-lived structure then the temporary should be constructed > on the heap, and explicitly freed somewhere else. If it isn't > retained, then the temporary object should be collected as > the expression scope is exited. Since there's no way for the > compiler to make that call, you almost inevitably wind up with > either memory leaks or you constrain yourself to operate with a > restricted, not-quite-object-oriented style, which can't really > be enforced by the compiler. I don't need to mention what a bad > idea memory leaks are in kernel mode, right? This is the first time in my life that I hear about temporary objects on the heap and/or memory leaks through temporary objects. Either you are remembering a bug in some ancient C++ compiler or you are referring to some buggy code. As to the conversions through constructors, conversion operators and implicit type promotions - I personally had much less incidents because of that than I had incidents in C with passing/casting something incorrect via void*. This is to say that C++ is far from perfect and there are languages that are much better than it, but C is even (much) less perfect. And of all languages out there, I think, that C++ comes closest to a definition of "enriched", "better", "fortified" C. Which implies much lower entry barrier (and possibility for limited/gradual introduction). -- Andriy Gapon
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?49992A68.8010702>