This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: __attribute__((cleanup(function)) versus try/finally
- From: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- To: Jason Merrill <jason at redhat dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: 08 May 2003 13:58:54 +0200
- Subject: Re: __attribute__((cleanup(function)) versus try/finally
- Organization: Integrable Solutions
- References: <wvladdzc0lz.fsf@prospero.boston.redhat.com>
Jason Merrill <jason@redhat.com> writes:
[...]
| > o Mark (and others) are against adding try/finally and favor adding
| > a different extension: __attribute__((cleanup(function)) which is
| > "lighter" in a sense.
|
| I agree with Alex's comments on this approach; it's trying to introduce the
| C++ object model into C, which seems like rather a backwards way to
| approach exception cleanliness.
Well, whatever is put in C will (implementation-wise speaking) end up
in C++. Therefore if you try to put try/finally in C then you've got to
think about how it is suposed to work with C++. And if there is an
existing or close to existing mechanism in C++ to achieve those effects
then I think it makes sense to write out the C++ approach and try to
see which bits can be safely added to C. There is nothing backward in
that approach. Rather, it looks rather smooth.
In the past kbunch ox extensions have been added to C without thinking
about how they would intereact with the rest of the langage and the
rest of C++. I believe that is clearly a bogus way to extend C.
-- Gaby