> -----Original Message-----
> From: Piers Cawley [mailto:[EMAIL PROTECTED]]
> "Jonathan Sillito" <[EMAIL PROTECTED]> writes:
> > get_counter:
> >     new_pad 1
>
> Doesn't this violate the 'caller saves' principle, making it hard to
> do tail call optimization? Would it make sense to move the creation of
> a new pad into the Sub's invoke method?
>

I am not sure how this violates the 'caller saves' principle, unless you
mean that the caller should be saving its own scratch pad if necessary? I
did notice that this is in pdd03:

"The caller is responsible for preserving any environment it is
interested in keeping. This includes any and all registers, lexical
scoping and scratchpads, opcode libraries, and so forth."

I suppose scratchpads could be an exception, to this?

I have to think more about the tail call optimization. I am not sure how
putting the creation of the new pad into the sub's invoke method would help,
it still seems like it would be created each time the method was invoked
(which seems equivalent to putting a new_pad instruction at the top ... On
the other hand, if the instruction is left to the PASM for some subs it
could easily be optomized away by the compiler. Or maybe it could be
conditional?

  get_counter:
    new_pad 1
  get_counter_no_new_pad:
    # etc

Would this address the problem? Or am I missing somthing?
--
Jonathan Sillito

Reply via email to