develooper Front page | perl.perl6.internals | Postings from February 2002

Re: PMCs, setting, and suchlike things

Thread Previous | Thread Next
From:
Dan Sugalski
Date:
February 13, 2002 09:46
Subject:
Re: PMCs, setting, and suchlike things
Message ID:
a05101411b89055dc576e@[63.120.19.221]
At 3:43 PM +0000 2/13/02, Dave Mitchell wrote:
>Dan Sugalski <dan@sidhe.org> wrote:
>>  >So in the following:
>>  >
>>  >my Complex $c = 3+4i;
>>  >my $plain = 1.1;
>>  >$plain = $c;
>>  >
>>  >I presume that $plain ends up as type Complex (with value 3+4i)?
>>
>>  Yup.
>>
>>  >If so, how does $plain know how to "morph itself into the RHS's type"?
>>
>>  The general rule is: If a PMC is not a fixed type, it tosses its
>>  contents and becomes whatever's assigned to it. If it is a fixed
>>  type, it extracts what it can as best it can from the source and uses
>>  that.
>
>Thanks.
>I just want to assert/clarify that the job of "becoming whatever's
>assigned to it" is delegated to the src PMC, since $plain won't itself know
>how to do this?

Sort of--delegated to the source PMC's vtable in parts. The sequence goes:

    Destination PMC calls its own destructor, if it has one
    Destination PMC calls clone on the source PMC, passing itself in 
as the PMC to be cloned into.
-- 
                                         Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
dan@sidhe.org                         have teddy bears and even
                                       teddy bears get drunk

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About