FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » out of sheer curiosity...
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: out of sheer curiosity... [message #177574 is a reply to message #177564] Tue, 10 April 2012 11:44 Go to previous messageGo to previous message
Thomas Mlynarczyk is currently offline  Thomas Mlynarczyk
Messages: 131
Registered: September 2010
Karma:
Senior Member
Jerry Stuckle schrieb:

> In OO terminology, the correct term is "constructor". I'm not familiar
> with Python, so I can't say what Python calls it. But the name is not
> as important as the job.

True. But one still has to keep in mind that the constructor is not
constructing the object, but initializing it.

> Initialization is NEVER harmful if it is done properly. That's the
> whole purpose of initialization!. wakeup() is NOT a constructor - any
> more than sleep() is a destructor.

You would have to take extra measures to prevent re-initializing an
already initialized object. Your constructor would need to detect what
type of initialization is required (freshly created by `new`, cloned or
unserialized). While certainly possible, this would be cumbersome.
Different magic initializers are clearly the better way to go.

> wakeup() is not a constructor. If you consider it a constructor, then
> you must also consider sleep() to be a destructor - in which case it
> would be illegal to call the destructor after calling sleep().

__wakeup() is an initializer, just like __construct() and __clone(). And
__sleep() is still not a destructor -- see my earlier post.

> It is the opposite of wakeup() - just like __construct() is the opposite
> of __destruct(). You can't have it both ways.

I think we do agree that __sleep() is not a destructor. And maybe we can
agree that __construct(), __clone() and __wakeup() all perform
initialization tasks and thus could be all called "initializers".

Greetings,
Thomas


--
Ce n'est pas parce qu'ils sont nombreux à avoir tort qu'ils ont raison!
(Coluche)
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: 5.4 windows installer.
Next Topic: Does PHP5 treat $_SERVER['PHP_AUTH_USER']) differently?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 22 14:27:33 GMT 2024

Total time taken to generate the page: 0.04521 seconds