At 06:42 PM 1/13/01 -0800, Benjamin Stuhl wrote:
>How is setting one SV from another going to be implemented?
>My (admittedly vague) recollection was that it would be
>something like
>
>void sv_setsv(SV* dest, SV* src)
>{
>    dest->sv_vtbl->delete(dest); /* clear the old value */
>    dest->sv_vtbl = src->sv_vtbl;
>    dest->sv_vtbl->dupfrom(dest, src); /* and copy in the
>new */
>}
>
>That is, in $a = $b, $a would get a new vtbl, the one from
>$b. My question is how does this work with the need for
>assign-by-value, which is required for things like ties and
>overloads?

The assignment will look like this in bytecode:

   sassign dest_scalar, source_scalar;

and proably like this in C:

   dest_scalar->vtable[ASSIGN](source_scalar);

or, more directly, the destination scalar is responsible for handling the 
assignment. Passive scalars will generally toss their contents, reassign 
their vtables, and copy the data, possibly after doing some type checking. 
(If, for example, a variable was a locked type it wouldn't necessarily do this)

The vtable method for active data will extract what it needs from the 
source scalar and Do Magic with it.

                                        Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
[EMAIL PROTECTED]                         have teddy bears and even
                                      teddy bears get drunk

Reply via email to