Yesterday, we witnessed the shattering of form via the Slip, where a single container dissolved into a multitude. Today, we confront the reverse dynamic—a terrifying gravity well that sits at the boundaries of our invocations, known to the initiated as the Slurpy Parameter.
When defining a subroutine, you normally dictate a rigid geometry of expected inputs. Yet, by carving the ancient asterisk * into the signature, you create an insatiable maw that eagerly swallows all remaining individual arguments flowing from the void.
The Incantation of the Infinite Array
Observe how a single parameter, bound with the mark of the slurpy asterisk *@, effortlessly absorbs an arbitrary procession of independent integers:
sub devour(*@sacrifices) {say"The maw has consumed {@sacrifices.elems} items.";say"The entities gathered: {@sacrifices.raku}";}devour(10, 20, 30);devour(5);devour(); # The void remains empty, yet satisfied
The maw has consumed 3 items.
The entities gathered: [10, 20, 30]
The maw has consumed 1 items.
The entities gathered: [5]
The maw has consumed 0 items.
The entities gathered: []
Unlike ordinary languages that violently reject an unexpected count of arguments, Raku behaves with an unsettling composure. The individual inputs are seamlessly unified into a single, standard @ array inside the subroutine’s domain.
Slurpy Parameters vs. Positional Arrays
A common trap for the uninitiated is confusing a slurpy parameter (*@items) with a standard positional array parameter (@items). They exist as entirely different metaphysical entities:
Parameter Style
The Cosmic Demand
The Invocation Ritual
sub normal(@x)
“Pass me a pre-bound array container.”
normal(@my-array)
sub slurpy(*@x)
“Pass me individual entities; I shall bind them myself.”
slurpy(1, 2, 3)
If you attempt to pass individual values into a normal @x parameter, the compiler will screech an error into the void. The * prefix is the precise magic required to instruct the routine to accept a loose stream of arguments.
Unifying the Slurpy Maw with the Slip
The universe achieves perfect symmetry when we combine the consumption of the slurpy parameter with the dissolution of the Slip operator (|).
If you possess a pre-bound array but wish to feed it to a subroutine that expects a loose stream of individual entities, you must dissolve it on the way in. The slurpy parameter will then re-synthesize those entities on the way out:
sub aggregate(*@numbers) {return [+] @numbers;}my@tribute=1, 2, 3, 4;# The | operator shatters the array; the * parameter catches the fragmentssay aggregate(|@tribute); # 10
10
Without the | incantation, the entire @tribute array would be treated as a single Scalar object by the aggregate function, completely altering the mathematics of the ritual.
Why You Must Master the Maw
The slurpy parameter is the foundation for constructing variadic functions, crafting flexible wrappers, and mastering the complex art of multi-dispatch. Once your mind accepts this infinite aggregation of arguments, you will be prepared to gaze into the deeper mysteries of Raku’s type hierarchy—a realm where containers and values cease to be distinct altogether.