# Associating arguments with partial functions to simplify nesting

**URL:** <https://discourse.julialang.org/t/associating-arguments-with-partial-functions-to-simplify-nesting/53457>\
**Category:** Performance\
**Tags:** gpu, argument, function\
**Created:** [January 16, 2021, 10:51pm UTC](https://discourse.julialang.org/t/associating-arguments-with-partial-functions-to-simplify-nesting/53457 "2021-01-16T22:51:29Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)\
**Post date:** [January 18, 2021, 12:50pm UTC](https://discourse.julialang.org/t/associating-arguments-with-partial-functions-to-simplify-nesting/53457/11 "2021-01-18T12:50:14Z")

</div>

> [@lmiq](#):
>
> > [@billykalfus](#):
> >
> > It seems to mention that in certain cases, there can be a performance penalty associated with type instability - any tips on how to avoid this?
> 
> It is nothing special about closures, it is for Julia in general.

Closures have extra problems related to type instability. See [this answer of mine](https://discourse.julialang.org/t/function-factories-or-callable-structs/52987/2). If you hit the problem with type-unstable closures you may want to use the _callable structs_ described there. However, I am not sure if you should not simply pass a function (without captured arguments) and pass the arguments down the chain with `args...` as other pointed out.

---

_[View the full topic](https://discourse.julialang.org/t/associating-arguments-with-partial-functions-to-simplify-nesting/53457)._
