On Sun, Apr 20, 2008 at 12:17 AM, Andy Lester <[EMAIL PROTECTED]> wrote:

> Just popping in to say that we cannot const any parms to vtable methods.
>  Parrot can't impose promises on the called code.

So take for example In default.pmc the method get_class:

VTABLE PMC *get_class() :const

That is expanded in default.c as:

PMC  *
Parrot_default_get_class(PARROT_INTERP, const PMC *pmc)

And inside this function:

INTVAL type = VTABLE_type(interp, pmc);

And VTABLE_type is:

#define VTABLE_type(interp, pmc) \
   (pmc)->vtable->type(interp, pmc)

The type of the 'type' function is:

typedef INTVAL (*type_method_t)(PARROT_INTERP, PMC* pmc);

pmc points to non const PMC.

So we have a problem. If vtable method params can't be const, a const
method can't call any vtable function without a cast removing
constnes, as long as the :const attribute is mapped in C to a const in
SELF.

So it looks like if vtable methods can't be const, then pmc methods
can't be const at the C level without a nightmare of casts adding and
removing constness.

--
Salu2

Reply via email to