Course of Raku / Advanced / Debugging / Debugging with dd

Dumping function signatures

A bare dd — called with no arguments inside a subroutine — prints the signature of that subroutine: its name and the list of parameters, if it has any. Examine the following example with two subroutines:

sub f1 {
    dd
}

f1();

sub f2($x) {
    dd
}

f2(42);

The program prints the signatures rather than any values:

sub f1()
sub f2($x)

This is especially useful with multi-functions, where it tells you which candidate was actually called:

multi sub g {
    dd
}

multi sub g($x) {
    dd
}

g();
g(42);

The output names the matching variant each time:

sub g()
sub g($x)

Course navigation

Quiz — Reading a dd dump   |   Dump the data structure


💪 Or jump directly to the exercises in this section.