Topic: Exception handling -- was a finally block ever considered?
Author: Fredrik Jonsson <euafjo@uab.ericsson.se>
Date: 1996/03/21 Raw View
Jason D. Morris wrote:
>
> Ok, but that still doesn't answer my question. I didn't ask for a
> method for simulating a finally block, I asked if the committee had
> considered a finally block as part of the exception handling
> mechanism, and if they had, why it wasn't adopted.
>
> Jason
I know the finally statement was mentioned/discussed during
afterwork hours at the Santa Cruz meeting but unfortunately
that is about it. (I agree with you that it is very convenient
to have the finally block, and most Borland Delphi or Java
programmers will agree on that.)
Ie. the answer to your question would be no, it has not been
discussed, at least not as far as I know.
/F. Jonsson
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: bs@research.att.com
Date: 1996/03/22 Raw View
From: Fredrik Jonsson <euafjo@uab.ericsson.se> writes:
> Jason D. Morris wrote:
> >
> > Ok, but that still doesn't answer my question. I didn't ask for a
> > method for simulating a finally block, I asked if the committee had
> > considered a finally block as part of the exception handling
> > mechanism, and if they had, why it wasn't adopted.
> >
> > Jason
>
> I know the finally statement was mentioned/discussed during
> afterwork hours at the Santa Cruz meeting but unfortunately
> that is about it. (I agree with you that it is very convenient
> to have the finally block, and most Borland Delphi or Java
> programmers will agree on that.)
>
> Ie. the answer to your question would be no, it has not been
> discussed, at least not as far as I know.
A finally-clause on a try block was certainly considered during the
design of the exception handling mechanisms. I considered it ad hoc
and inelegant compared to the "resource requisition is initialization"
technique. Also, catch(...) has some of the properties (good and bad)
of a finally-clause. See for example sec 16.5 of D&E.
- Bjarne
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: jdmorris@ix.netcom.com (Jason D. Morris)
Date: 1996/03/13 Raw View
I would like to know if the following construct was ever considered by
the C++ and if it was, why it was rejected.
try
{
// some code that could generate an exception...
}
catch ( // some expected exception type )
{
// handler code
}
finally
{
// code that would be guaranteed to execute no matter how the
// function was exited.
}
Basically, a Java style finally clause. I also found it interesting
that Microsoft's structured exception handling under Win32 includes a
finally clause.
Jason
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: ebiederm@cse.unl.edu (Eric W. Biederman)
Date: 1996/03/16 Raw View
In article <31475017.8100207@nntp.ix.netcom.com> jdmorris@ix.netcom.com
(Jason D. Morris) writes:
I would like to know if the following construct was ever considered by
the C++ and if it was, why it was rejected.
try
{
// some code that could generate an exception...
}
catch ( // some expected exception type )
{
// handler code
}
finally
{
// code that would be guaranteed to execute no matter how the
// function was exited.
}
This can be written quite easily as I see it with C++, though the
structure is a little awkward.
Basically you just need to write a destructor. The code ordering is a
little less pleasant
Say,
func( ... )
{
class finally{
public:
~finally()
{
// code that would be guaranteed to execute no matter how the
// function was exited.
} finally;
try
{
// some code that could generate an exception...
}
catch ( // some expected exception type )
{
// handler code
}
}
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: jdmorris@ix.netcom.com (Jason D. Morris)
Date: 1996/03/17 Raw View
On 16 Mar 96 10:13:46 GMT, ebiederm@cse.unl.edu (Eric W. Biederman)
wrote:
>This can be written quite easily as I see it with C++, though the
>structure is a little awkward.
>
>Basically you just need to write a destructor. The code ordering is a
>little less pleasant
>Say,
>
>func( ... )
>{
> class finally{
> public:
> ~finally()
> {
> // code that would be guaranteed to execute no matter how the
> // function was exited.
> } finally;
> try
> {
> // some code that could generate an exception...
> }
> catch ( // some expected exception type )
> {
> // handler code
> }
>}
Ok, but that still doesn't answer my question. I didn't ask for a
method for simulating a finally block, I asked if the committee had
considered a finally block as part of the exception handling
mechanism, and if they had, why it wasn't adopted.
Jason
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]