This becomes a bit less efficient when we're looking at intermediate values of expressions. Something like:
a = b + c + d
turns to
new $P0, SomeIntermediateType add $P0, b, c add a, $P0, d
Well...how about this:
1. Have all vtable methods which take a dest return a PMC *.
2. If dest is NULL, it's filled with the appropriate type before anything else is done.
3. At the end of the method, there's a "return dest;".
Thus, an op like add should be written like:
op add(inout PMC, in PMC, in PMC) { $1=VTABLE_add(interpreter, $2, $3, $1); /* or whatever */ }
This does mean checking if dest == NULL at the beginning of each vtable function, but other than that, it's fairly clean. It might even be possible for pmc2c to insert this code automagically. (I believe PMC registers are initialized to NULL, so it should Just Work most of the time, and there's always the null_p op when you need to do it explicitly.)
-- Brent "Dax" Royal-Gordon <[EMAIL PROTECTED]> Perl and Parrot hacker
Oceania has always been at war with Eastasia.