On Mon, Jul 10, 2017 at 3:46 PM, Graeme Geldenhuys <mailingli...@geldenhuys.co.uk> wrote: > Then lastly, you can even add a finally block in there too (Java calls this > try-with-resources).
No, that's not what try-with-resources is. This is try-with-resources: https://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html Any object which implements the interface AutoClosable is auto-closed in the try, regardless of an exception happening or not. Pascal is a little different, since it has destructors, so I guess in Pascal we could auto-free objects in a hypotetical try-with-resources in Pascal. Something like: try ( stringList := TStringList.Create; otherObj := TSomeOtherClass.Create; ) code here except exception block, optional end; And any object in the () section would be auto-freed, auto-checking if it was already created or not. -- Felipe Monteiro de Carvalho _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal