[bitc-dev] Pair-consing vs. by-ref

Jonathan S. Shapiro shap at eros-os.com
Tue Jul 8 10:02:35 CDT 2008


Just to illustrate the problem with by-ref, consider:

  (f (x : (by-ref int)  y:int))

converted to pair-consed form:

  (f (pair (by-ref int) int)))

The simple possibility of this type means that it is now possible to
write instead:

  (define (f x:(pair (by-ref int) int)) x)
  f: (pair (by-ref int) int) -> (pair (by-ref int) int)

with the effect that a by-ref parameter can now escape. Which is bad,
because we now have a dangling pointer into the stack. It is certainly
possible to successfully restrict this in the type system by performing
region analysis and/or escape analysis, but at the moment we have not
implemented this check (it isn't currently needed).

If we implement something like (apply-1 f the-pair-type), I suspect that
we would really be forced into the region analysis.


shap



More information about the bitc-dev mailing list