Dan Sugalski wrote:
>   TheObj *foo;
>   SV *new_sv;
>   foo = new TheObj("A parameter");
>   sv = perl_new_sv();
>   perl_make_sv_object(sv, "Some::Package", foo, &dispatch_routine,
>                                                 &destroy_routine);
> 
>   perl_return(perl_make_ref(sv));

Are you really thinking about keeping "SV *" and two-level refs
and all that? That sounds an awful lot like the current internals.

I'd like to see *minimal* overhead for simple scalars -- if we
could cram immediates (like small integers and booleans) directly
into the "SV *" that seems like a big win.

For foreign objects, I'm not sure why you're forcing a two level
dispatch. Why not let the foreign code register dispatches directly
in the scalar's vtbl? If we did it that way, a foreign object
is just:

[SV *] --> [type_code, flags, pointer]

The type_code defines the vtbl to use when calling an op on
the object. Calling an op is just calling vtbl[type_code].the_op(SV *).
We're immediately into the foreign code so foreign objects can have
method calls as fast as built-in types.

In other words, the perl_new_sv() and the perl_make_ref(sv)
functions seem unnecessary. Adding a perl_make_type() seems useful.

Here's code I'd like to see:

   Perl_Vtbl foo_glue;
   ... initialize foo_glue (C++ inheritance would be useful)
   Perl_Type foo_type = perl_make_type(&foo_glue);

   TheObj *foo;
   foo = new TheObj("A parameter");
   perl_return(perl_make_sv_object(foo_type, foo));

- Ken

Reply via email to