On 3 August 2013 03:52, Jonathan S. Shapiro <[email protected]> wrote: > On Fri, Aug 2, 2013 at 8:20 AM, Matt Rice <[email protected]> wrote: >> >> On Sat, Jul 27, 2013 at 1:29 PM, Jonathan S. Shapiro <[email protected]> >> wrote: > However when region polymorphism is introduced at procedure parameters and > return values this becomes less clear. Objects in a caller region can now be > manipulated by a callee. The lifetime of a region is still bounded by the > stack frame in which it is allocate [*], but it's no longer easy to point at > a single stack frame and say "that's the [single] frame in which this region > can be touched".
You didn't add the footnote you mentioned there, but I think that for those that have particular questions about regions, once you have that AH! moment and grok regions, this paragraph will take on new meaning. Shap said: > The lifetime *of a region* is bounded by the stack frame in which *it* is > allocated This need not be the stack frame that the *value* was allocated in. The return case is illustrative, because a function can return a reference to a fresh list of dynamically determined length and still have accurate lifetimes inferred by the region analysis! Clearly the list itself can't be allocated on the stack, so what is going on? A region system can tell us that references into a region do not escape, may escape, or clearly escape via the return value. When a region escapes via return, region inference requires that the caller take responsibility for disposal of the region (usually, specifically the value). It is perfectly acceptible for the value itself to live on the heap. I find the most thorough introduction to regions to be Mads Tofte and Lars Birkedal: "A Region Inference Algorithm", ACM Transactions on Programming Languages and Systems, Vol 20, No 5, July 1998. It builds on a lot of earlier work, but is quite readable, and introduces enough effect types to describe how we can really say that "the caller takes responsibility for disposal", above, even though the hacker may not have added any region annotations to the program. -- William Leslie Notice: Likely much of this email is, by the nature of copyright, covered under copyright law. You absolutely may reproduce any part of it in accordance with the copyright law of the nation you are reading this in. Any attempt to deny you those rights would be illegal without prior contractual agreement. _______________________________________________ bitc-dev mailing list [email protected] http://www.coyotos.org/mailman/listinfo/bitc-dev
