=begin pod

=head1 Code

    class Code is Any does Callable { ... }

C<Code> is the ultimate base class of all code objects in Perl 6. It
exposes functionality that all code objects have. While thunks are
directly of type C<Code>, most code objects (such as those resulting
from blocks, subroutines or methods) will be of some subclass of C<Code>.


=head2 Methods

=head3 ACCEPTS(Code:D: Mu $topic)

Usually calls the code object and passes C<$topic> as an argument.
However, when called on a code object that takes no arguments, the code
object is invoked with no arguments and C<$topic> is dropped. The
result of the call is returned.

=head3 arity(Code:D:) returns Int:D

Returns the minimum number of positional arguments that must be passed
in order to call the code object. Any optional or slurpy parameters in the
code object's C<Signature> do not contribute, nor do named parameters.

    sub argless() { }
    sub args($a, $b?) { }
    sub slurpy($a, $b, *@c) { }
    say &argless.arity;             # 0
    say &args.arity;                # 1
    say &slurpy.arity;              # 2

=head3 count(Code:D:) returns Real:D

Returns the maximum number of positional arguments that may be passed
when calling the code object. For code objects that can accept any
number of positional arguments (that is, they have a slurpy parameter),
C<count> will return C<Inf>. Named parameters do not contribute.

    sub argless() { }
    sub args($a, $b?) { }
    sub slurpy($a, $b, *@c) { }
    say &argless.count;             # 0
    say &args.count;                # 2
    say &slurpy.count;              # Inf

=head3 signature(Code:D:) returns Signature:D

Returns the C<Signature> object for this code object, which describes
its parameters.

=head3 Str(Code:D:) returns Str:D

Returns the name of the code object.

    sub marine() { }
    say ~&marine.name;   # marine

=end pod
