Piers Cawley <[EMAIL PROTECTED]> wrote: > I've been trying to implement a Parrot port of xUnit so we can write > tests natively in parrot and things were going reasonably well until I > reached the point where I needed to do exception handling.
> Exception handling hurt my head, badly, so eventually I gave up and > used a continuation instead. Did it not work? > ... Here's the basic 'run' and 'exception > failure' parts of my code (The current full suite is in the tar file > attached): > .sub run method > .param pmc testResult > .local Sub handler > .local Sub exceptRet > .local pmc name ^^^^^^^^ > .local string nameString > name = self."name"() [ ... ] > self.name() - self.name() + .local string names + names = name + self.names() > Now, depending on whether I use C<handler()> or C<handler>, teardown > gets run 3 (handler()) or two (invoke) times. The problem with continuations is: The register allocator isn't aware of them. Register usage get's messed up. You can only use lexicals or globals in your catch handler. Its basically the same problem as with Jens' example. > conti = newcont _end > with > new conti, .Continuation > set_addr conti, _end > which is weird because I *thought* they were supposed to do equivalent > things. They are equivalent, except that register usage is different, the return continuation is saved in a different register and voila instead of returning from the sub the continuation is invoked again. leo