Basic class definition

    class ClassName {
	has $.public_instance_var;
	# Untyped instance variable, a readonly accessor is automatically
	# generated. Methods have readwrite access to $.instance_var.

	has $.public_instance_var is rw;
	# Untyped instance variable, a readwrite accessor is automatically
	# generated.

	has Type $.public_instance_var;
	# Typed instance variable.

	has $!private_instance_var;
	# Private instance variable, no accessor is automatically generated.
    }

Inheritance

    class ParentClass {...}

    class SubClass is ParentClass {...}
    # or
    class SubClass {
	is ParentClass;
	...;
    }

Methods

    method methodname(...) {...}
    # Standard subroutine signature

    method methodname($invocant: ...) {...}
    # The invocant (the class or the instance) is explicitly bound to
    # $invocant. In any case, there's $?SELF and $?CLASS, too.

    method methodname(Class $class: ...) {...}
    # Class method

    method methodname(::?CLASS $self: ...) {...}
    # Instance method

Roles

    role RoleName {
	method methodname(...) {...}
    }

    class SomeClass does RoleName {...}
    # or
    class SomeClass {
	does RoleName;
    }

Magical variables

    $?SELF    # The current instance as scalar variable
    $?CLASS   # The current class as scalar variable
    ::?CLASS  # The current class as package variable
    $?ROLE    # The current role as scalar variable
    ::?ROLE   # The current role as package variable

Subtypes

    my subtype Int::Odd of Int where { $^value % 2 == 1 };
    # Declaration of a new, lexical subtype of Int, allowing only odd integers.
    
    my Int::Odd $var = 3;    # valid
    $var++;                  # invalid

    my Int::Odd $var = 4;    # invalid
