Hi Bart,
Sorry for the late reply, I'm spending way too much on the first of my two promised posts, which gets longer and longer :-( but on the bright side I think that it also allowed me to find some good examples and rationales on why to do things a certain way. I hope that I can send a first version in about 24 hours. It will most likely only discuss typeset without -u. However, I think that it may still address some of the questions that you raise here.
For now, just two very quick answers.
The question is, is this OK? Or should return from i have set the
scope all the way to g? That has different side-effects in other
circumstances.
I think that I have an example without -u that exhibits a similar behavior, probably for the same reason. I think that the latter or something more similar to the latter should be done. I will have more explanation in my post.
Thinking further about this, I think a better solution is that when a
referent goes out of scope, the reference loses the -u property along
with it, and just becomes a "normal" named reference that moves to
lower levels as the scopes unwind.
I will have to have a closer look at this but my first impression is that the -u property should be kept, actually for the same rationale as the one for the change above.
Philippe