Not only is there nothing technically wrong with Paul Needham's suggestion (ie...
> issues := nil; > terrorists := nil; > changes := TStringList.create; > try > issues := TIssuesList.create; > terrorists := THardToFind.create; ...) but it also won't create any compiler warnings if you follow that formula - because there is nothing to warn about. While it does have two more lines of code than the potentially unsafe example that Nahum kicked this thread off with, it is still shorter than every other safe solution that I know of. For example it is shorter than nested try's and it is shorter than Neven's very similar suggestion which had one extra unnecessary line setting StringList1 to nil (which may also have the undesirable consequence of raising a hint/warning). Cheers, David Brennan. DB Solutions Ltd. > > 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; > > > _______________________________________________ Delphi mailing list [EMAIL PROTECTED] http://ns3.123.co.nz/mailman/listinfo/delphi
