At 07:54 AM 8/6/00 -0400, John Tobey wrote:
>On Sun, Aug 06, 2000 at 01:24:10AM -0400, Dan Sugalski wrote:
> > John Tobey wrote:
> >  > Picture this.  A Lisp (or Java, ...) structure holds a Perl
> >  > interpreter.  A Perl variable holds a reference to the Lisp structure.
> >  > Structure and interpreter become inaccessible to all threads.  Perl
> >  > will never know it's done with the Lisp structure, neither Perl nor
> >  > the structure will ever be collected, and we will have defeated
> >  > mark-and-sweep.
> >
> > FWIW, this isn't a case I'm worried about. If an embedding program doesn't
> > explicitly destroy an interpreter, then its reasonable to assume that the
> > interpreter's not dead and shouldn't be cleaned up after--if someone's
> > leaking interpreters then, well, they've got bigger problems than the odd
> > foreign object. :)
>
>I'm not so sure I agree with this.  Other-language modules in a large
>application might have good reason to use a private Perl interpreter
>within an encapsulated interface.

That's fine. It should trash the interpreter when it's done, at which point 
we clean up. If it doesn't trash the interpreter when it's done, then 
someone made a whoops.

>Anyway, my point is valid for data structures other than
>interpreters.  Lisp variable `perl-int' holds an interpreter, which
>contains a by-Perl-unreferenced anonymous scalar, which contains a
>Lisp structure, which contains a reference to the scalar.
>
>
>       ------------     ---------------------
>       |         |     |            |
>       |  Perl -------->| SCALAR(0x8335bfc) |
>       |         |     |       |            |
>       ------------     --------|------------
>                                |   ^
>                                |   |
>                                V   |
>                           |-----+--|--|
>                           |     |  |  |
>                           | car | cdr |
>                           |     |     |
>                           |-----+-----|
>
>If Perl uses reference-counting as its only garbage collection, this
>loop will have to be broken explicitly.  But if we anticipate possibly
>implementing mark-and-sweep, our mark routine should call Lisp's mark
>routine on those Lisp objects we still reference, which would allow
>those we don't to be collected.

I'd rather perl didn't touch things owned by other languages. We can call 
the "we're done" routine on the foreign object and let it deal with the 
possibility of garbage.

                                        Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
[EMAIL PROTECTED]                         have teddy bears and even
                                      teddy bears get drunk

Reply via email to