pmc_i_ops branch.

Vasily Chekalkin bacek at bacek.com
Mon Jun 8 06:58:13 UTC 2009


Patrick R. Michaud wrote:
> On Mon, Jun 08, 2009 at 10:07:06AM +1000, Vasily Chekalkin wrote:
>> Few days ago I created branch for implementing mathematical ops in term  
>> of i_ops. E.g. "c = add a, b" implemented as "c = a; c+= b". No test  
>> failures (actually I fixed some i_ops which was wrong before. E.g.  
>> Integer.i_add(Complex) and so on), so I'm going to merge this branch to  
>> trunk.
>>
>> Any objections?
> 
> I object, somewhat strongly.
> 
> If I'm reading the branch diff correctly, it appears to be
> replacing most instances of
> 
>        dest = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
> 
> with
> 
>        dest = SELF.clone();
> 
> However, these are not exactly the same thing.  In particular,
> I can imagine that a VTABLE_clone operation for some (derived)
> PMC types could be a lot more expensive than simply creating
> a new empty instance, which is what happens now.

Objection accepted. I can replace SELF.clone with pmc_new. OTOH, this 
behaviour is more consistent with HLL. Consider next example:

   $P0 = new ['somehll', 'Integer']
   $P1 = new ['somehll', 'Integer']
   $P2 = $P0 + $P1

With SELF.clone $P2 type will be ['somehll', 'Integer'] without any 
additional work from hll implementers.

-- 
Bacek


More information about the parrot-dev mailing list