Una curiosidad: Si una variable de objeto es nil y utilizamos algunos método o propiedades de este objeto, sobre todo lo referente a mensajes de Windows, no se produce un access violation, en el caso que quede apuntado a una dirección inválida si sucede.
Código:
Var
MyEdit : TEdit;
begin
MyEdit := Nil;
ShowMessage( MyEdit.Text );
He preguntado sobre esto a Borland, y un tercero me respondió:
Cita:
It's a feature!
Such mistakes results normaly in AV and in this case in mal function.
With pascal we(!) have to write code that prevents us for this mistakes.
MyEdit.Text results in:
function TControl.Perform(Msg: Cardinal; WParam, LParam: Longint): Longint;
var
Message: TMessage;
begin
Message.Msg := Msg;
Message.WParam := WParam;
Message.LParam := LParam;
Message.Result := 0;
if Self <> nil then WindowProc(Message);
Result := Message.Result;
end;
Sorry, but it's not so nice that you fill QC with such senceless information.
Probably start a diskussion in borland.public.delphi.language.objectpascal
for testing every access to any TObject for a valid address. See what the community will say about this.
|
Saludos!