Subroutines & signatures

proto

Full

A shared front-end for a family of multi candidates.

A proto declares the common shape of a multi family — one place to name the routine and, optionally, run shared code around every candidate. The body {*} means "dispatch to the best matching multi".

Declaring a proto #

proto describe(|) {*}
multi describe(Int $) { "int" }
multi describe(Str $) { "str" }
say describe(5);
say describe("x");
Output
int
str

The proto's signature (|) accepts any arguments (a capture); each multi narrows it, and {*} hands off to the one that fits.

Notes #