Mathieu Bouchard <[EMAIL PROTECTED]> writes:
> On 12 Aug 2001, Owen Taylor wrote:
> > - User data stored with a structure should have an associated
> > notifier.
> > - Callback functions must take not just a function, but
> > a function,user data, destroy notifier combination.
>
> The first "associated notifier", is that a destroy notifier too?
Yes.
> is a destroy notifier the same thing as a destructor/finalizer ?
Not really. The destroy notifier is called when the library
is done with the user data. In many cases the language binding
will simply decrease a reference count on the language object
that the user data points to.
> > - Data structures should be one of:
> > * Immutable and refcounted.
> > * Copy by value.
> > * Copy by reference, reference counted, with destroy
> > notification and a user data facility for maintaining
> > persistant language <=> library associates.
>
> I see there is no mark+sweep garbage collection here?
> Ruby features mark+sweep.
> OTOH, Ruby has no reference counting of any kind.
Currently, few people are bold enough to make a library that is
intended to work with multiple different languages garbage
collection. If you have such a library, then you can change refcounted
to "garbage collected".
The library would then need to export functions for adding and
removing garbage collection roots, so that external callers can keep
objects alive.
Interfacing a garbage collected language with a refcounted library is
mostly straightforward ... you add a reference count when you create
the "wrapper object", and drop the reference count when the
wrapper is collected.
But whether the library or the binding are garbage collected, you
don't actually get a real benefit beyond reference counting until both
sides are using the same collector.
Regards,
Owen