On Tue, Mar 11, 2008 at 09:09:39AM -0400, Jonathan S. Shapiro wrote: > Problem: BY-REF parameters can escape: > > (define (outer x:'a) > (define (capture xc:(by-ref 'a)) > (lambda (y) > (pair y, x))) > > Note that "x" is in the call frame of OUTER, it is aliased by "xc", "xc" > is in turn captured by the lambda, and the lambda escapes. This is bad, > because we now have a heap-based object (the closure) that points back > into a stack-based object.
If I understand, once by-ref's have been included you've pretty much subverted your value/ref dichotomy. I.e. it's the strong distinction between value and ref's that ensure type safety and by-ref allows value types to be propagated to refs. As another, much more complicated solution, how about some limited form of region typing. Each pointer would be annotated with the (highest) stack frame it came from and if a pointer ever escapes from a frame with the same annotation then a compile error is thrown. Some form of parametrisation is also needed, which is where the (implementation) complexity arises when I think about it. I haven't thought about this much so it's probably full of holes, though I hope not! Sam _______________________________________________ bitc-dev mailing list [email protected] http://www.coyotos.org/mailman/listinfo/bitc-dev
