Today I discovered an interesting compiler feature. In other languages it is quite common that you can do the following with an object:
which is equivalent to:
if ( Assigned( obj )) then ...
While not possible with standard pascal libraries you can get the feature in pascal if you overload the assignment operator:
operator := ( obj: TObject ): Boolean;
begin
Result:= Assigned( obj );
end;
I think it the code is still understandable but shorter. This could also be applied to other types as pointers or ints and so on. But I think there it is less understandable.
What do you think, is this bad programming practice if used locally inside a library?