This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: __attribute__((cleanup(function)) versus try/finally


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]