SMOP p6opaque Implementation


The p6opaque Responder Interface is the default responder for all Perl 6 objects, according to the SMOP OO API.

p6opaque Structure

I use 'repr' as class keyword here to indicate that this is not a real class, but the low-level reponder interface that intercepts the calls with the '^!' prefix. Everything else should be delegated to the metaclass instance.

repr p6opaque {
has $.^!instanceof is rw; # direct delegation of a single prototype, used by most object instances.
has $.^!WHENCE is rw; # autovivication closure, used by autovivification
has p6opaque_proto $!^!proto_storage handles *;
has Hash of Hash %.^!instance_storage is rw;
default ($ri, $identifier, $capture) {
$capture.invocant.^!how.dispatch($ri, $identifier, $capture);
}
bool method ^!defined {
self.^!instance_storage
}
}

repr p6opaque_proto {
has $.^!how is rw; # the metaclass instance in use
has $.^!who is rw; # the package implementing this prototype
has @.^!isa is rw; # an array of other protoypes
has @.^!does is rw; # an array of other prototypes
has %.^!storage is rw; # prototype storage (class variables)
has %.^!attributes is rw; # attribute definitions
has %.^!methods is rw; # methods by name
has %.^!submethods is rw; # submethods by name
has %.^!multimethods is rw; # hash of hash of method by name,capture
has %.^!multisubmethods is rw; # hash of hash of submethod by name,capture
}