[Type System Summary]
Perl 6 has an optional type system that helps you write safer code that performs better. The compiler is free to infer what type information it can from the types you supply, but will not complain about missing type information unless you ask it to.
A variable's type is a constraint indicating what sorts of values the variable may contain. More precisely, it's a promise that the object or objects contained in the variable are capable of responding to the methods of the indicated "role".
External access to opaque objects (P6opaque) is always through method calls, even for attributes.
Every object supports a
HOW function/method that returns the metaclass instance managing it, regardless of whether the object is defined
Various introspection access points
Typed variables can also hold a
Perl 6 supports the notion of properties on various kinds of objects
Compile-time properties are called "traits"
A non-scalar type may be qualified, in order to specify what type of value each of its elements stores (e.g.
my Egg @carton)
Anywhere you can use a single type you can use a set of types, for convenience specifiable as if it were an "or" junction
subset type constrants on the container
Parameters may be given types, just like any other variable
Within a declaration, a class variable (either by itself or following an existing type name) declares a new type name and takes its parametric value from the actual type of the parameter it is associated with. It declares the new type name in the same scope as the associated declaration.
Types (classes) may be parameterized, using square brackets
Compact structs, for interfacing with OS and other languages
There are also features of various specific types, and mention of some specific types.
classes may be nested, lexically scoped, anonymous, etc.
Classes are "open" and may be added to
Multiple inheritance exists
Undefined and autovivifyong protoobjects
Method calls fall back to sub calls if not found
Dispatch can take strings and code blocks, not just literal method names.
submethod, non-inheriting override.
Attributes exist, are private, access using accessors from outside.
new inherited from
Object. bless, CREATE, etc.
Multimethods, multi-dispatch - some discussion in S12