2018-03-08 9:13 GMT+01:00 Ryan Joseph <r...@thealchemistguild.com>: > The more efficient approach would clearly be something like: > > procedure MyProc; > var > list: stack TList; // assume this allocates us on the stack like a > record > begin > list.Clear; // there’s no Create call so init the class some how > list.Add(x); > // Free() is called when MyProc goes out of scope > end;
Small ad of mORMot (main author Arnaud Bouchez aka ab) : with SynCommons module you have nice utils for such things: procedure MyProc; var list: TList; begin with TAutoFree.One(list, TList.Create) do begin list.Add(x); { ... some other stuff with list here } end; // <-- here is called list.Free end; There is also nice module AutoScope which uses management operators (!) by Dmitriy Pomerantsev aka pda0: https://github.com/pda0/AutoScope -- Best regards, Maciej Izak
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal