🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Avner Ben Tue, 05 Dec 1995 19:45
RE: function try-block
#2874
Author: Avner Ben
Date: Tue, 05 Dec 1995 19:45
42 lines
1919 bytes
This message came out wrong in the process of transfer, so I subsmit
 it again:

The April draft mentions, in the chapter on exception handling, a
creature named __function-try-block__. The idea, if I get it right, 
is to allow the constructor of an assembly class to properly handle
exceptions that might occur in the constructors of its contained 
objects. Without this refinement (if the try block is inside the ctor 
function block) the local handlers  will not catch it - only handlers 
of the block that tried to create the object. I think this is a great 
idea. Unfortuantely, the DWG refrains from bringing examples, 
and I am not sure I could read the BNF precisely. Does

	function-try-block:
		try ctor-initializer-opt function-body handler-seq

mean the following crazy piece of code?

	FileOfRecords::FileOfRecords(const char* name, int size)
	 try {
	 : m_file(name), m_buffer(size)
	{
		// do stuff
	} catch(...) {
		// handle error
	}

The draft also mentions that function try blocks apply to destructor as
well. I can unsderstand the need for that. I also advices that the
exception handlers for function try blocks by rethrowing. This is
sensible too. But why call it "function try block?" can it be applied
to plain functions as well. What is this good for?

	Avner Ben | avnerben@netvision.net.il



---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads