On Fri, Oct 4, 2013 at 11:09 AM, Jonathan S. Shapiro <[email protected]>wrote:

>
> extern f(bS: borrowed String);
>
> let s = "abcdefg"
> in
>   f(s);
>
>
> Note that /s/ is not live after the call. In fact, if the architecture
> specifies that parameters are placed in register %param1, the compiler is
> completely free here to place /s/ in %param1. This has the effect that if a
> GC occurs during the call to f(), there are no witnessably live references
> to that string.
>

I am by no means a rust expert, but AFAIK Rust's semantics do not agree
with your explanation.

A Rust borrowed pointer has a "named lifetime" associated with it (which
can be implicit). The semantics of borrowing is a test (and/or assertion)
that the variable must live at least for the duration of f(s), if not
longer.

Since Rust is not heavily tied to it's GC system (and it may be removed), I
suspect there is no attempt to take s out of scope even directly after
calling f(). I suspect s only goes out of scope at the end of it's
functional block.

The lifetime test in f(s) therefore is asking "will s survive the call
duration? (a) it's a stack variable in the containing scope... great, then
it does. (b) it's a static global variable... great then it does. (c) it's
a GC variable that someone is tracking.. great than it does"
_______________________________________________
bitc-dev mailing list
[email protected]
http://www.coyotos.org/mailman/listinfo/bitc-dev

Reply via email to