Chip Salzenberg <[EMAIL PROTECTED]> writes: > On Sun, Jun 12, 2005 at 03:15:22PM +0100, Piers Cawley wrote: >> But if you fallow the calling conventions that looks like: >> >> sub foo { >> $a = 1. >> $c = 10; >> print $c >> >> save_dollar_a_and_only_dollar_a_because_im_going_to_use_it_after_this_function_call >> foo() >> _implicit_label_for_return_continuation: >> restore_dollar_a >> _ooh_i_dont_have_to_save_anything >> $b = bar() >> _nor_do_i_have_to_restore_anything >> print $b >> } > > You have greatly misunderstood. We're talking about how &foo manages > its callee-saves registers. The registers involved, the ones that I'm > calling $a and $b, are P16-P31. > >> Of course, if you're going to actually use GOTO to get to some label >> that you should only get to via a continuation ... > > For purposes of allocating the callee-saves registers, a continuation > may as well _be_ a goto.
No it's not. A continuation should carry all the information required to restore the registers to the correct state when it is taken. A goto doesn't. For the purposes of allocating the registers in foo you can allocate $a to P16, and $b to p16, because when the call to bar takes the continuation back to bar, the 'restore' phase should grab $a from the continuation and bung it back on P16. The continuation doesn't even need to know where to restore $a to, because the 'caller restores' code should take care of that. > Don't feel bad, though. I thought the same thing the first time *I* > heard about this problem. I think you should have held that thought.