as long as the objects being allocated are trivial and unlikely to fail i'd be happy with the given way.. certainly stuff like critical sections should be seperately try..finally'd.
points i'd make: in the typical case, doing it like this improves readability and maintainability. you're probably more like to introduce bugs by having more nesting of try..finallys. i'd be more interested in spending time eg to use FreeAndNil() instead of .free, to make invalid pointer use obvious. re paul's suggestion.. while technically theres nothing wrong with it, it'll add a couple of (innocent) compiler warnings that might obscure something more relevent. (unless you implement a Nil() procedure..). plus you're adding more lines of code to maintain etc.. (minor point) issues := nil; terrorists := nil; changes := TStringList.create; try issues := TIssuesList.create; terrorists := THardToFind.create; personally i'd like a switch so that delphi initialises local vars.. but thats just me :-) > is the following code ok? or should I give each it's own try..finally? > > -- > > changes := TStringList.create; > issues := TIssuesList.create; > terrorists := THardToFind.create; > try > > // stuff is done, planes flown. That type of things. > > finally > terrorists.free; > issues.free; > changes.free; > end; > __________________________________ Do you Yahoo!? Yahoo! Search - Find what you�re looking for faster http://search.yahoo.com _______________________________________________ Delphi mailing list [EMAIL PROTECTED] http://ns3.123.co.nz/mailman/listinfo/delphi
