This file is part of the Perl 6 Archive

To see what is currently happening visit http://www.perl6.org/

NAME

docs/pdds/pdd02_vtables.pod - Common vtable format for all variables

ABSTRACT

This PDD presents the vtable entries, and their order, that all variables MUST provide.

DESCRIPTION

All parrot variables hide their guts behind a magic parrot structure generally referred to as a PMC, or Parrot Magic Cookie. Nothing outside the core of parrot (in fact, nothing outside the data type's vtable routines) should infer anything about a PMC (hence the Magic part).

The first parameter to any vtable routine should be the current interpreter. The second parameter should be the PMC itself.

vtables are neat because they decouple the interface and implementation of various object functions. This does mean, though, that you need to either know what functions are available and what they do, or have some method of finding out. It's faster if you know which vtable entry does what, so that's the method parrot's using.

The actual vtable structure contains pointers to functions that implement the methods for that particular vtable. All pointers must point to valid functions with appropriate prototypes.

IMPLEMENTATION

vtable functions

This is a list of each of the vtable methods, their prototypes, and a description of the method.

The following functions are singleton functions. (There are no keyed versions of these)

The following functions have a plain form, a _keyed form, and a _keyed_int form. The keyed forms take a PMC* or INTVAL for each PMC parameter. The PMC* parameter for each PMC is NULL if there is no key for that PMC; this means that that argument is unkeyed.

In some cases, the caller must provide a non-NULL key. Those cases are explicitly stated below. In the other cases, you may have to implement the keyed vtable methods and check for a NULL self key even if you are implementing a non-aggregate type. If the self key is non-NULL and the PMC class is a non-aggregate type, the _keyed_* methods should throw an exception.

If you do not implement the _keyed_int methods, the default will convert the INTVAL into a key PMC* and call the corresponding _keyed method.

The keyed methods should NOT assume that the key pointer will be valid after the method exits. The pointer may be to a stack variable in the calling function.

VERSION

CURRENT

   Maintainer: Dan Sugalski <dan@sidhe.org>
   Class: Internals
   PDD Number: 2
   Version: 1.5
   Status: Developing
   Last Modified: 27 July 2003
   PDD Format: 1
   Language: English

HISTORY

CHANGES