delphi-run-time-library

Delphi FreeAndNil: Looking for an alternate implementation

偶尔善良 提交于 2020-12-05 12:24:53
问题 NOTE: Bear with me, I feel a little "flame grilled" due to some discussions over here and here and some issues I reported here and here. Some background Ye olde (pre 10.4) FreeAndNil looked like this: FreeAndNil(var SomeObject) The new and fresh FreeAndNil looks like this: FreeAndNil(const [ref] SomeObject: TObject); IMO both have their downsides: The old one doesn't do any type checking, so calling FreeAndNil on pointers, records and interfaces compiles just fine, but produces interesting

Delphi FreeAndNil: Looking for an alternate implementation

微笑、不失礼 提交于 2020-12-05 12:23:11
问题 NOTE: Bear with me, I feel a little "flame grilled" due to some discussions over here and here and some issues I reported here and here. Some background Ye olde (pre 10.4) FreeAndNil looked like this: FreeAndNil(var SomeObject) The new and fresh FreeAndNil looks like this: FreeAndNil(const [ref] SomeObject: TObject); IMO both have their downsides: The old one doesn't do any type checking, so calling FreeAndNil on pointers, records and interfaces compiles just fine, but produces interesting