From: Phil!Gregory Date: 19:02 on 07 Apr 2005 Subject: Ugly Code I hate having to write ugly code. (Yes, this is another Delphi hate.) I like the fact that Delphi supports exceptions; they make error handling easier: try // code // code // code except on EFooError do begin // handle error end; end; Exceptions also necessitate cleanup clauses. In Delphi that's try...finally: try ... finally // cleanup end; Of, course, many times, you want to both handle errors and clean up allocated resources. This is where Delphi gets ugly: try try ... except on EError1 do begin ... end; on EError2 do begin ... end; end; finally ... end; And don't forget that if you raise an exception in a finally clause it clobbers the preceeding exception: try try ... except on Exception do begin ... end; end; finally try ... except on Exception do begin ... end; end; end; Ugh. Not to start any language wars, but there are other syntaxes that I find much more attractive. For example: (if (null (catch 'exception (unwind-protect (code) (cleanup)))) (handle-error)) (Granted, it's less structured than Delphi, so the programmer has to impose his own structure, but it *looks nicer*.)
Generated at 10:28 on 16 Apr 2008 by mariachi