# Using default function parameters to do a "fake" variadic function?

**URL:** https://forum.ada-lang.io/t/using-default-function-parameters-to-do-a-fake-variadic-function/4787
**Category:** General
**Created:** [October 1, 2026, 7:17pm UTC](https://forum.ada-lang.io/t/using-default-function-parameters-to-do-a-fake-variadic-function/4787 "2026-10-01T19:17:33Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![BlueAlmost](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/bluealmost/32/953_2.png) [@BlueAlmost](https://forum.ada-lang.io/u/BlueAlmost)
#### Post date: [October 1, 2026, 7:17pm UTC](https://forum.ada-lang.io/t/using-default-function-parameters-to-do-a-fake-variadic-function/4787/1 "2026-10-01T19:17:33Z")

</div>

Ada does not natively support variadic functions/procedures (let’s exclude calling imported C variadic functions). Nonetheless, I am trying to obtain something similar to variadic.

To make this more concrete, suppose foo should take as arguments UP TO, say, 3 unconstrained arrays). A call to foo may have 1 argument, or 2, or 3. One idea might be to use default parameter values which would be ignored in the program body:

```ada
   type UA is array (Integer range <>) of Float;
   procedure foo( A1 : UA := null ; A2 : UA := null ; A3 : UA := null ) is

      -- process each non-null input

```

Some questions:

1. Does this look a reasonable way to go? Is there a better approach?

2. How should this “null” really be implemented? (Related: how would UA be given a “null” default initialization?)

Thanks for any suggestions.

---

<div class="post-metadata">

### Author: ![dmitry-kazakov](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/dmitry-kazakov/32/522_2.png) [@dmitry-kazakov](https://forum.ada-lang.io/u/dmitry-kazakov)
#### Post date: [October 1, 2026, 7:50pm UTC](https://forum.ada-lang.io/t/using-default-function-parameters-to-do-a-fake-variadic-function/4787/2 "2026-10-01T19:50:27Z")

</div>

> [@BlueAlmost](#):
>
> Ada does not natively support variadic

Ada is a typed language, ergo no arguments of unknown types.

> [@BlueAlmost](#):
>
> To make this more concrete, suppose foo should take as arguments UP TO, say, 3 unconstrained arrays).

That is not variadic arguments, it is a variable number of arguments having the same type. For that you can use an array, provided that arguments are identically constrained:

```ada
type Arguments is array (Positive range <>, Positive range <>) of Float;
procedure Foo (List : Arguments);

```

or overloading:

```ada
type Argument is array (Positive range <>) of Float;
procedure Foo (A1 : Argument);
procedure Foo (A1, A2 : Argument);
procedure Foo (A1, A2, A3 : Argument);

```

> [@BlueAlmost](#):
>
> 1. Does this look a reasonable way to go? Is there a better approach?

No. As Python illustrates it is very difficult to handle because of combinatorial explosion of variants. Consider passing “null” to A1 and A3 and non-null to A2.

> [@BlueAlmost](#):
>
> 1. How should this “null” really be implemented? (Related: how would UA be given a “null” default initialization?)

You can use an empty array if that is an illegal value. Or you can wrap array:

```ada
type Argument is array (Positive range <>) of Float;
subtype Count is range -1..Positive'Last;
type Optional_Array (Length : Count) is record
   case Length is
      when -1 =>
         null;
      when others =>
         Value : Argument (1..Length);
   end case;
end record;

```
