Agree the disarm is ugly , i hate this type of code in Dispose, hard to
track and see.
Hard to say without seeing more of the code , cant the unwind code be a
method / Func delegate you pass in if its common code ? you can also use a
helper something like
Object TryFInHelper ( Func<?,?> code ,Action<bool , int> fin)
{
try{
bool iscompleted = false;
var ret = code();
completed = true;
return ret;
}
finally
{
fin ( completed0;
}
}
though it seems to me with an interface on InputMarker ( or a wrapper
around marker ) you can get do better but i cant say if it fits in .
GenericParser(IMarker marker)
{
var completed = false;
try{
foreach ( var thing in marker.Things )
thing.Parse();
var result = marker.BuildAST();
completed = true;
return result;
}
finaly {
if ( result == false)
{
m_tokenPos = marker.tokenPos;
marker.Dispose();
}
//FIXME do we need to dispose on success ?
}
}
class Parse {
ParseSomeNonTerminal(...)
{
return GenericParser ( new InputMarker(tokenStream))
}
}
}
On Tue, Aug 27, 2013 at 10:37 PM, Jonathan S. Shapiro <[email protected]>wrote:
> On Tue, Aug 27, 2013 at 5:16 AM, Bennie Kloosteman <[email protected]>wrote:
>
>> Why not use try / finaly for more control ...
>>
>
> Because the extra boilerplate, when multiplied across 100 functions or so,
> is a *lot* of places that need to be changed if the unwind code (which is
> common code) changes.
>
> _______________________________________________
> bitc-dev mailing list
> [email protected]
> http://www.coyotos.org/mailman/listinfo/bitc-dev
>
>
_______________________________________________
bitc-dev mailing list
[email protected]
http://www.coyotos.org/mailman/listinfo/bitc-dev