TITLE ^

Object - Perl 6 Object class

DESCRIPTION ^

This file sets up the base classes and methods for Perl 6's object system. Differences (and conflicts) between Parrot's object model and the Perl 6 model means we have to do a little name and method trickery here and there, and this file takes care of much of that.

Functions ^

onload()

Perform initializations and create the base classes.

make_proto(class [, 'name'=>name] )

Create protoobjects and mappings for class, using name as the Perl 6 name for the class. The class argument can be a Parrot Class object, or anything that will obtain a Parrot class via the get_class opcode.

make_grammar_proto(grammar [, 'name'=>name] )

Create protoobjects and mappings for grammar, using name as the Perl 6 name for the grammar. The grammar argument must be a Parrot Class object.

!keyword_class(name)

Internal helper method to create a class.

!keyword_role(name)

Internal helper method to create a role.

!keyword_grammar(name)

Internal helper method to create a grammar.

!keyword_does(class, role_name)

Internal helper method to implement the functionality of the does keyword.

!keyword_has(class, attr_name)

Adds an attribute with the given name to the class.

Object methods ^

new()

Create a new object having the same class as the invocant.

isa($class)

Returns true if the invocant is of type $class.

WHAT()

Return the invocant's protoobject.

HOW()

Return the invocant's metaclass object (in Parrot, this is the class object for the invocant).

WHENCE()

Return the invocant's auto-vivification closure.

REJECTS(topic)

Define REJECTS methods for objects (this would normally be part of the Pattern role, but we put it here for now until we get roles).

true()

Defines the .true method on all objects via prefix:?.

print()

say()

Print the object

clone (vtable method)

Actually just returns the object itself. This is used to get us working with the copy opcode, which clones things on assignment. However, objects by default have reference semantics, not value semantics. Those with value semantics override this.

Protoobject methods ^

Protoobjects are described in Synopsis 12, these are objects that are "empty" instances that differ in definedness and how they respond to certain methods.

get_string() (vtable method)

Returns the short name of the class (prototype objects stringify to the short name).

defined() (vtable method)

Returns false (prototype objects evaluate as undef).

clone() (vtable method)

Returns a copy of the proto-object.

HOW()

Returns the metaclass (Parrot class) of the protoobject.

WHAT()

Returns the invocant's protoobject, which in the case of a protoobject is just itself.

WHENCE()

Returns the invocant's autovivification closure.

ACCEPTS(topic)

get_pmc_keyed(key) (vtable method)

Returns a proto-object with an autovivification closure attached to it.


parrot