Home

variadically

Variadic describes a function, operation, or construct that accepts a variable number of arguments. The adverb variadically denotes performing such an action. The term is used in mathematics, statistics, and computer science and stems from Latin varius, meaning "varied," combined with the -adic suffix. Variadic behavior contrasts with fixed-arity functions, which require a predetermined number of inputs.

In mathematics, variadic notation is used for sequences like sum(a1, a2, ..., an) or product(a1, a2, ..., an),

Considerations for variadic constructs include type checking, argument processing, and performance. Some languages wrap variadic inputs

where
the
number
of
operands
is
not
fixed.
In
computer
science,
variadic
functions
allow
callers
to
pass
an
arbitrary
number
of
arguments.
Many
languages
provide
mechanisms
to
handle
variadic
inputs.
In
C,
a
function
declared
with
...
is
variadic
and
access
to
arguments
is
via
va_list
and
va_arg.
In
Python,
the
*args
parameter
collects
extra
positional
arguments,
and
**kwargs
collects
extra
keyword
arguments.
In
JavaScript,
rest
parameters
...args
gather
additional
arguments.
In
Java,
varargs
use
the
syntax
...,
and
in
Kotlin,
varargs
function
similarly.
In
C++,
variadic
templates
enable
compile-time
handling
of
arbitrary
argument
lists.
Not
all
languages
support
variadic
functions
for
both
positional
and
keyword
arguments,
and
some
impose
limits
on
the
number
of
arguments
or
require
explicit
packing
into
a
collection.
into
a
container
type
(such
as
a
list
or
array)
for
uniform
processing,
while
others
rely
on
stack-based
retrieval.
Variadic
design
also
interacts
with
function
overloading,
default
arguments,
and
calling
conventions.
The
notion
extends
beyond
functions
to
operators
and
macros
in
some
languages,
where
operators
may
accept
a
variable
number
of
operands.