Methods (and subroutines) can take other traits, such as "is lvalue" or
even user-defined traits. I can imagine that a Perl 6 port of
Test::Class would suggest using trats of "is startup" and "is
tests( 4 )" to replace the use of attributes in the Perl 5 version.
Currently, there's no way to query these traits through introspection,
nor is there a description of the descriptors beyond indicating that
they're some sort of object.
I have no strong feeling as to what type of object they should be, but
they ought to support some sort of traits() method to return a list of
names of all available traits on the method. Passing the name of a
trait to the method ought to return the value of the trait, if it is a
parametrized trait. Otherwise, it could return boolean.
Perhaps there's a more general mechanims that works better in specific
cases. Ruby's Class#method? syntax is nice, but being able to hardcode
a method name and pass a string parameter makes introspection a little
Having the class for these descriptors be available and extensible also
makes it possible to write a method that returns only the *interesting*
traits, which might be convenient.
Well, arguably Stevan's perl5/Perl6-MetaModel is the best place to
prototype such interfaces.
Getting traits requires deeper introspection. You need to ask the
Meta-Objects themselves what properties they support. In other words,
by looking at .meta.meta you should be able to see this. Even though
we're aiming to avoid the Smalltalk '72 problem of
meta-meta-meta-meta-model madness. There is some early rantings of it
Quite how far the "turtles all the way down" principle works will be an
interesting test of the design, I think. I wouldn't expect making
changes to .meta objects 3-4 levels deep to work, and that they should
be like a "reciprocal" (or a metaclass that can be its own metaclass).
1. Piers Cawley drew the prior art connection here. I forget the exact
years, but there were two Smalltalk language versions, the first where
each meta-model layer was independant, and the second where they had
figured out how to make the system close back on itself simpler. Maybe
someone can give a better description than this.