Tsomething(nil).SomeMethod and Tsomething(garbage).SomeMethod should halt the debugger.
- From: "Skybuck Flying" <nospam@xxxxxxxxxxx>
- Date: Fri, 30 Sep 2005 12:53:04 +0200
Hello,
First take a look at this short code/example which compiles and executes
just fine (in delphi 7) and then take a look at these two lines:
Tsomething(nil).SomeMethod; // nil reference
Tsomething(666).SomeMethod; // garbage reference
and then read the rest of the stuff and about me requesting a nice debugging
feature ;)
*** Begin of Code ***
program Project1;
{$APPTYPE CONSOLE}
uses
SysUtils;
type
Tsomething = class
public
mSomething : integer;
procedure SomeMethod;
end;
procedure Tsomething.SomeMethod;
begin
writeln('Hello');
end;
procedure Case1;
var
Something : Tsomething;
begin
Something.SomeMethod;
end;
procedure Case2;
var
Something : Tsomething;
begin
Something := Tsomething.Create;
Something.mSomething := 12345;
Something.Destroy;
// add watch: Something.mSomething and see the ghost value ;)
Something.SomeMethod;
end;
begin
writeln('program started');
Tsomething(nil).SomeMethod; // nil reference
Tsomething(666).SomeMethod; // garbage reference
Case1;
Case2;
readln;
writeln('program finished');
end.
*** End of Code ***
Data and methods are to be considered part of the object.
Tsomething(nil).SomeMethod; // nil reference
Tsomething(666).SomeMethod; // garbage reference
When this code is executed there is no object, so calling a method of a
non-existent object should report some kind of problem/error/runtime
error/exception/etc and halt the debugger right there and then ;)
For example:
Runtime error: "method call on non-existent object not allowed."
This would simplify debugging some what for the end users/programmers since
the debugger would halt on this line, instead of going into much deeper code
until some field of the object is accessed causing an access violation and
halting the debugger.
Checking for nil references doesn't "cut it" though ;)
I want the debugger to report a problem on these cases as well:
procedure Case1;
var
Something : Tsomething;
begin
Something.SomeMethod;
end;
procedure Case2;
var
Something : Tsomething;
begin
Something := Tsomething.Create;
Something.mSomething := 12345;
Something.Destroy;
Something.SomeMethod;
end;
In case1 the reference is simply pushed onto the stack and takes the
value/garbage of whatever is there.
In case2 the same thing more or less happens but now the value is pointing
to where the object used to be...
the user could be fooled into believing the object is still there because
some watches still show valid values etc ;) these values are ofcourse only a
"ghost" of the object that used to be there lol ;) <= it's dead you
motherfucker lol :P wieeeeeeeeeeeee hahaha.
Anyway,
Borland should get of it's lazy *** and implement some decent "debugging"
references which check if the object exists ;)
How hard could that be ? ;)
How much work would that be ? ;)
Bye,
Skybuck =(=OD)
.
- Prev by Date: Re: IcompleteInterface = interface(IsubInterface1, IsubInterface2, IsubInterface3) not possible ?
- Next by Date: Re: Layouts in Delphi?
- Previous by thread: Detecting Window
- Index(es):