🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by Avner Ben Tue, 21 Nov 1995 20:47
function try block
#2685
Author: Avner Ben
Date: Tue, 21 Nov 1995 20:47
35 lines
1742 bytes
The April DWG 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
	}

			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. ]
Re: function try block
#2675
Author: David Vandevoorde
Date: Wed, 22 Nov 1995 03:23
24 lines
1333 bytes
>>>>> "AB" == Avner Ben <avnerben@netvision.net.il> writes:
In article <48tdsi$5o4@engnews1.eng.sun.com> Avner Ben <avnerben@netvision.net.il> writes:
[...]
AB> Does
AB> 	function-try-block:
AB> 		try ctor-initializer-opt function-body handler-seq
AB> mean the following crazy piece of code?
[Code adapted below]

I think that first brace is extraneous:

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

	Daveed

[ 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