Home

Variadic

Variadic describes constructs that can operate on a variable number of inputs. In mathematics and computer science, a variadic function or operator is defined to accept any finite number of arguments, rather than a fixed count. The term blends vari- “vary” with -adic, similar in spirit to other mathematical and programming terminology.

In programming, variadic functions are common across languages, though implementations differ. In C, a function can

Common examples include printing or formatting routines such as C’s printf, Python’s print, or JavaScript’s console.log,

end
with
an
ellipsis
(...)
to
accept
additional
arguments
beyond
fixed
parameters,
with
access
via
the
va_list
family
of
macros.
C++
extends
this
idea
with
variadic
templates,
enabling
type-safe
expansion
of
parameter
packs
at
compile
time.
Java
supports
variable
arity
methods
by
declaring
a
parameter
of
the
form
Type...
name,
allowing
callers
to
pass
any
number
of
arguments
of
that
type.
Python
uses
*args
to
collect
extra
positional
arguments
and
**kwargs
for
extra
keyword
arguments.
JavaScript
provides
rest
parameters
(...)
to
gather
remaining
arguments
into
an
array.
Go
also
supports
variadic
functions
using
…T
in
the
parameter
list,
where
callers
pass
a
sequence
of
values
or
a
slice.
which
can
handle
arbitrary
numbers
of
inputs.
Variadic
capabilities
raise
design
considerations,
including
type
safety,
performance,
and
the
complexity
of
handling
heterogeneous
argument
lists.
In
languages
built
around
static
typing,
variadic
features
are
often
complemented
by
templates,
generics,
or
explicit
slice/array
conversions
to
preserve
type
safety.
Beyond
programming,
variadic
concepts
appear
in
mathematics
as
functions
defined
on
sequences
of
variable
length.