[Prev][Next][Index][Thread]

Re: Object lifetime management



On 7/11/01 4:30 PM, Brad Settlemyer, wrote:

> And then they don't give me a well supported polymorphic way
> to manage those resources (ala C++ destructors).

Again, what exactly is the problem with macros of the with-* ilk? This is
how resource management of the type you allude to has been done in Common
Lisp for years, and it's where Dylan gets this style of resource management.

Just as you must write your own destructors in C++, you may have to write
your own with-my-resource-type macros in Dylan (when you use resources for
which macros don't yet exist). The macro would, of course take care of
resource allocation and cleanup by expanding into a block of code with the
allocation at the beginning (raising an exception if the resource was
unavailable, etc.), the client code wrapped in the middle, and cleaning up
(deallocating the resource, raising exceptions if problems arise, etc.) at
the end. How is this different than having to write such code in C++
constructors and destructors?
-- 

Raffael Cavallaro, Ph.D.
raffael@mediaone.net



References: