<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Jan 10, 2017 at 6:14 AM, Michael Schnell <span dir="ltr"><<a href="mailto:mschnell@lumino.de" target="_blank">mschnell@lumino.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
If destroying an object is not necessary, the class should provide a dummy Free procedure. So the application programmer always can/should use Free.<span class="gmail-HOEnZb"><font color="#888888"><br><br></font></span></blockquote><div>Why dummy? if it should be like this</div><div><br></div><div>procedure TObject.Free;</div><div>begin</div><div>  if Self<>nil then Self:=nil;</div><div>end; </div><div><br></div><div>Destroying object is not necessary, but dereferencing is. </div><div>If the code keeps the reference to an object, it would not be collected.</div><div><br></div><div>For example. In pascal:</div><div>var</div><div>  b : TSomeClass;</div><div>begin</div><div>  b := TSomeClass.Create; // allocated</div><div>  ..</div><div>  b.Free;  // freed (b becomes an invalid pointer)</div><div>  ...</div><div>end.<br></div><div><br></div><div>JVM with dummy Free<br></div></div><div>var</div><div>  b : TSomeClass;</div><div>begin</div><div>  b := TSomeClass.Create; // allocated</div><div>  ..</div><div>  b.Free;  // does nothing (b remains a valid pointer)</div><div>  ...</div><div>end.// a might be freed after leaving  the scope of visibility</div><div><br></div><div><div class="gmail_quote">JVM with nil-ing Free.<br></div><div class="gmail_quote">var<br></div><div>  b : TSomeClass;</div><div>begin</div><div>  b := TSomeClass.Create; // allocated</div><div>  ..</div><div>  b.Free;  // derefering a, (a, become nil)</div><div><br></div><div>  ... // a might be Freed here somewhere, whenever gc occurs</div><div>end.</div></div><div><br></div><div>thanks,<br></div></div><div class="gmail_extra">Dmitry</div></div>