[pypy-dev] Yet another trace tool!

Richard Emslie rxe at ukshells.co.uk
Mon Aug 30 18:36:50 CEST 2004


Hi Armin,

On Mon, 30 Aug 2004, Armin Rigo wrote:

> Hi Richard,
>
> On Sat, Aug 28, 2004 at 10:22:31PM +0100, Richard Emslie wrote:
>> Also BTW you can't overload c++ return types - unless you know something I
>> don't.
>
> That's right, but it's not necessary.  The C version (genc.h) has a type code
> for return type too (e.g. OP_ADD_iii) but that's only so that typer.py can
> know what the return type will be, and convert it if needed.  In general I
> don't think we need to overload on the return type.  If we define only:
>
>  Int op_add(const Int&, const Int&)
>  Ref op_add(const Ref&, const Ref&)
>
> and then do:
>
>  someref = op_add(someint, someint)
>
> then the first signature will be choosen and the return type will be
> automatically converted from Int to Ref, which is fine.
>

I get it (partially). :-).  Either we only support ops which explicitly 
match the signature and convert the return type via a temporary or 
not-so-obviously let c++ create a temporary when passing in a const c++ 
reference (c++ : why???  if it wasn't reference then fair enuf... but 
*sigh*).

"""
   Int i;
   Ref r;
   r = op_add(i, i); // calls Int op_add(const Int&, const Int&)
                     // converts return type :-)

   r = op_add(i, r); // i converted to Ref as temporary  :-(
"""

but I assume the latter is not what you mean.

Actually,  to make things more explicit - I would prefer to only have an 
assignment operator for Ref:

class Ref... {
   ...

   Ref & operator= (const Int &ref) {
     ...
     return *this;
   }

}

Cheers,
Richard



More information about the Pypy-dev mailing list