# Variable length params for functions

**URL:** <https://forum.soliditylang.org/t/variable-length-params-for-functions/2290>\
**Category:** Language Design\
**Created:** [April 24, 2024, 3:39pm UTC](https://forum.soliditylang.org/t/variable-length-params-for-functions/2290 "2024-04-24T15:39:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nathanglb](https://sea1.discourse-cdn.com/flex001/user_avatar/forum.soliditylang.org/nathanglb/32/1309_2.png) [@nathanglb](https://forum.soliditylang.org/u/nathanglb)\
**Post date:** [April 24, 2024, 3:39pm UTC](https://forum.soliditylang.org/t/variable-length-params-for-functions/2290/1 "2024-04-24T15:39:40Z")

</div>

It is common in many languages to support a variable number of function parameters of the same type. Solidity could benefit from this as well. Consider the case where you want to efficiently hash 1 or more values. Abi encode is very expensive in this case, and given a known number of input values to encode and hash you can write this much more efficiently in assembly. If you want to make a library for this you would have to make an overload of the efficient hashing function for each possible number of values to hash. A great language feature would be to allow passing in an arbitrary number of values and have them automatically wrapped into an array. For example:

```auto
_efficientHash(value1, value2, value3);

...

function _efficientHash(params bytes32[] values) internal pure returns (bytes32 hash) {
  ...
}

```

For an example of what this looks like in other languages, see [Method parameters are passed by value. Modifiers enable pass-by-reference semantics, including distinctions such as read-only, and `out` parameters. Learn the different parameter passing modes and how to use them. The params modifier allows a series of optional arguments. - C# | Microsoft Learn](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/method-parameters#params-modifier)  
[Params Keyword in C#](https://www.c-sharpcorner.com/UploadFile/c63ec5/use-params-keyword-in-C-Sharp/)
