"Chip Salzenberg" <[EMAIL PROTECTED]> wrote:
On Tue, Jan 24, 2006 at 12:11:14AM -0000, Jonathan Worthington wrote:
.NET has these managed reference thingies.  They're basically like
pointers, but safe.  [...]
Making them work on Parrot is no problem.  Making them work without
comprimising the safety of the VM is harder.  Amongst the things you can
get a pointer to are parameters and local variables. Under .NET that means
stack locations; with Parrot that means registers.
Indeed, and yet pointing to registers is not as fatal as you might
imagine, nor does it require restructuring the VM by e.g. adding a
register type.

This is good news, and the kinda solution I was hoping for.  :-)

The trick is to keep references to registers in a way that notices
when the register set is gone, or alternatively, that keeps the
register set from going away.  The latter is already achieved by the
default LexPad implementation.

Looking at it, I kinda see where you're coming from, but just stashing away and ensuring a LexPad PMC gets marked for a long as the reference gets marked is not enough, as a LexPad PMC doesn't control lifetime of a context structure, which is responsible for the registers. OTOH, taking a closure does keep the context and thus register frame in place, which is perhaps what you meant and seems workable.
Therefore, the representation of a safe pointer to a register would
not, in fact, be a pointer to the register's storage in memory, but
rather a weak reference (or, conceivably, a strong one?  I doubt it)
plus an integer register number.
A weak reference to the closure PMC, I assume? I think we don't have weak references yet though, but that can be fixed up in the future. Ah, and the reference might not be to an integer register, but that's just detail...
Is a pointer to a register the only tough case?

Other cases are pointer to an array element and pointer to a field. However, I really don't want to be messing around with referencing into memory managed by the PMC that could move, so the plan is that the managed reference PMC will hold a reference to the array PMC plus the element number (or object PMC and field name). Yes, performance will not be amazing, but that ain't really the goal.
And in what way is this different from the Reference type we're going
to have to make work just for e.g. the Perl backslash operator?

Probably not much, apart from that I'd like it to work now.  ;-)

Many thanks,

Jonathan

Reply via email to