Dan Sugalski <[EMAIL PROTECTED]> wrote:
> Ah, the joys of Supreme Executive Power!

Look 'ere - Supreme Executive Power resides in a mandate from the masses,
not some farcical aquatic ceremony... :-)


> We really have three separate but related needs:
> 
>    *) Shallow register copy. (set) This just copies a value from one 
> register to another, or sticks a pointer to a constant into a register.
> 
>    *) Deep copy (assign). This takes the contents of one structure (string 
> or PMC) and stuffs it inside an existing string or PMC. (So the string or 
> PMC structure remains, but the buffer is changed)
> 
>    *) Clone with toss (clone). This takes a register pointing to a string 
> or PMC, creates a new one that's identical to it, and puts the pointer to 
> it in the destination register.

In terms of vtable methods, I'm trying to get it clear in my head
how a perl scalar assignment would be implemented, eg $dst = $src.

Presumably the bytecode stream would contain an assign op. This op
would call $dst->vtable->assign($src) -ie the target is control of
how it gets assigned to. For most simple types (ie those not involving the
Perl6 equivalent of perl 5's magic), the assign method just falls
through to the clone method of the src, ie

void assign(PMC *dst, PMC *src) {
        src->vtable->clone(dst);
}

or to put it another way, the dst declares "there's nothing special about me,
allow the src to go ahead and write all over me".

For a dst type that needs special handling, (eg $.), its assign method
might look more like:

void assign(PMC *dst, PMC *src) {
        current_fh->lineno = src->vtable->get_int();
}

Does the above overlap in any way with the Dans Eye view of the world?

Dave.

Reply via email to