Perl 6
SMOP OO API: Revision 21

In order to ensure the interoperability among object representations and even between different object systems that uses the same representation. In this context we need to define the HOW and REPR API, this is the SMOP OO API that allows representations to be interchanged, and custom BUILD methods to be written. The interesting aspect is that all this methods must be called in the object itself in SMOP, and that's why they have the "^" and "^!" prefixes, where the first mean a HOW call, and the second means a REPR call.

It is important to stress that the REPR API is SMOP specific, whereas the HOW API is supposed to be transversal to Perl 6 implementations.

Object API

This is what is implemented by Object

method new($prototype: *@protoobjects, *%initialize) {...};
method bless($prototype: $candidate?, *@protoobjects, *%initialize) {...};
method clone($object: ) {...};
method CREATE($prototype: :$repr) {...};
method BUILDALL($object: *@protoobjects, *%initialize) {...};
method DESTROYALL($object: ) {...};
submethod BUILD($object: *@protoobjects, *%initialize) {...};
submethod DESTROY($object: ) {...};

HOW API

This is the instrospection API, that is available as standard Perl 6 and modify the current object.

method ^CREATE($object: ) {...}; # this assumes the same representation as the given object
method ^methods($object: ) {...};
method ^add_method($object: $name, $method) {...};
method ^set_isa($object: $superclass) {...};
method ^add_isa($object: $superclass) {...};
method ^add_role($object: $role) {...};

REPR API

This is SMOP specific, and it isn't part of the standard Perl 6, however, this is how different representations can coexist in SMOP. This only operates in the specific object, it doesn't look to any of the superclasses, that might even have a different representation.

# This is the basic initialization and destruction API.
submethod ^!CREATE($prototype: ) {...};
submethod ^!DESTROY($object: ) {...};
submethod ^!clone($object: ) {...};
submethod ^!initialize_instance_storage($prototype: $object) {...};
submethod ^!destroy_instance_storage($prototype: $object) {...};

# This is the RW introspection API
our Scalar submethod ^!direct_prototype($object: ) {...};
our Scalar submethod ^!whence($object: ) {...};
our List submethod ^!isa($object: ) {...};
our List submethod ^!role($object: ) {...};
our Hash submethod ^!private_storage($object: $package) {...};
our Hash submethod ^!class_storage($prototype: ) {...};
our List submethod ^!submethod_definitions($prototype: ) {...};
our List submethod ^!method_definitions($prototype: ) {...};
our List submethod ^!attribute_definitions($prototype: ) {...};
our Hash submethod ^!properties($object: ) {...};

# This is the RO introspection API
our Submethod submethod ^!can_submethod($prototype: $name, $signature) {...};
our Method submethod ^!can_method($prototype: $name, $signature) {...};
our Attribute submethod ^!has($prototype: $name) {...};

Upload Files

Click "Browse" to find the file you want to upload. When you click "Upload file" your file will be uploaded and added to the list of attachments for this page.

Maximum file size: 50MB

 
 
 
File Name Author Date Uploaded Size

Save Page As

Enter a meaningful and distinctive title for your page.

Page Title:

Tip: You'll be able to find this page later by using the title you choose.

Page Already Exists

There is already a page named XXX. Would you like to:

Save with a different name:

Save the page with the name "XXX"

Append your text to the bottom of the existing page named: "XXX"

Upload Files

Click "Browse" to find the file you want to upload. When you click "Add file" this file will be added to the list of attachments for this page, and uploaded when you save the page.

 
 
 
Add Tags

Enter a tag and click "Add tag". The tag will be saved when you save the page.

Tag: 

Suggestions: