Delphi
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   Web Development Archives Mailing Lists Delphi

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Web Development Archives Sponsor:
  #1  
Old May 8th, 2008, 12:32 PM
Doug Hale
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
edit1.create

I went and looked at the assembly code for this - you are right - this
will not cause an exception (I even tried it).

The main reason it works is that Delphi does not need a valid object
pointer to call .Free - it is not a virtual method.

If Free were a virtual method, then a valid object pointer would be
required to call free.

Doug

Totoliciu Denis Dan wrote:
When I have posted that the following lines:
>

:= Nil;
Free();
>

do not raise an exception, I didn't have Delphi at
hand; but I knew that inside TFree() it is
written something like this:
>

procedure TFree();
begin
if Self <Nil then
Self.Destroy;
end;
>

The call to Free() through (that is Nil) goes K
because:
1. Free() is not a virtual method; and as we all know,
the binding is done at compile time. That means there
is no need to access a VMT.
2. Every method of a class has a hidden parameter; and
that parameter is Self. When calling Free, there is
no need that is different then Nil as (named
Self inside the method Free()) is passed as parameter.
>

Free() would raise an error when points to a
zone of memory that is not allowed to be accessed.
>

Reply With Quote
Reply

Viewing: Web Development Archives Mailing Lists Delphi > edit1.create


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT