Posts

Showing posts from July, 2020

Pass the Dog, Get the Cat

This story begins with the FreeAndNil procedure, why its signature could not have a typed var parameter, why we can only pass variables declared as TObject to such procedures, and why the compiler refuses to compile if we try passing any other variable type even if it is a descendant of TObject . procedure FreeAndNil(var Obj); So why does the compiler enforce this behavior? If we take a look at the FreeAndNil implementation and imagine it with a typed var parameter, it may seem that the compiler is throwing us curve balls for nothing. There is nothing we do inside that procedure that would warrant a compiler error for passing TObject descendant types: assigning variable to another TObject variable - pass assigning nil to original variable - pass freeing original object instance stored in temporary variable - pass procedure FreeAndNil(var Obj: TObject); var Temp: TObject; begin Temp := TObject(Obj); Pointer(Obj) := nil; Temp.Free; end; var Obj: TSomeObject

Why some people cannot use dark themes?

Olivier Sannier answers that question in his posts about astigmatism and its impact on everyday software usage: https://www.linkedin.com/pulse/astigmatism-part-1-starry-effects-olivier-sannier/ https://www.linkedin.com/pulse/astigmatism-part-2-blurry-effects-olivier-sannier/ Blog version: https://www.obones.com/en/more/blog/astigmatism-part-1 https://www.obones.com/en/more/blog/astigmatism-part-2 French version: https://www.obones.com/more/blog/astigmatisme-partie-1 https://www.obones.com/more/blog/astigmatisme-partie-2