# Is \`Function.constantly\` worth adding?

**URL:** <https://forum.elixirforum.com/t/is-function-constantly-worth-adding/39830>\
**Category:** Discussions\
**Tags:** kernel\
**Created:** [May 19, 2021, 11:25pm UTC](https://forum.elixirforum.com/t/is-function-constantly-worth-adding/39830 "2021-05-19T23:25:08Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![benwilson512](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/benwilson512/32/1457_2.png) [@benwilson512](https://forum.elixirforum.com/u/benwilson512)\
**Post date:** [May 20, 2021, 1:21am UTC](https://forum.elixirforum.com/t/is-function-constantly-worth-adding/39830/3 "2021-05-20T01:21:28Z")

</div>

I think this proposal is tricky because, unlike `identity/1`, there isn’t an obvious arity that your return function should have. Should it be:

```elixir
fn -> value end
or
fn _ -> value end
or
fn _, _ -> value end
... etc

```

Each of those has real scenarios where they’d be useful.

The other issue is that these two things do not have the same semantics: `Function.constantly(code)` and `fn -> code end` will behave differently depending on what `code` is. If `code` is `DateTime.utc_now()` then `Function.constantly` will return the same date time over and over, but `fn -> DateTime.utc_now() end` will return a new datetime each time it is invoked.

---

_[View the full topic](https://forum.elixirforum.com/t/is-function-constantly-worth-adding/39830)._
