Hi,
It has occurred to me that the ability to take references to objects combined
with the BitC's tagged unions might be dangerous. Can we take references to
the contents of a union? It would be nice if we could, safely. On the other
hand, if the union is mutable, it is important that programs not be able to
keep references to the contents of the union past the assignment. Because the
assignment might change which leg of the union is being used.
The following program probably isn't correct BitC 0.6, but I hope it conveys
the hypothetical problem scenario.
(defunion foo
(a int32)
(b . . .))
(define x:(mutable foo)
(a 10))
(define myfunc
(case x
((a int_from_a)
(let (r (ref int_from_a))
(begin
(set! x (b (. . .)))
(do_something r))))
((b ...)
(...))
)
))
do_something gets a reference to int_from_a, even though x is no longer in the
'a' branch of the union.
Reading the 0.6 BitC spec, I don't anything making this illegal. And it
doesn't seem that the (let (r (ref int_from_a))) does a copy of int_from_a. So
the above code should be illegal. Have I missed something?
--Eric
_______________________________________________
bitc-dev mailing list
[email protected]
http://www.coyotos.org/mailman/listinfo/bitc-dev