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

Home » Imported messages » comp.lang.php » Operator precedence
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Object constructors/destructors [message #185149 is a reply to message #185147] Sun, 02 March 2014 20:42 Go to previous messageGo to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma:
Senior Member
On 3/2/2014 2:28 PM, Richard Damon wrote:
> On 3/1/14, 2:22 PM, Jerry Stuckle wrote:
>> On 3/1/2014 12:56 PM, Richard Damon wrote:
>>> On 2/27/14, 8:25 AM, Jerry Stuckle wrote:
>>>> On 2/26/2014 11:49 PM, Richard Damon wrote:
>>>> > On 2/26/14, 8:44 AM, Jerry Stuckle wrote:
>>>> >> On 2/26/2014 7:50 AM, Richard Damon wrote:
>>>> >>>
>>>> >>> An the "name" of the Deserializing constructor in PHP is __wakeup().
>>>> >>>
>>>> >>> You also do NOT get two destructor calls on the same object, the
>>>> >>> deserializing created a new object.
>>>> >>>
>>>> >>
>>>> >> __wakeup() is not a constructor - and does not do the same thing.
>>>> >>
>>>> >
>>>> > What makes it NOT a constructor? IT seems to be exactly the thing that
>>>> > does what you say must be done to make the new object via
>>>> > unserialization.
>>>> >
>>>>
>>>> If you want to consider __wakeup() to be a constructor, then you must
>>>> consider __sleep() to be a destructor. In that case, PHP is also wrong
>>>> because if an object is serialized, it will call both __sleep() and the
>>>> destructor. This would be two calls to destructors for the same object.
>>>>
>>>
>>> WHY does __sleep() need to be a destructor?
>>>
>>> __sleep() is a function to control how an object is serialized, and the
>>> object, as you seem to know, still exists, so no destructor should
>>> happen at this point, in fact, if you look at it, __sleep() has not
>>> expected to have any effect on the current object, its purpose is to
>>> make sure that __wakeup() will get all the data it needs, and allow the
>>> removal of data that it won't need.
>>>
>>
>> If you are going to claim __wakeup() is a constructor, then you have to
>> agree that it's opposite (__sleep()) is a destructor. Otherwise you are
>> being inconsistent.
>>
>> You can't just make up rules as you see fit!
>>
>
> Then why are you claiming that something that isn't a desturctor must be
> one.
>

I'm not - you're the one claiming __wakeup() is a constructor, but it's
opposite, __sleep() is not a destructor.

> Serialization, creates an external representation for an object, that is
> what __sleep() is part of. This does NOT inherently involve the
> destruction of the object (at least at that point).
>

Then __wakeup() does NOT inherently involve creation of an object.

> Deserialization, on the other hand, creates an object from an external
> representation. so it will involve the construction of a new object (you
> can do "in-place" deserialization in some languages, where you first
> create a dummy object, and then fill it in with the external data, but
> this is normally a clumsy way to define it).
>

Not in other languages. It builds from an already existing object where
the constructor has been called.

> Note that the object oriented paradigm does have asymmetry in it. A
> given type will tend to have multiple constructors, for the different
> ways that an object might come into existence. There is usually only one
> destructor. In PHP, one of these constructors is called __construct()
> which is the general purpose constructor. (unlike in other statically
> type languages, we can only define one of these). PHP also lets us
> define a piece of the deserialing constructor with __wakeup() (PHP does
> some of the heavy lifting here in parsing the serialized data and
> setting up the object, __wakeup() is just required to do any final
> needed operations after the values have been set.)
>

Constructors are constructors, and the destructor is a destructor. No
asymmetry there. Except in PHP.


--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex(at)attglobal(dot)net
==================
[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
Previous Topic: Correlating curl resources to some other object.
Next Topic: Experienced Web designer required
Goto Forum:
  

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

Current Time: Sat Nov 30 23:12:46 GMT 2024

Total time taken to generate the page: 0.05153 seconds