On Fri, 14 Jun 2002, Nicholas Clark wrote:
: But surely an routine that calls another routine can potentially have its
: stack inspected by the caller?

Certainly.

: So it would only make sense for leaf nodes, and even then they might
: get inspected by overloaded values or methods on objects that were passed
: as parameters?

Yes.

: So is it possible to make it useful in a general case, or were you meaning
: that a subroutine can declare "I don't need to be on the stack", document
: itself as such, and then any indirect calls it makes don't get to see it
: (but at their own risk). It's still a form of action-at-a-distance, so
: is it that good?

Probably can't make the optimization unless we have the body and can
tell either that there are no indirect calls or that any indirect
calls made are known safe.  I can see some routines that could use
this optimization that couldn't use inlining (such as when we have
no guarantee against redefinition, except in that case you still have
to go indirect through the header).

: Or would the property of "I don't use caller or want" still be useful on a
: subroutine, because the run-time could determine that it would be
: inline-able (or whatever) inside a loop at run time, based on parameters
: passed to it? (and call it non-inline if the parameters were not base perl
: types)

Maybe.  I'm not an expert on run-time optimizations.  I just know that
the more info you have, the easier it is to know when you can get
away with a particular optimization.  And that there are advantages
and disadvantages to knowing anything at any particular stage.  And I
really like optional declarations, because then the programmer gets
to make the tradeoff.

Larry

Reply via email to