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

_______________________________________________
bitc-dev mailing list
[email protected]
http://www.coyotos.org/mailman/listinfo/bitc-dev

Reply via email to