NAME ^

Class - Core structure of a class

DESCRIPTION ^

Classes are instances of the Class PMC. Currently implemented in PIR, but ultimately implemented as low-level .pmc.

SYNOPSIS ^

    .local pmc class, init_args, obj
    init_args = new Hash
    init_args['name'] = 'MyClass'
    class = new 'Class', init_args
#   class = newclass 'MyClass'

    class.add_attribute('myattribute')
    obj = class.'new'( 'myattribute' => "Foo" )

find_class ^

This subroutine prototypes the find_class opcode. It looks up a class by name and returns a class object.

name ^

The accessor for the name attribute. With no argument, it simply returns the current value for name. When passed an argument, it sets the name of the class, and also sets the association with a namespace.

new ^

    obj = class.'new'( 'myattrib' => "Foo" )

Create a new instance object from the class object. It takes an optional slurpy, named list of attributes and values to initialize the object.

attributes ^

An accessor for the attributes attribute of the class. It returns the a Hash of all attributes, with a key of the attribute name, and a value of the Attribute object. The accessor is set by a hash of attributes, with a key name and a value type.

add_attribute ^

Adds a single attribute to the class. It takes a simple string name, and a simple string value for type.


parrot