Hi,
As discussed at YAPC::Europe, here's my suggestions for two new core
PMCs to handle:
* References to a particular element in an aggregate type
* References to a register
The second of these needs an opcode to create it, which I have
proposed a name for. The first of them I'd *like* to have an opcode to
create for consistency, but we can do it by passing stuff to
parameters to the PMC initialization method I *think* (can we?).
These are basically working in .Net and the plan is to move the
functionality into the core, as well as complete the safety stuff in
the Parrot core to really get the "weak reference" semantics when
referencing a register.
Anyway, suggested PDD patch attached. Comment away. :-)
Jonathan
Index: docs/pdds/clip/pdd17_basic_types.pod
===================================================================
--- docs/pdds/clip/pdd17_basic_types.pod (revision 14383)
+++ docs/pdds/clip/pdd17_basic_types.pod (working copy)
@@ -115,6 +115,30 @@
The PMC that represents a reference to another PMC. Delegates all functions to
the referred-to PMC.
+=item AggregateElementRef
+
+This PMC represents a reference to an element contained in an aggregate PMC
+type, such as an array or hash. It is initialized with the key being
+referenced and the aggregate PMC containing that key.
+
+Note that assigning to the reference PMC will be equivalent to a keyed set on
+the referenced aggregate PMC - that is, it modifies the element rather than
+doing a v-table call on the element itself. It is important to be aware of
+this when assigning a PMC through this reference; it is not the same behaviour
+as the Ref PMC.
+
+=item WeakRegisterRef
+
+This PMC represents a weak reference to a register. Should the reference live
+beyond the context containing the register that it references, any attempt to
+use the reference will throw an exception.
+
+A weak register reference can only be created by the C<register_ref> opcode.
+Any assignment to the register will behave like a set instruction. That is,
+when assigning a PMC using a WeakRegisterRef PMC, the register will be updated
+to reference that PMC rather than calling the assign v-table call on the PMC
+in that register. This is not the same behaviour as the Ref PMC.
+
=item Random
A singleton PMC that generates a random number. {{ NOTE: Why do we have