🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #2874

RE: function try-block

#2874
From: 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. ]
Technical Details
Message-ID: <01BAC353.36913DA0@ts32p14.NetVision.net.il>
Path: arc1-ca.pugleaf.net!howland.reston.ans.net!agate!agate!Matt

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!howland.reston.ans.net!agate!agate!Matt
From: Avner Ben <avnerben@netvision.net.il>
Newsgroups: comp.std.c++
Subject: RE: function try-block
Date: 05 Dec 1995 19:45:45 GMT
Organization: <none>
Approved: Matt@Austern
Message-ID: <01BAC353.36913DA0@ts32p14.NetVision.net.il>
NNTP-Posting-Host: austern.hip.berkeley.edu