At 3:31 PM +0100 12/14/04, Leopold Toetsch wrote:
Dan Sugalski <[EMAIL PROTECTED]> wrote:
At 10:19 AM +0100 12/14/04, Leopold Toetsch wrote:

 Which does argue that it ought not be a sub, I suppose, but something
 simpler. A plain bsr sort of thing.

A bsr doesn't change anything. It has to return to the caller. That thing, where it's returning to, is alive.

I'm only concerned about overhead here. Live-ness is a separate issue. (An important one, but separate. That's dealt with below)


>>If the cleanup handler is a plain subroutine, the previous one, which
should be cleaned, is alive. A lazy DOD will find the filehandle in the
lexicals and likely in registers.

 Well, maybe. Subs are going to have multiple scopes in them (which
 argues for a faster-than-sub cleanup handler dispatch) so it's more
 than just a 'cleanup before leaving the sub' sort of thing. There's
 an awful lot of code around that looks like:

      sub foo {
          # Insert code here
          foreach (@some_array) {
          }

          {
             # Some code that needs its own block
          }
          if (foo) {
          } else {
          }
     }

 Besides cleaning up on sub exit, there's also a potential cleanup
 when the foreach is left, the bare block is left, and each of the
 legs of the if are left. (Potentially once on each foreach iteration,
 I suppose)

Yes. I'll presume that the first Perl6 compiler will just emit closures for each block.

Ah, I hope not. I *really* hope not. (Paying attention Patrick? :) That'd be rather slower than necessary in most cases.


[Snippage]

But that still doesn't solve the problem that a file-handle (after
cleaning lexicals) is still in a PMC register, when the C<sweep 0>
opcode is run.

True but, and this is the good part, that's not our problem. It is, I think, safe to assume that language compilers that want timely destruction will make sure to clean up after themselves sufficiently to make that timely destruction possible. It's our job to provide the mechanisms they need, and leave it to them to use them as needed.


In other words, we punt it to someone else. :)
--
                                Dan

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

Reply via email to