"Stut" <stuttle@xxxxxxxxx> a écrit dans le message de news: 47BC348E.1060604@xxxxxxxxxxxx > Sylvain R. wrote: >> "Chris" <dmagick@xxxxxxxxx> a écrit dans le message de news: >> 47BB6C80.6020704@xxxxxxxxxxxx >>> Sylvain Rabot wrote: >>>> Hello, >>>> >>>> First of all I would like to know if one day we will be able to unset >>>> $this into a class in order to destroy the object. It could really be >>>> useful to prevent big memory usage. >>> I doubt the php-dev's will ever allow something like that, seems rather >>> dangerous to me. >> >> Why ? It would be nice to stop thinking PHP developpers are idiots who >> don't know how to code. > > I don't see how that reply implies that opinion. I didn't mean to be rude but how a language structure could be dangerous ? You use it if you know how to otherwise you don't. I don't understand why we should not implement something because it could be bad used by some persons as far it useful for others. >> I don't mean unset($this) is the best wy to allow an object to destroy >> itself. I just say we miss something to auto destroy objects. >> We could also think about a magic method like __destroy(). > > An object that destroys itself is a really bad idea from an architectural > point of view. I, as a consumer of your class, need to have control over > the lifetime of any instances I create. In my opinion if you have a need > for a class to destroy itself then you have a fundamental design flaw. I want the object to be destroyed when a specific method of this object is called because when it has been called, the object has no reason to exist anymore. It's like a SQL resource, when you have freed it, you don't need it anymore. >>>> As it can't be done I tried to unset an object by unsetting a reference >>>> of this object but it has no effect on the object but only on the >>>> reference. >>>> >>>> Should unset destroy the reference itself and the object ??? >>> No, it's not meant to (and I doubt it will change). Why do you want it >>> to do that? >>> >>> What is the original problem you're trying to solve? >>> >> >> I put SQL resources into an objects and I would like to destroy objects >> when calling method free() but obviously I can't. > > I don't understand why you need to destroy the class instance to clear up > member variables. Or am I not understanding your diction? I would like to implement it in order to delete automaticly from memory useless objects. It can be really useful for example to make schedulers in PHP in order to avoid "max memory usage exceeded" errors. > -Stut > > -- > http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php