fix codetest failure - ASSERT_ARGS does not have a ; after and
[parrot.git] / docs / pdds / pdd17_pmc.pod
blobddc64da426652906509fd06213812a4760a4090f
1 # Copyright (C) 2001-2010, Parrot Foundation.
2 # $Id$
4 =head1 PDD 17: Polymorphic Containers
6 =head2 Abstract
8 This PDD describes the internal structure and behavior of the Polymorphic
9 Container (PMC) data type.
11 =head2 Version
13 $Revision$
15 =head2 Description
17 PMCs implement all internal data types more complex than a simple integer,
18 float, or string, and also the data types of high-level languages.  Nothing
19 outside the core of Parrot (in fact, nothing outside the data type's vtable
20 routines) should infer anything about a PMC.
22 This does mean, though, that you need to either know what functions are
23 available and what they do, or have some method of finding out. Parrot defines
24 a standard set of functions that each PMC provides. More complex features are
25 constructed out of these fundamental building blocks.
27 =over 4
29 =item - PMCs contain both state and behavior
31 =item - PMCs can inherit from other PMCs
33 =item - PMCs can be composed of low-level roles
35 =item - High-level objects can subclass low-level PMCs
38 =back
40 =head2 Implementation
42 =head3 Internal structure
44 All PMCs have the form:
46     struct PMC {
47         Parrot_UInt flags;
48         VTABLE *vtable;
49         DPOINTER *data;
50         PMC *_metadata;
51     }
53 C<flags> holds a set of flags associated with the PMC; these are documented
54 in F<include/parrot/pobj.h>, and are generally only used within the Parrot
55 internals.
57 C<vtable> holds a pointer to the B<vtable> associated with the PMC. This
58 points to a set of functions, with interfaces described in L<Vtable Functions>
59 that implement the basic behaviour of the PMC (i.e. how it behaves under
60 addition, subtraction, cloning etc.)
62 C<data> holds a pointer to the core data associated with the PMC. This
63 may be null.
65 C<_metadata> holds internal PMC metadata (properties). See the setprop/getprop
66 ops in F<docs/ops/pmc.pod>.
68 C<_synchronize> is for access synchronization between shared PMCs.
70 PMCs are used to implement the basic data types of the high level languages
71 running on top of Parrot. For instance, a Perl 5 C<SV> will map onto one (or
72 more) types of PMC, while particular Python datatypes will map onto different
73 types of PMC.
75 =head3 Defining PMCs
77 PMCs are declared by the C<pmclass> keyword:
79   pmclass <name> [ <modifier> ... ] {
80   }
82 The modifiers specify core features, such as:
84 =over 4
86 =item abstract
88 The PMC cannot be instantiated. (By convention, abstract classes are given
89 lower-case names.)
91 =item no_init
93 Don't generate class initialization code (don't set up a vtable for the PMC).
94 Used with C<abstract>.
96 =item dynpmc
98 The PMC is a dynamic PMC, so generate special class initialization code
99 suitable for dynamic loading at runtime.
101 =item singleton
103 The PMC is a singleton, created in the constant PMC pool.
105 =item no_ro
107 Don't create a second read-only vtable for the PMC. (Used, for example,
108 by STM's C<share_ro()>.)
110 =item is_shared
112 The PMC is shared (across threads).
114 =item extends
116 Inherit from another PMC. Takes one argument, the name of the PMC to inherit
117 from.
119 =item does
121 Compose a role. Takes one argument, the name of the role to compose. [NOTE:
122 this modifier has been taken from the older feature C<does> which is now
123 called C<provides>.]
125 =item resolves
127 Resolve a conflicting vtable function, method, or attribute from a composed
128 role by using the same named vtable function, method, or attribute from the
129 current C<pmclass> or C<prole>.
131 =item provides
133 The PMC satisfies a particular low-level interface, which gives some
134 assurances on how and where a PMC can be used.
136 Roles composed with C<does> may also define C<provides> for one or more
137 interfaces. (They generally define at least a C<provides> corresponding
138 to their own name.)
140 =over 4
142 =item * C<array> is an aggregate PMC with numerically-keyed elements
144 =item * C<hash> is an aggregate PMC with string-keyed elements
146 =item * C<library> corresponds to a dynamic library
148 =item * C<ref> references another PMC
150 =item * C<string> behaves similarly to the base string type
152 =item * C<integer> behaves similarly to the base int type
154 =item * C<float> behaves similarly to the base number type
156 =item * C<boolean> does true/false only.
158 =item * C<scalar> (only used by the sample src/dynpmc/foo.pmc)
160 =item * C<event> can be used with event queue
162 =back
164 =item hll
166 Declare the PMC in an HLL namespace other than the default HLL 'parrot'.
167 Takes one argument, the name of the HLL.
169 =item maps
171 Map the current PMC to a core PMC type for code declared in a particular
172 HLL. May only be used together with the C<hll> modifier.
174 =back
176 =head4 Defining attributes
178 The attributes of a PMC (both public and private) live in a custom
179 struct for the PMC, stored in the C<data> member of the C<PMC> struct.
180 The standard way of declaring attributes is with C<ATTR> within the body
181 of a C<pmclass> or C<prole> declaration.
183   ATTR <type> <name> [ :<modifier> ... ];
185 This declaration is used to generate the data struct for the PMC
186 (named "Parrot_<pmcname>_attributes").
187 The data struct incorporates any attributes declared
188 in a composed role or inherited class. Composed attributes are inserted at the
189 end of the generated struct. Inherited attributes are inserted at the top of
190 the generated struct, so the struct members shared by the parent and child are
191 in the same position, and code compiled for direct struct access to the parent
192 can also perform the same direct struct access on the child.
194 The declaration is also used to generate accessor macros, C<GET_ATTR_attrname>
195 and C<SET_ATTR_attrname>, to set up helper information for the C<inspect>
196 vtable function, and to provide attribute access through the default
197 C<get_attr> and C<set_attr> vtable functions.
199 It's also possible to define and store the PMC's data struct manually,
200 but the standard declaration syntax must be used in roles, in PMCs that
201 compose roles, and in PMCs that will be subclassed by high-level classes
202 (this means all core PMCs, and most non-core PMCs).
204 Low-level PMCs that use multiple inheritance (C<pmclass> declarations with
205 more than one C<extends> entry) have to be careful with the contents of their
206 structs. There's no problem if the two parents have identical data struct
207 members. But, if the two parents have different data struct members, any
208 vtable functions inherited from the parents will not be able to directly
209 access the parents' struct members or use the accessor macros. The solution is
210 to either override those vtable functions that directly access data struct
211 members in the child PMC, define the parents as roles instead of classes, or
212 declare the multiply inheriting child in PIR or an HLL.
214 =head4 Defining vtable functions
216 Vtable functions are defined as C functions within the body of the C<pmclass>
217 declaration, and are marked with C<VTABLE>.
219   VTABLE STRING *get_string() {...}
220   VTABLE void set_string_native(STRING *value) {...}
222 Within the body of vtable functions, several shortcuts are provided:
224 =over 4
226 =item INTERP
228 The current interpreter object.
230 =item SELF
232 The current invocant by dynamic type.
234 =item STATICSELF
236 The current invocant by static type.
238 =item SUPER
240 Calls the current method in the nearest superclass, using the dynamic
241 type of C<SELF>.
243 =item STATICSUPER
245 Calls the current method in the nearest superclass, using the static
246 type of C<SELF>.
248 =back
250 =head4 Methods
252 Methods are declared in the body of the C<pmclass> or C<prole>
253 declaration with C<METHOD>.
255   METHOD inspect(STRING *what :optional, int got_what :opt_flag) {...}
257 =head3 PMCs and Namespaces
259 Like high-level classes, low-level PMCs are tied to a corresponding
260 namespace. By default this is a namespace with the same name as the PMC
261 in the 'parrot' HLL, but the C<hll> modifier in the C<pmclass>
262 declaration selects a different HLL.
264 Accessing a core PMC type from within an HLL other than 'parrot'
265 requires the same steps as accessing a class from another HLL, first
266 retrieving the namespace object, and then instantiating from that
267 namespace.
269 =begin PIR_FRAGMENT
271   $P0 = get_root_namespace ['parrot'; 'Integer']
272   $P1 = new $P0
274 =end PIR_FRAGMENT
276 HLLs can choose to provide direct access to Parrot's core PMC types by
277 aliasing them within the HLL namespace.
279 =head3 Inheritance
281 PMCs can inherit behavior and state from other PMCs. Inheritance is performed
282 in the C<pmclass> declaration using the C<extends> keyword.
284   pmclass Foo extends Bar {
285   }
287 =head3 Composition
289 Composition is another form of code reuse in PMCs. Unlike inheritance,
290 composed roles aren't complete stand-alone PMCs, they are just bundles of
291 behavior and state that can be used within the composing PMC. As such, roles
292 are never instantiated directly, and are never translated to C directly. They
293 have no core structs, though they define attributes to be added to the PMC
294 they are composed into.
296 When a PMC that uses a role is translated to C, the role provides vtable
297 functions, methods, and attributes that will be added to the generated C
298 code for that PMC. Composed vtable functions, methods, and attributes
299 are not permitted to have the same name as corresponding features
300 defined in the composing PMC. This is called a conflict, and must be
301 explicitly resolved in the composing PMC. When composed features have
302 the same name as inherited vtable functions, methods, or attributes, the
303 composed feature overrides the inherited feature, just as it would if
304 defined in the composing PMC.
306 Roles are defined using the C<prole> keyword.
308   prole <name> <modifiers> {
309   }
311 Roles can compose other roles, but they can't inherit.
313 Role attributes are defined using the same format as PMC attributes.
315 Core roles live in src/role and have a file extension of C<.pr>.
317 Roles are composed into a PMC with the C<does> modifier.
319 =head3 PMCs and high-level objects
321 High-level objects, as specified in PDD15, need to be able to inherit
322 from PMCs. Subclassing a low-level PMC from a high-level class makes an
323 entry in the high-level class's list of parents.
325 For PDD15 objects, there is a corresponding instance of the C<Class>
326 PMC. For a low-level PMC, however, the class definition is written in C
327 and compiled away. There needs to be something placed in the parents
328 list for a PDD15 class, that can provide access to the low-level PMC's
329 vtable and methods, and define the storage that the low-level PMC will
330 need within the high-level object. That something is the C<PMCProxy>
331 PMC. Like a PDD15 class, it is stored as the C<class> element in the
332 namespace associated with a PMC, provides introspection facilities and
333 can sit in an inheritance hierarchy.
335 The PMCProxy PMCs are only created when needed for subclassing a low-level
336 PMC, to avoid a large load of unused PMCProxy objects. When created, they are
337 cached in the class slot of the namespace corresponding to the low-level PMC,
338 so they are only created once.
340 Therefore, subclassing a PMC looks, at a PIR level, like subclassing a high
341 level class.
343 =begin PIR_FRAGMENT
345   $P0 = get_class 'Hash'
346   $P1 = newclass 'MyClass'
347   addparent $P1, $P0     # The new class inherits from the Hash PMC
349 =end PIR_FRAGMENT
351 Or, more briefly:
353 =begin PIR_FRAGMENT
355   $P1 = subclass 'Hash', 'MyClass'
357 =end PIR_FRAGMENT
359 PMCs store state in a very different way to PDD15 objects. When a method
360 inherited from a PMC is called on a PDD15 object, that method needs to
361 access the attributes of the inherited low-level PMC. Further, if
362 multiple PMCs are inherited from, they may each have attributes with the
363 same name, that need to be correctly "visible" to the PDD 15 object
364 according to the laws of inheritance. Users of Parrot at a PIR level
365 should not have to care about such issues.
367 To enable attributes from the low-level PMC to act as full inherited
368 attributes in the child class, the PMCProxy class will create a set of
369 PDD 15 attributes that correspond in type and name to the attributes
370 declared with C<ATTR> in the declaration body of the low-level PMC, as
371 if each had been added with C<add_attribute>. It will also override the
372 C<GET_ATTR_attrname> and C<SET_ATTR_attrname> functions to point to the
373 PDD 15 attributes (with automatic boxing and unboxing for the PMC
374 values) rather than to members of a C struct.
376 The PMCProxy will also scan the low-level PMC for methods declared with
377 C<METHOD> and insert them in the proxy class as if each had been
378 declared with C<add_method> (possibly with a shim to standardize calling
379 conventions, but hopefully the calling conventions are similar enough
380 between C-defined and PIR-defined methods not to need a shim). The
381 PMCProxy will maintain a link to the low-level PMC's vtable, and use it
382 for any vtable calls that aren't overridden by the proxy class itself.
384 As a result, a low-level PMC used as a parent of a PDD 15 class will
385 never be instantiated directly. It will only be used as a source for
386 attribute names and types, methods, and a vtable.
388 When a method is called on an object whose class has low-level PMC
389 parents, the call is made exactly as it would be for PDD 15 parents. The
390 invocant is always the PDD 15 object. Any method or vtable calls made
391 within the low-level PMC are dispatched on the PDD 15 object invocant.
392 This allows the PDD 15 object to intelligently handle method and vtable
393 overrides within multiple parents and itself.
395 If a low-level PMC expects to be overridden by high-level classes (which
396 means all the core low-level PMC types), it must respect the standard
397 interface.
400 =head2 Definitions
402 =head3 Vtable Functions
404 Vtables decouple the interface and implementation of various object functions.
405 The actual vtable structure contains pointers to functions that implement the
406 methods for that particular PMC.  All pointers must point to valid functions
407 with appropriate prototypes.
409 In C code, the first parameter to any vtable routine is the current
410 interpreter. The second parameter is the PMC itself.
412 The following list details each of the vtable functions, their prototypes, and
413 their behavior.
415 =head4 Core Vtable Functions
417 =over 4
419 =item init
421   void init(INTERP, PMC *self)
423 Called when a PMC is first instantiated. It takes an unused PMC parameter and
424 turns it into a PMC of the appropriate class.
426 =item init_pmc
428   void init_pmc(INTERP, PMC *self, PMC *initializer)
430 Alternative entry point called when a PMC is first instantiated.  Accepts a
431 PMC parameter used to initialize the given object.  Interpretation of the PMC
432 initializer is left open, each PMC is free to choose its own implementation. A
433 null value passed as the initializer parameter is allowed.
435 NOTE: It is strongly suggested that init_pmc(PMCNULL) be equivalent to
436 init(), though there will of necessity be exceptions.
438 =item instantiate
440   PMC* instantiate(INTERP, PMC *self, PMC *init)
442 Creates a new PMC object of the type of the class and calls init_pmc(),
443 passing in the initialization argument, I<init>, which is usually a
444 hash. This opcode is most often used with high-level classes, but
445 low-level PMCs may instantiate an object of their own type.
447 =item inspect
449   PMC* inspect(INTERP, PMC *self)
451 Return a hash of all characteristics of the I<self> PMC available for
452 introspection.
454   PMC* inspect_str(INTERP, PMC *self, STRING *what)
456 Return a PMC value for one characteristic of the I<self> PMC, selected
457 by string name. Returns PMCNULL if the characteristic doesn't exist.
459 =item morph
461   void morph(INTERP, PMC *self, INTVAL type)
463 Turn the PMC into a PMC of type I<type>. If the morphing can't be done in any
464 reasonable way -- for instance if an integer is asked to turn into an Array --
465 then the PMC is first destroyed, then recreated as an empty PMC of the new
466 type.
468 This method is primarily used when the interpreter has need of coercing a PMC
469 to a particular type, and isn't meant as a general purpose casting tool.
470 Compilers should only emit valid morphing operations.
472 =item mark
474   void mark(INTERP, PMC *self)
476 Called when the GC is tracing live PMCs. If this method is called then the
477 code must mark all strings and PMCs that it contains as live, otherwise they
478 may be collected.
480 This method is only called if the GC has detected that this PMC is both alive
481 and has a custom mark routine as indicated by the custom mark PMC flag.  (Most
482 normal PMCs don't need a custom mark routine.)
484 If a PMC has this flag set, then it is responsible for marking all buffers and
485 PMCs under its control as alive. If it does not, those PMCs or buffers may be
486 collected later. This method does I<not> have to call the C<mark> method on
487 any PMCs it marks--the GC system takes care of that. (So no need to recurse
488 into aggregate PMCs or anything of the sort).
490 This method may allocate no memory from Parrot, nor may it alter Parrot's
491 internal structures. It should have no side-effects from the C level either.
492 This routine may not throw an exception.
494 =item destroy
496   void destroy(INTERP, PMC *self)
498 Called when the PMC is destroyed. This method is called by the GC when it
499 determines that a PMC is dead and that the PMC has marked itself as having a
500 destroy method (an active finalizer).
502 When this method finishes, the PMC will be marked as dead. As such you should
503 make sure that you don't leave any references to it in any Parrot structure
504 by the end of the method.
506 This method may not throw an exception. It will be ignored if it does.
508 =item clone
510   PMC* clone(INTERP, PMC *self)
512 Return a clone of a PMC.
514 =item defined
516   INTVAL defined(INTERP, PMC *self)
518 Return a true value if the PMC is defined, false otherwise.
520 =item get_class
522   PMC* get_class(INTERP, PMC *self)
524 Return the class object for this PMC. For high-level objects, this is a
525 C<Class> object (or other high-level class object). For low-level PMCs,
526 this returns a C<PMCProxy> object.
528 =item get_namespace
530   PMC* get_namespace(INTERP, PMC *self)
532 Return the namespace object for this PMC.
534 =item freeze
536   void freeze(INTERP, PMC *self, visit_info* info)
538 Freeze the PMC to an archived string format (a bytecode string constant
539 that can be saved in a packfile).
541 =item thaw
543   void thaw  (INTERP, PMC *self, visit_info* info)
545 Thaw a PMC from an archived string format (a bytecode string constant
546 that can be saved in a packfile).
548 =item thawfinish
550   void thawfinish (INTERP, PMC *self, visit_info* info)
552 Called after the PMC has been thawed to perform any finalization steps.
554 =item visit
556   void visit (INTERP, PMC *self, visit_info* info)
558 Used by C<freeze> and C<thaw> to visit the contents of the PMC.
560 =item share
562   void share(INTERP, PMC *self)
564   PMC* share_ro(INTERP, PMC *self)
566 Mark a PMC as shared and read-only.
568 [NOTE: these seem to be used interchangably, should be distinguished or
569 merged.]
571 =back
573 =head4 Accessors
575 =over 4
577 =item getprop
579   PMC* getprop(INTERP, PMC *self, STRING *key)
581 Return the value from the property hash of I<self> keyed by I<key>. The key
582 should not be null.
584 =item setprop
586   void setprop(INTERP, PMC *self, STRING *key, PMC *value)
588 Set the value in the property hash of I<self> that is keyed by I<key> to the
589 value of I<value>. The key should not be null.
591 =item delprop
593   void delprop(INTERP, PMC *self, STRING *key)
595 Delete the value from the property hash of I<self> keyed by I<key>. The key
596 should not be null.
598 =item getprops
600   PMC* getprops(INTERP, PMC *self)
602 Return the entire property hash for I<self>.
604 =item type
606   INTVAL type(INTERP, PMC *self)
608 Return the type of the PMC. Type is a unique number associated with the PMC
609 when the PMC's class is loaded. Negative numbers are considered
610 interpreter-specific, non-public types.
612 =item name
614   STRING* name(INTERP, PMC *self)
616 Return the name of the class for the PMC.
618 =item get_integer
620   INTVAL get_integer(INTERP, PMC *self)
622 Return the native integer value of the PMC.
624 =item get_number
626   FLOATVAL get_number(INTERP, PMC *self)
628 Return the native floating-point value of the PMC.
630 =item get_string
632   STRING* get_string(INTERP, PMC *self)
634 Return the native string value of the PMC. This may be in any encoding, chosen
635 by the PMC.
637 =item get_repr
639   STRING* get_repr(INTERP, PMC *self)
641 Return a string representation of the PMC. [NOTE: redundant with
642 C<get_string>, candidate for deprecation.]
644 =item get_bool
646   INTVAL get_bool(INTERP, PMC *self)
648 Return the true/false value of the PMC (the constant TRUE or the constant
649 FALSE). The definition of truth for a given PMC will depend on the type of the
650 PMC. For a scalar, it may be as simple as returning false when the PMC has a
651 value 0 or "", and returning true when the PMC has any other value.
653 =item get_pmc
655   PMC* get_pmc(INTERP, PMC *self)
657 Return the PMC value for this PMC. This is useful in circumstances where the
658 thing being accessed may return something other than its own value. For
659 example, an array might return a reference to itself. Any PMC may return a
660 value different from the PMC that C<get_pmc> is being called on.
662 =item set_integer_native
664   void set_integer_native(INTERP, PMC *self, INTVAL value)
666 Set the integer value of this PMC from a native integer value (integer
667 register/constant).
669 =item set_integer_same
671   void set_integer_same(INTERP, PMC *self, PMC *value)
673 Set the value of this PMC from the integer value of another PMC. The value PMC
674 is guaranteed to be of the same type as the I<self> PMC, so optimizations may
675 be made.
677 =item set_number_native
679   void set_number_native(INTERP, PMC *self, FLOATVAL value)
681 Set the value of this PMC from a native floating-point value (float
682 register/constant).
684 =item set_number_same
686   void set_number_same(INTERP, PMC *self, PMC *value)
688 Set the value of this PMC from the floating-point value another PMC. The value
689 PMC is guaranteed to be of the same type as the I<self> PMC, so optimizations
690 may be made.
692 =item get_pointer
694   void* get_pointer(INTERP, PMC *self)
696 Returns a pointer value for the PMC. Useful for PMCs that hold pointers to
697 arbitrary data. The details of the data (type, location etc.) depend on the
698 PMC.
700 =item set_bignum_int
702   void set_bignum_int(INTERP, PMC *self, INTVAL value)
704 Morph the PMC to a BIGNUM PMC, and set the extended-precision value from a
705 native integer.
707 =item set_string_native
709   void set_string_native(INTERP, PMC *self, STRING *value)
711 Set the value of this PMC from a native string value (string
712 register/constant).
714 =item assign_string_native
716   void assign_string_native(INTERP, PMC *self, STRING *value)
718 Set the value of this PMC to a copied native string value (string
719 register/constant).
721 =item set_string_same
723   void set_string_same(INTERP, PMC *self, PMC *value)
725 Set the value of this PMC from the string value of another PMC. The value PMC
726 is guaranteed to be of the same type as the I<self> PMC, so optimizations may
727 be made.
729 =item set_bool
731   void set_bool(INTERP, PMC *self, INTVAL value)
733 Set the boolean state of the PMC to TRUE if the native integer value passed in
734 is TRUE, or FALSE if the value is FALSE. The definition of truth is left open
735 to the particular PMC. For a scalar, it may be as simple as setting false when
736 a 0 value is passed in, and seting true when any other value is passed in.
738 =item assign_pmc
740   void assign_pmc(INTERP, PMC *self, PMC *value)
742 Set the value of the PMC in I<self> to the value of the PMC in I<value> by
743 copying the value.
745 =item set_pmc
747   void set_pmc(INTERP, PMC *self, PMC *value)
749 Make the PMC in I<self> refer to the PMC passed as I<value>.
751 =item set_pointer
753   void set_pointer(INTERP, PMC *self, void* value)
755 Set the pointer value of the PMC Useful for PMCs that hold pointers to
756 arbitrary data. The details of the data (type, location etc.) depend on the
757 PMC.
759 =back
761 =head4 Aggregate Vtable Functions
763 Many of the following functions have a *_keyed form, a *_keyed_int form, and a
764 *_keyed_str form. The keyed forms take a PMC *, INTVAL, or STRING * key as a
765 parameter. The PMC * parameter is null (PMCNULL) if there is no key for that
766 PMC; this means that that argument is unkeyed.
768 In some cases, the caller must provide a non-null key.  Those cases are
769 explicitly stated below.  In the other cases, you may have to implement the
770 keyed vtable functions and check for a null I<self> key even if you are
771 implementing a non-aggregate type.  If the I<self> key is non-null and the PMC
772 class is a non-aggregate type, the _keyed_* methods should throw an exception.
774 If you do not implement the *_keyed_int and *_keyed_str functions, the default
775 will convert the INTVAL or STRING * into a key PMC * and call the
776 corresponding *_keyed functions.
778 =over 4
780 =item elements
782   INTVAL elements(INTERP, PMC *self)
784 Return the number of elements in the PMC.
786 =item get_integer_keyed
788   INTVAL get_integer_keyed(INTERP, PMC *self, PMC *key)
789   INTVAL get_integer_keyed_int(INTERP, PMC *self, INTVAL key)
790   INTVAL get_integer_keyed_str(INTERP, PMC *self, STRING *key)
792 Return the integer value for the element indexed by a PMC, integer, or string
793 key. The key is guaranteed not to be null for this function.
795 =item get_number_keyed
797   FLOATVAL get_number_keyed(INTERP, PMC *self, PMC *key)
798   FLOATVAL get_number_keyed_int(INTERP, PMC *self, INTVAL key)
799   FLOATVAL get_number_keyed_str(INTERP, PMC *self, STRING *key)
801 Return the native floating-point value for the element indexed by a PMC,
802 integer, or string key. The key is guaranteed not to be null for this
803 function.
805 =item get_string_keyed
807   STRING* get_string_keyed(INTERP, PMC *self, PMC *key)
808   STRING* get_string_keyed_int(INTERP, PMC *self, INTVAL key)
809   STRING* get_string_keyed_str(INTERP, PMC *self, STRING *key)
811 Return the string value for the element indexed by a PMC, integer, or string
812 key. The key is guaranteed not to be null for this function.
814 =item get_pmc_keyed
816   PMC* get_pmc_keyed(INTERP, PMC *self, PMC *key)
817   PMC* get_pmc_keyed_int(INTERP, PMC *self, INTVAL key)
818   PMC* get_pmc_keyed_str(INTERP, PMC *self, STRING *key)
820 Return the PMC value for the element indexed by a PMC, integer, or
821 string key. The key is guaranteed not to be null for this function.
823 =item get_pointer_keyed
825   void* get_pointer_keyed(INTERP, PMC *self, PMC *key)
826   void* get_pointer_keyed_int(INTERP, PMC *self, INTVAL key)
827   void* get_pointer_keyed_str(INTERP, PMC *self, STRING *key)
829 Return the pointer value for the element indexed by a PMC, integer, or
830 string key. The details of the data (type, location etc.) depend on the
831 PMC.
833 =item set_integer_keyed
835   void set_integer_keyed(INTERP, PMC *self, PMC *key, INTVAL value)
836   void set_integer_keyed_int(INTERP, PMC *self, INTVAL key, INTVAL value)
837   void set_integer_keyed_str(INTERP, PMC *self, STRING *key, INTVAL value)
839 Set the integer value of the element indexed by a PMC, integer, or
840 string key. The key is guaranteed not to be null for this function.
842 =item set_number_keyed
844   void set_number_keyed(INTERP, PMC *self, PMC *key, FLOATVAL value)
845   void set_number_keyed_int(INTERP, PMC *self, INTVAL key, FLOATVAL value)
846   void set_number_keyed_str(INTERP, PMC *self, STRING *key, FLOATVAL value)
848 Set the floating-point value of the element indexed by a PMC, integer,
849 or string key. The key is guaranteed not to be null for this function.
851 =item set_string_keyed
853   void set_string_keyed(INTERP, PMC *self, PMC *key, STRING *value)
854   void set_string_keyed_int(INTERP, PMC *self, INTVAL key, STRING *value)
855   void set_string_keyed_str(INTERP, PMC *self, STRING *key, STRING *value)
857 Set the string value of the element indexed by a PMC, integer, or string
858 key. The key is guaranteed not to be null for this function.
860 =item set_pmc_keyed
862   void set_pmc_keyed(INTERP, PMC *self, PMC *key, PMC *value)
863   void set_pmc_keyed_int(INTERP, PMC *self, INTVAL key, PMC *value)
864   void set_pmc_keyed_str(INTERP, PMC *self, STRING *key, PMC *value)
866 Set the PMC value of the element indexed by a PMC, integer, or string key by
867 copying the value of another PMC.
869 =item set_pointer_keyed
871   void set_pointer_keyed(INTERP, PMC *self, PMC *key, void* value)
872   void set_pointer_keyed_int(INTERP, PMC *self, INTVAL key, void* value)
873   void set_pointer_keyed_str(INTERP, PMC *self, STRING *key, void* value)
875 Set the pointer value of the element indexed by a PMC, integer, or string key.
877 =item pop_integer
879   INTVAL pop_integer(INTERP, PMC *self)
881 Return the integer value of the last item on the list, removing that item.
883 =item pop_float
885   FLOATVAL pop_float(INTERP, PMC *self)
887 Return the floating-point value of the last item on the list, removing that
888 item.
890 =item pop_string
892   STRING* pop_string(INTERP, PMC *self)
894 Return the string value of the last item on the list, removing that item.
896 =item pop_pmc
898   PMC* pop_pmc(INTERP, PMC *self)
900 Return the PMC value of the last item on the list, removing that item.
902 =item push_integer
904   void push_integer(INTERP, PMC *self, INTVAL value)
906 Add the passed in integer value to the end of the list.
908 =item push_float
910   void push_float(INTERP, PMC *self, FLOATVAL value)
912 Add the passed in floating-point number to the end of the list.
914 =item push_string
916   void push_string(INTERP, PMC *self, STRING *value)
918 Add the passed in string to the end of the list.
920 =item push_pmc
922   void push_pmc(INTERP, PMC *self, PMC *value)
924 Add the passed in PMC to the end of the list.
926 =item shift_integer
928   INTVAL shift_integer(INTERP, PMC *self)
930 Return the integer value of the first item on the list, removing that item.
932 =item shift_float
934   FLOATVAL shift_float(INTERP, PMC *self)
936 Return the floating-point value of the first item on the list, removing that
937 item.
939 =item shift_string
941   STRING* shift_string(INTERP, PMC *self)
943 Return the string value of the first item on the list, removing that item.
945 =item shift_pmc
947   PMC* shift_pmc(INTERP, PMC *self)
949 Return the PMC value of the first item on the list, removing that item.
951 =item unshift_integer
953   void unshift_integer(INTERP, PMC *self, INTVAL value)
955 Add the passed in integer value to the beginning of the list.
957 =item unshift_float
959   void unshift_float(INTERP, PMC *self, FLOATVAL value)
961 Add the passed in floating-point number to the beginning of the list.
963 =item unshift_string
965   void unshift_string(INTERP, PMC *self, STRING *value)
967 Add the passed in string to the beginning of the list.
969 =item unshift_pmc
971   void unshift_pmc(INTERP, PMC *self, PMC *value)
973 Add the passed in PMC to the beginning of the list.
975 =item splice
977   void splice(INTERP, PMC *self, PMC *value, INTVAL offset, INTVAL count)
979 Replace some number of PMCs (specified by the integer I<count>) at
980 offset I<offset> from the beginning of I<self> with the PMCs in the
981 aggregate I<value>.
983 =item exists_keyed
985   INTVAL exists_keyed(INTERP, PMC *self, PMC *key)
986   INTVAL exists_keyed_int(INTERP, PMC *self, INTVAL key)
987   INTVAL exists_keyed_str(INTERP, PMC *self, STRING *key)
989 Check if the element indexed by a PMC, integer, or string key exists.
991 =item defined_keyed
993   INTVAL defined_keyed(INTERP, PMC *self, PMC *key)
994   INTVAL defined_keyed_int(INTERP, PMC *self, INTVAL key)
995   INTVAL defined_keyed_str(INTERP, PMC *self, STRING *key)
997 Check if the element indexed by a PMC, integer, or string key is defined.
999 =item delete_keyed
1001   void delete_keyed(INTERP, PMC *self, PMC *key)
1002   void delete_keyed_int(INTERP, PMC *self, INTVAL key)
1003   void delete_keyed_str(INTERP, PMC *self, STRING *key)
1005 Delete the element indexed by a PMC, integer, or string key.
1007 =back
1009 =head4 Math Vtable Functions
1011 =over 4
1013 =item add
1015   void add(INTERP, PMC *self, PMC *value, PMC *dest)
1016   void add_int(INTERP, PMC *self, INTVAL value, PMC *dest)
1017   void add_float(INTERP, PMC *self, FLOATVAL value, PMC *dest)
1019   void i_add(INTERP, PMC *self, PMC *value)
1020   void i_add_int(INTERP, PMC *self, INTVAL value)
1021   void i_add_float(INTERP, PMC *self, FLOATVAL value)
1023 Add the value of I<self> to the value of a PMC, native integer, or native
1024 floating-point number and store the result in a PMC I<dest>. Note that I<dest>
1025 may be the same PMC as I<self>; in that case optimizations may be made.
1026 The C<i_> variants perform an inplace operation, modifying the value of
1027 I<self>.
1029 =item subtract
1031   PMC* subtract(INTERP, PMC *self, PMC *value, PMC *dest)
1032   PMC* subtract_int(INTERP, PMC *self, INTVAL value, PMC *dest)
1033   PMC* subtract_float(INTERP, PMC *self, FLOATVAL value, PMC *dest)
1035   void i_subtract(INTERP, PMC *self, PMC *value)
1036   void i_subtract_int(INTERP, PMC *self, INTVAL value)
1037   void i_subtract_float(INTERP, PMC *self, FLOATVAL value)
1039 Subtract the value of a PMC, native integer, or native floating-point number
1040 from a PMC and store the result in I<dest>. If I<dest> is null create a result
1041 PMC of an appropriate type.  Note that I<dest> may be the same PMC as I<self>;
1042 in that case optimizations may be made. The C<i_> variants perform an
1043 inplace operation, modifying the value of I<self>.
1045 =item increment
1047   void increment(INTERP, PMC *self)
1049 Increment the value of a PMC by 1.
1051 =item decrement
1053   void decrement(INTERP, PMC *self)
1055 Decrement the value of a PMC by 1.
1057 =item multiply
1059   void multiply(INTERP, PMC *self, PMC *value, PMC *dest)
1060   void multiply_int(INTERP, PMC *self, INTVAL value, PMC *dest)
1061   void multiply_float(INTERP, PMC *self, FLOATVAL value, PMC *dest)
1063   void i_multiply(INTERP, PMC *self, PMC *value)
1064   void i_multiply_int(INTERP, PMC *self, INTVAL value)
1065   void i_multiply_float(INTERP, PMC *self, FLOATVAL value)
1067 Multiply a PMC, native integer, or floating-point value by the value of the
1068 PMC I<self> and store the result in the I<dest> PMC. Note that I<dest> may be
1069 the same PMC as I<self>; in that case optimizations may be made. The C<i_>
1070 variants perform an inplace operation, modifying the value of I<self>.
1072 =item divide
1074   void divide(INTERP, PMC *self, PMC *value, PMC *dest)
1075   void divide_int(INTERP, PMC *self, INTVAL value, PMC *dest)
1076   void divide_float(INTERP, PMC *self, FLOATVAL value, PMC *dest)
1078   void i_divide(INTERP, PMC *self, PMC *value)
1079   void i_divide_int(INTERP, PMC *self, INTVAL value)
1080   void i_divide_float(INTERP, PMC *self, FLOATVAL value)
1082 Divide the value of the I<self> PMC by a PMC, native integer, or native
1083 floating-point number and store the result in I<dest>.  Note that I<dest> may
1084 be the same PMC as I<self>; in that case optimizations may be made. The
1085 C<i_> variants perform an inplace operation, modifying the value of
1086 I<self>.
1088 =item floor_divide
1090   PMC* floor_divide(INTERP, PMC *self, PMC *value, PMC *dest)
1091   PMC* floor_divide_int(INTERP, PMC *self, INTVAL value, PMC *dest)
1092   PMC* floor_divide_float(INTERP, PMC *self, FLOATVAL value, PMC *dest)
1094   void i_floor_divide(INTERP, PMC *self, PMC *value)
1095   void i_floor_divide_int(INTERP, PMC *self, INTVAL value)
1096   void i_floor_divide_float(INTERP, PMC *self, FLOATVAL value)
1098 Divide the PMC's value number by I<value> and return the result in
1099 I<dest>. The result is the C<floor()> of the division i.e. the next
1100 whole integer towards -inf. If the denominator is zero, a 'Divide by
1101 zero' exception is thrown. The C<i_> variants perform an inplace
1102 operation, modifying the value of I<self>.
1104 =item modulus
1106   void modulus(INTERP, PMC *self, PMC *value, PMC *dest)
1107   void modulus_int(INTERP, PMC *self, INTVAL value, PMC *dest)
1108   void modulus_float(INTERP, PMC *self, FLOATVAL value, PMC *dest)
1110   void i_modulus(INTERP, PMC *self, PMC *value)
1111   void i_modulus_int(INTERP, PMC *self, INTVAL value)
1112   void i_modulus_float(INTERP, PMC *self, FLOATVAL value)
1114 Divide the value of the I<self> PMC by the value of a PMC, native integer, or
1115 native floating-point number and store the remainder in I<dest>.  Note that
1116 I<dest> may be the same PMC as I<self>; in that case optimizations may be
1117 made.  The C<i_> variants perform an inplace operation, modifying the value of
1118 I<self>.
1120 =item cmodulus
1122   void cmodulus(INTERP, PMC *self, PMC *value, PMC *dest)
1123   void cmodulus_int(INTERP, PMC *self, INTVAL value, PMC *dest)
1124   void cmodulus_float(INTERP, PMC *self, FLOATVAL value, PMC *dest)
1126   void i_cmodulus(INTERP, PMC *self, PMC *value)
1127   void i_cmodulus_int(INTERP, PMC *self, INTVAL value)
1128   void i_cmodulus_float(INTERP, PMC *self, FLOATVAL value)
1130 Divide the value of the I<self> PMC by the value of a PMC, native integer, or
1131 native floating-point number and store the remainder in I<dest>.  Note that
1132 I<dest> may be the same PMC as I<self>; in that case optimizations may be
1133 made.  The C<i_> variants perform an inplace operation, modifying the value of
1134 I<self>.
1136 Note that C<modulus> uses Knuth's "corrected mod" algorithm, as implemented in
1137 F<src/utils.c>, while C<cmodulus> uses the C-style fmod function.
1139 =item pow
1141   PMC* pow(INTERP, PMC *self, PMC *value, PMC *dest)
1142   PMC* pow_int(INTERP, PMC *self, INTVAL value, PMC *dest)
1143   PMC* pow_float(INTERP, PMC *self, FLOATVAL value, PMC *dest)
1145   void i_pow(INTERP, PMC *self, PMC *value)
1146   void i_pow_int(INTERP, PMC *self, INTVAL value)
1147   void i_pow_float(INTERP, PMC *self, FLOATVAL value)
1149 Return the value of I<self> raised to the power of I<value>. The C<i_>
1150 variants perform an inplace operation, modifying the value of I<self>.
1152 =item absolute
1154   PMC* absolute(INTERP, PMC *self, PMC *dest)
1155   void i_absolute(INTERP, PMC *self)
1157 Return the absolute value of I<self>. The C<i_> variant performs an
1158 inplace operation, modifying the value of I<self>.
1160 =item neg
1162   void neg(INTERP, PMC *self, PMC *dest)
1163   void i_neg(INTERP, PMC *self)
1165 Negate the sign of I<self> and store the result in I<dest>. Note that
1166 I<self> and I<dest> may refer to the same PMC, in which case
1167 optimizations may be made. The C<i_> variant performs an inplace
1168 operation, modifying the value of I<self>.
1170 =back
1172 =head4 Logical Vtable Functions
1174 =over 4
1176 =item bitwise_or
1178   void bitwise_or(INTERP, PMC *self, PMC *value, PMC *dest)
1179   void bitwise_or_int(INTERP, PMC *self, INTVAL value, PMC *dest)
1180   void i_bitwise_or(INTERP, PMC *self, PMC *value)
1181   void i_bitwise_or_int(INTERP, PMC *self, INTVAL value)
1183 Calculate the bitwise-OR of the value of the I<self> PMC and the value of a
1184 PMC or native integer and store the result in I<dest>. Note that I<dest> may
1185 be the same PMC as I<self>; in that case optimizations may be made.
1186 [Question: what happens when the I<self> and I<value> PMCs aren't integers?]
1188 The C<i_> variants perform an inplace operation and store the result in
1189 I<self>.
1191 =item bitwise_and
1193   PMC* bitwise_and(INTERP, PMC *self, PMC *value, PMC *dest)
1194   PMC* bitwise_and_int(INTERP, PMC *self, INTVAL value, PMC *dest)
1195   void i_bitwise_and(INTERP, PMC *self, PMC *value)
1196   void i_bitwise_and_int(INTERP, PMC *self, INTVAL value)
1198 Return the result of a bitwise AND on the passed in I<value> and the I<self>
1199 PMC. The C<i_> variants perform an inplace operation and store the result in
1200 I<self>.
1202 =item bitwise_xor
1204   PMC* bitwise_xor(INTERP, PMC *self, PMC *value, PMC *dest)
1205   PMC* bitwise_xor_int(INTERP, PMC *self, INTVAL value, PMC *dest)
1206   void i_bitwise_xor(INTERP, PMC *self, PMC *value)
1207   void i_bitwise_xor_int(INTERP, PMC *self, INTVAL value)
1209 Return the result of a bitwise XOR on the passed in I<value> and the I<self>
1210 PMC. The C<i_> variants perform an inplace operation and store the result in
1211 I<self>.
1213 =item bitwise_ors
1215   PMC* bitwise_ors(INTERP, PMC *self, PMC *value, PMC *dest)
1216   PMC* bitwise_ors_str(INTERP, PMC *self, STRING *value, PMC *dest)
1217   void i_bitwise_ors(INTERP, PMC *self, PMC *value)
1218   void i_bitwise_ors_str(INTERP, PMC *self, STRING *value)
1220 Return the result of a bitwise OR over an entire string on the passed in
1221 I<value> and the I<self> PMC. The C<i_> variants perform an inplace operation
1222 and store the result in I<self>.
1224 =item bitwise_ands
1226   PMC* bitwise_ands(INTERP, PMC *self, PMC *value, PMC *dest)
1227   PMC* bitwise_ands_str(INTERP, PMC *self, STRING *value, PMC *dest)
1228   void i_bitwise_ands(INTERP, PMC *self, PMC *value)
1229   void i_bitwise_ands_str(INTERP, PMC *self, STRING *value)
1231 Return the result of a bitwise AND over an entire string on the passed in
1232 I<value> and the I<self> PMC. The C<i_> variants perform an inplace operation
1233 and store the result in I<self>.
1235 =item bitwise_xors
1237   PMC* bitwise_xors(INTERP, PMC *self, PMC *value, PMC *dest)
1238   PMC* bitwise_xors_str(INTERP, PMC *self, STRING *value, PMC *dest)
1239   void i_bitwise_xors(INTERP, PMC *self, PMC *value)
1240   void i_bitwise_xors_str(INTERP, PMC *self, STRING *value)
1242 Return the result of a bitwise XOR over an entire string on the passed in
1243 I<value> and the I<self> PMC. The C<i_> variants perform an inplace operation
1244 and store the result in I<self>.
1246 =item bitwise_not
1248   PMC* bitwise_not(INTERP, PMC *self, PMC *dest)
1249   void i_bitwise_not(INTERP, PMC *self)
1251 Returns the bitwise negation of the I<self> PMC. The C<i_> variant performs an
1252 inplace operation, storing the result in I<self>.
1254 =item bitwise_nots
1256   PMC* bitwise_nots(INTERP, PMC *self, PMC *dest)
1257   void i_bitwise_nots(INTERP, PMC *self)
1259 Returns the bitwise negation of the string I<self> PMC. The C<i_> variant
1260 performs an inplace operation, storing the result in I<self>.
1262 =item bitwise_shl
1264   PMC* bitwise_shl(INTERP, PMC *self, PMC *value, PMC *dest)
1265   PMC* bitwise_shl_int(INTERP, PMC *self, INTVAL value, PMC *dest)
1266   void i_bitwise_shl(INTERP, PMC *self, PMC *value)
1267   void i_bitwise_shl_int(INTERP, PMC *self, INTVAL value)
1269 Return the value of the I<self> PMC bitwise shifted left by the amount
1270 specified in I<value>, shifting in zeroes on the right (arithmetic/logical
1271 bitwise shift). A negative I<value> shifts right. The C<i_> variants perform
1272 an inplace operation, storing the result in I<self>.
1274 The result may be promoted to a C<BigInt>.
1276 =item bitwise_shr
1278   PMC* bitwise_shr(INTERP, PMC *self, PMC *value, PMC *dest)
1279   PMC* bitwise_shr_int(INTERP, PMC *self, INTVAL value, PMC *dest)
1280   void i_bitwise_shr(INTERP, PMC *self, PMC *value)
1281   void i_bitwise_shr_int(INTERP, PMC *self, INTVAL value)
1283 Return the value of the I<self> PMC bitwise shifted right by the amount
1284 specified in I<value>, shifting in copies of the sign bit on the left
1285 (arithmetic bitwise shift). A negative I<value> shifts left. The C<i_>
1286 variants perform an inplace operation, storing the result in I<self>.
1288 The result may be promoted to a C<BigInt> (when I<value> is negative).
1290 =item bitwise_lsr
1292   PMC* bitwise_lsr(INTERP, PMC *self, PMC *value, PMC *dest)
1293   PMC* bitwise_lsr_int(INTERP, PMC *self, INTVAL value, PMC *dest)
1294   void i_bitwise_lsr(INTERP, PMC *self, PMC *value)
1295   void i_bitwise_lsr_int(INTERP, PMC *self, INTVAL value)
1297 Return the value of the I<self> PMC bitwise shifted right by the amount
1298 specified in I<value>, shifting in zeroes on the left (logical bitwise shift).
1299 A negative I<value> shifts left. The C<i_> variants perform an inplace
1300 operation, storing the result in I<self>.
1302 =item is_equal
1304   INTVAL is_equal(INTERP, PMC *self, PMC *value)
1305   INTVAL is_equal_num(INTERP, PMC *self, PMC *value)
1306   INTVAL is_equal_string(INTERP, PMC *self, PMC *value)
1308 Return an integer value (1/0) indicating if the I<self> PMC is equal to
1309 the I<value> PMC. The C<_num> version tests for numeric equality, while
1310 the C<_string> version tests for string equality.
1312 =item is_same
1314   INTVAL is_same(INTERP, PMC *self, PMC *value)
1316 Return an integer value (1/0) indicating if I<self> is the same as
1317 I<value> (with "sameness" determined by each PMC).
1319 =item cmp
1321   INTVAL cmp(INTERP, PMC *self, PMC *value)
1322   INTVAL cmp_num(INTERP, PMC *self, PMC *value)
1323   INTVAL cmp_string(INTERP, PMC *self, PMC *value)
1325 Returns the integer result of comparing the values of I<self> and
1326 I<value> (0 for equal, 1 if I<self> is greater, -1 if I<value> is
1327 greater). The C<_num> version performs a numeric comparison, while the
1328 C<_string> version performs a string comparison.
1330 =back
1332 =head4 String Vtable Functions
1334 =over 4
1336 =item concatenate
1338   PMC* concatenate(INTERP, PMC *self, PMC *value, PMC *dest)
1339   PMC* concatenate_str(INTERP, PMC *self, STRING *value, PMC *dest)
1340   void i_concatenate(INTERP, PMC *self, PMC *value)
1341   void i_concatenate_str(INTERP, PMC *self, STRING *value)
1343 Concatenate I<self> with a PMC or string value and return the result.
1344 The C<i_> variant performs an inplace concatenation, modifying the value
1345 of I<self>.
1347 =item repeat
1349   PMC* repeat(INTERP, PMC *self, PMC *value, PMC *dest)
1350   PMC* repeat_int(INTERP, PMC *self, INTVAL value, PMC *dest)
1351   void i_repeat(INTERP, PMC *self, PMC *value)
1352   void i_repeat_int(INTERP, PMC *self, INTVAL value)
1354 Return the result of repeating the value in I<self> the number of times
1355 indicated in I<value>. The C<i_> variants perform an inplace operation,
1356 modifying the value of I<self>.
1358 =item substr
1360   void substr(INTERP, PMC *self, INTVAL offset, INTVAL length, PMC *dest)
1361   STRING* substr_str(INTERP, PMC *self, INTVAL offset, INTVAL length)
1363 Extracts the string starting at I<offset> with size I<length> and return
1364 it as a PMC in I<dest> or as a string return value.
1366 =back
1368 =head4 Code Vtable Functions
1370 =over 4
1372 =item invoke
1374   opcode_t* invoke(INTERP, PMC *self, void* next)
1376 Invoke the code object I<self>.
1378 =back
1380 =head4 Class/Object Vtable Functions
1382 =over 4
1384 =item can
1386   INTVAL can(INTERP, PMC *self, STRING *method)
1388 Return a true value if the PMC has a method named I<method>, return 0
1389 otherwise.
1391 =item isa
1393   INTVAL isa(INTERP, PMC *self, STRING *classname)
1395 Return a true value if the PMC inherits from  the class named
1396 I<classname>, return 0 otherwise.
1398 =item does
1400   INTVAL does(INTERP, PMC *self, STRING *role)
1402 Return a true value if the PMC C<does> (composes) or C<performs>
1403 (satisfies the interface of) the role named I<role>, return 0 otherwise.
1405 =item get_attr
1407   PMC* get_attr_str(INTERP, PMC *self, STRING *idx)
1409 Retrieve an attribute value from the PMC (instance object).
1411 =item set_attr
1413   void set_attr_str(INTERP, PMC *self, STRING *idx, PMC *value)
1415 Store an attribute value in the PMC (instance object).
1417 =item add_parent
1419   void add_parent(INTERP, PMC *self, PMC *parent)
1421 Add a parent to the PMC (class object), establishing an inheritance relation.
1423 =item remove_parent
1425   void remove_parent(INTERP, PMC *self, PMC *parent)
1427 Remove a parent from a PMC (class object).
1429 Not all object metamodels will support removing parents.
1431 =item add_role
1433   void add_role(INTERP, PMC *self, PMC *role)
1435 Add a role to the PMC (class object), establishing a composition relation.
1437 =item remove_role
1439   void remove_role(INTERP, PMC *self, PMC *role)
1441 Remove a role from the PMC (class object).
1443 Not all object metamodels will support removing roles.
1445 =item add_attribute
1447   void add_attribute(INTERP, PMC *self, STRING *name, PMC *type)
1449 Add an attribute to the PMC (class object).
1451 =item remove_attribute
1453   void remove_attribute(INTERP, PMC *self, STRING *name)
1455 Remove an attribute from the PMC (class object).
1457 Not all object metamodels will support removing attributes.
1459 =item add_method
1461   void add_method(INTERP, PMC *self, STRING *method_name, PMC *sub_pmc)
1463 Add a method to the PMC (class object).
1465 =item remove_method
1467   void remove_method(INTERP, PMC *self, STRING *method_name)
1469 Remove a method from the PMC (class object).
1471 Not all object metamodels will support removing methods.
1473 =item add_vtable_override
1475   void add_vtable_override(INTERP, PMC *self, STRING *vtable_name,
1476                            PMC *sub_pmc)
1478 Add a vtable override to the PMC (class object).
1480   void remove_vtable_override(INTERP, PMC *self, STRING *vtable_name)
1482 Remove a vtable override from the PMC (class object).
1484 =item find_method
1486   PMC* find_method(INTERP, PMC *self, STRING *method_name)
1488 Return a subroutine PMC for the passed method name. This subroutine PMC may be
1489 cached, so the method I<must> return an equivalent sub PMC each time, or be
1490 capable of dealing with the returned sub PMCs being reused. [Why should it be
1491 cached? Can you turn off caching? What if you want to override find_method to
1492 generate methods on the fly?]
1494 =back
1498 =head3 Core PMCs
1500 Parrot has a number of core PMC types that all programs can guarantee will be
1501 available to them. (With the possible exception of Parrot programs executing
1502 on an embedded device or other restricted environment)
1504 =head4 Scalar types
1506 =over 4
1508 =item Undef
1510 This is the generic no-value type. It has a numeric value of zero, a string
1511 value of empty string, and a boolean value of false. It will, on assignment,
1512 turn itself into a PMC of the source type, or if assigned a basic type will
1513 turn itself into one of the wrapper PMC types (detailed below) for the basic
1514 types.
1516 =item Integer
1518 The PMC wrapper for Parrot's low-level integer type. Always an integer, with
1519 other types auto-converted to an integer when stored into this PMC. The range
1520 and behaviour of the Integer PMC is identical to the platform low-level
1521 integer.
1523 The boolean value for an Integer is false if zero, otherwise true.
1525 Floating point, string, and bignum values assigned to an Integer PMC round to
1526 the nearest integer. Floats, or strings which resolve to numbers, cap at the
1527 platform maximum or minimum integer value.
1529 Integer PMCs take on a value of 1 if a boolean true is assigned, and a value
1530 of 0 if a boolean false is assigned.
1532 If an out-of-range value is assigned to an Integer PMC, the PMC will throw an
1533 exception if exact math is enabled.
1535 =item Float
1537 The PMC wrapper for Parrot's low-level floating-point type. Always a float,
1538 with other types autoconverted to a float when stored into this PMC.
1540 The boolean value for a Float is false if exactly zero, otherwise true.
1542 When converted to an integer, floats round to the closest integer, capping at
1543 the platform maximum or minimum integer value.
1545 When converting to a string, floats use the platform default snprintf format.
1547 =item String
1549 The PMC wrapper for Parrot's low-level string type. Always a simple string,
1550 with other types autoconverted to a string when stored into this PMC.
1552 The boolean value for a String is false if empty or the string '0' (a one
1553 character string holding a zero) otherwise true. This PMC autoconverts to an
1554 integer or float when its integer or float value is fetched.
1556 =item Boolean
1558 A true/false value. Returns 0 for false, 1 for true when fetched as an
1559 integer or float, empty string for false and '1' for true when fetched
1560 as a string.
1562 =item BigInt
1564 An arbitrary precision integer.
1566 =item BigNum
1568 The PMC wrapper for Parrot's low-level BigNum type.
1569 {{ NOTE: this type doesn't seem to exist. }}
1571 =item Complex
1573 A complex number, consisting of a real part and an imaginary part.
1574 {{ NOTE: is this a complete and useful implementation of complex
1575 numbers? }}
1577 =item Class
1579 The PMC for Parrot's class.
1581 =item Object
1583 The PMC for Parrot's base object type.
1585 =item Ref
1587 The PMC that represents a reference to another PMC. Delegates all functions to
1588 the referred-to PMC.
1590 =item AggregateElementRef
1592 This PMC represents a reference to an element contained in an aggregate PMC
1593 type, such as an array or hash. It is initialized with the key being
1594 referenced and the aggregate PMC containing that key.
1596 Note that assigning to the reference PMC will be equivalent to a keyed set on
1597 the referenced aggregate PMC - that is, it modifies the element rather than
1598 doing a v-table call on the element itself. It is important to be aware of
1599 this when assigning a PMC through this reference; it is not the same behaviour
1600 as the Ref PMC.
1602 =item WeakRegisterRef
1604 This PMC represents a weak reference to a register. Should the reference live
1605 beyond the context containing the register that it references, any attempt to
1606 use the reference will throw an exception.
1608 A weak register reference can only be created by the C<register_ref> opcode.
1609 Any assignment to the register will behave like a set instruction. That is,
1610 when assigning a PMC using a WeakRegisterRef PMC, the register will be updated
1611 to reference that PMC rather than calling the assign v-table call on the PMC
1612 in that register. This is not the same behaviour as the Ref PMC.
1614 =item Exception
1616 The base class for all exceptions. Currently based on
1617 C<ResizablePMCArray>, but that's likely to change.
1619 =back
1621 =head4 Array types
1623 Note that for the following types you can set the size of the array by using
1624 the VTABLE_set_integer_native() function. Assigning an integer to the array
1625 as a whole sets the array to that size.
1627 Size-changing operations (such as push, pop, shift, unshift, and splice)
1628 on statically-sized arrays will throw an exception.
1630 ResizablePMCArray returns Undef for unset elements (so does the new
1631 object model, because it uses ResizablePMCArray for storage), but Hash
1632 returns PMCNULL. Standardize all core aggregate PMC types on the
1633 singleton PMCNULL.
1635 =over 4
1637 =item Array
1639 The base class for all array types (a statically sized array for any
1640 arbitrary type). New array types can be derived from the base Array.
1641 In user code it is recommended to use one of the specific array types
1642 below, rather than the base type.
1644 =item FixedBooleanArray
1646 A statically sized array which holds only Boolean values.
1648 =item ResizableBooleanArray
1650 A dynamically sized array which holds only Boolean values.
1652 =item FixedIntegerArray
1654 A statically sized array which holds only Integer values.
1656 =item ResizableIntegerArray
1658 A dynamically sized array which holds only Integer values.
1660 =item FixedFloatArray
1662 A statically sized array which holds only Float values.
1664 =item ResizableFloatArray
1666 A dynamically sized array which holds only Float values.
1668 =item FixedPMCArray
1670 A statically sized array which holds only PMC values.
1672 =item ResizablePMCArray
1674 A dynamically sized array which holds only PMC values.
1676 =item FixedStringArray
1678 A statically sized array which holds only String values.
1680 =item ResizableStringArray
1682 A dynamically sized array which holds only String values.
1684 =back
1686 =head4 Hash types
1688 =over 4
1690 =item Hash
1692 A container with key-value semantics. The values are PMCs.
1694 =item Env
1696 Env is a singleton PMC class, that is there is only one Env PMC in any
1697 interpreter. This PMC gives access to the process' environment
1698 variables--reading from it returns the value of the named process environment
1699 variable, while writing to it sets the value of a process environment
1700 variable.  For example, to retrieve the current value of TERM (the terminal
1701 type on most Unix systems):
1703    new P1, 'Env'
1704    set S1, P1['TERM']
1706 Note that an embedding system may override this behavior.
1708 =item NameSpace
1710 Stores one level of a namespace. Every slot in a namespace contains
1711 either another namespace (the next level down), or a variable or
1712 subroutine/method.
1714 =item OrderedHash
1716 A hash that also preserves the order of elements, providing the
1717 interface of both a hash and an array.
1719 =item AddrRegistry
1721 Simulates reference counting for dead-object detection and garbage
1722 collection.
1724 =back
1726 =head4 Subroutine types
1728 =over 4
1730 =item Sub
1732 A fundamental subroutine object, and base class for other subroutine
1733 PMC types.
1735 =item Closure
1737 A closure: subroutine object plus captured lexical scope.
1739 =item Continuation
1741 A continuation: a subroutine object that captures the interpreter's
1742 context at the point where the continuation was constructed.
1744 =item Coroutine
1746 A coroutine: a continuation object that can stop part way through
1747 execution and restart at the point where it left off the next time it's
1748 called.
1750 =item Eval
1752 An extension of C<Sub> that provides dynamic code evaluation and
1753 execution.
1755 =item ExceptionHandler
1757 A code object for handling exceptions.
1759 =item MultiSub
1761 A container for multiply dispatched subroutines.
1763 =item NCI
1765 A native call interface wrapper around a C function.
1767 =item Bound_NCI
1769 An internal NCI method call bound to a particular call instance.
1771 =item Compiler
1773 A subroutine implementing a language compiler. (Derived from NCI.)
1775 =back
1777 =head2 References
1779 F<docs/pmc2c.pod>
1781 =cut
1783 __END__
1784 Local Variables:
1785   fill-column:78
1786 End: