php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #7765 not OO until automatic class destructor is added
Submitted: 2000-11-12 03:20 UTC Modified: 2002-04-27 14:00 UTC
From: shelby at DownloadFAST dot com Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 4.0.3pl1 OS: *
Private report: No CVE-ID: None

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-10-21 19:10 UTC] sniper@php.net
Couldn't find the information about for which report 
this was duplicate. And this is feature reques.

 [2001-10-23 13:54 UTC] shelby at DownloadFAST dot com
Thank you for keeping my feature request alive.

If I remember the discussions correctly, the implementation issue boiled down to the fact that PHP does not kill local variables at function or block termination (for speed reasons I believe).  In order to properly implement a destructor, the reference count for a variable needs to be decremented as the block scope of the declaration is exited.

I had suggested that this be a compile time flag, because correct program behavior is to do the reference decrements on block exit.  For those of us who want every possible tool to illuminate bugs (e.g. error_reporting( E_ALL)), this just adds another level of error checking on use of such constructs as global references on local variables, etc.

Again, perhaps this is not the main focus of PHP, but nevertheless I think it would be helpful option for developers who are writing huge OO sites with PHP.  It seems the incidence of such has increased greatly since I first made this report.

BTW, I do not know how my original comments got deleted.  I hope my memory of the issues is correct herein.  Apologies if I am mistaken.

Please take my comments constructively.


 [2001-10-23 14:42 UTC] shelby at DownloadFAST dot com
Thank you for keeping my feature request alive.

If I remember the discussions correctly, the implementation issue boiled down to the fact that PHP does not kill local variables at function or block termination (for speed reasons I believe).  In order to properly implement a destructor, the reference count for a variable needs to be decremented as the block scope of the declaration is exited.

I had suggested that this be a compile time flag, because correct program behavior is to do the reference decrements on block exit.  For those of us who want every possible tool to illuminate bugs (e.g. error_reporting( E_ALL)), this just adds another level of error checking on use of such constructs as global references on local variables, etc.

Again, perhaps this is not the main focus of PHP, but nevertheless I think it would be helpful option for developers who are writing huge OO sites with PHP.  It seems the incidence of such has increased greatly since I first made this report.

BTW, I do not know how my original comments got deleted.  I hope my memory of the issues is correct herein.  Apologies if I am mistaken.

Please take my comments constructively.


 [2002-04-27 14:00 UTC] jimw@php.net
ZE2 has destructors.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Sep 18 22:01:26 2024 UTC