[antlr-interest] "finally" blocks

Paul J. Lucas pauljlucas at mac.com
Mon Jan 17 22:38:01 PST 2005

On Tue, 18 Jan 2005, Alan Gutierrez wrote:

> * Paul J. Lucas <pauljlucas at mac.com> [2005-01-18 01:13]:

> > 	I wasn't asking.  I think you're misquoting.  Terence was the
> > 	one who was asking.
>     Yes. I know. And if Terrence was asking if reliance of
>     destructors is prevelent in C++, in leiu of finally, I'm saying,
>     the answer is yes.

	OK, if you knew, then you intentionally misquoted (for reasons
	that aren't clear).

> > 	The lone standard such wrapper is auto_ptr<T>.
>     Boost has a number of such wrappers.

	I clearly said "standard": Boost isn't part of ISO C++.

>     I also consider the std::string, std::list, std::vector to be RAII
>     wappers.

	std::string is; std::list is, but only if T is an object that
	has a destructor.  If T is really MyObject*, then, although the
	list will be properly destroyed, all the MyObjects will be
	leaked.  Same with vector.

	In my own code, I've created variants of auto_ptr<T>, i.e.,
	various flavors of managed_ptr<T> that properly destroys the T
	object when the pointer to it gets destroyed.

	But I digress...

>     My mistake. I'll go back to saying, for C++, forget about it.

	And, IMHO, it's not such a bad thing.  A C++ programmer would
	never want to have a "finally" block in ANTLR anyway because a
	C++ programmer doesn't think about "finally" blocks at all
	since C++ doesn't have them.

	But a Java programmer wants/expects a "finally" block in ANTLR
	because Java has them.

	- Paul

More information about the antlr-interest mailing list