Re: Denial of denial of service

[prev] [thread] [next] [lurker] [Date index for 2007/01/30]

From: Andy Armstrong
Subject: Re: Denial of denial of service
Date: 09:33 on 30 Jan 2007
On 30 Jan 2007, at 04:01, Peter da Silva wrote:
>> try / finally.
>
> Unless there's some magic involved, you still have to keep track of  
> where you are in the try block so you can unwind things properly.

I think this may be the nub of the debate.

Ideally the try block shouldn't need much in the way of cleanup. It's  
a bit like a database transaction; if you hit an exception you should  
be able to walk away from it (rollback) without doing too much  
cleanup. If the block completes then it should commit as its last  
action.

That's much easier to achieve if you have garbage collection which I  
assume you don't.

Garbage collection isn't just about automatically freeing memory;  
it's about making the question of who's responsibility it is to free  
memory moot. I've seen (and written) plenty of C/C++ that's  
effectively hamstrung by the need to know who owns each object.

> And so does the guy calling you, and so does the guy calling him,  
> and any function simple enough it doesn't need to keep track of  
> which failed function it needs to clean up after likely only calls  
> one function with the potential of throwing a "non-exceptional  
> exception".

I guess when you say "clean up" you're talking about freeing memory  
and releasing resources? If you're going to use exceptions  
effectively you should try to avoid the need for cleanup other than  
that. Ideally you shouldn't have to actually reverse any changes in  
the event of an exception - just a quick tidy up and then walk away.  
And it should be possible to do that for a whole try block without  
knowing how far you got through it before the exception was thrown.  
All of which is made easier by the presence of GC.

-- 
Andy Armstrong, hexten.net

There's stuff above here

Generated at 23:01 on 06 Feb 2007 by mariachi 0.52