# Documenting when the closure "bug" (#15276) binds, and how to avoid it for introductory users

**URL:** <https://discourse.julialang.org/t/documenting-when-the-closure-bug-15276-binds-and-how-to-avoid-it-for-introductory-users/12642>\
**Category:** General Usage\
**Tags:** closure\
**Created:** [July 24, 2018, 11:13pm UTC](https://discourse.julialang.org/t/documenting-when-the-closure-bug-15276-binds-and-how-to-avoid-it-for-introductory-users/12642 "2018-07-24T23:13:44Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [July 25, 2018, 3:37pm UTC](https://discourse.julialang.org/t/documenting-when-the-closure-bug-15276-binds-and-how-to-avoid-it-for-introductory-users/12642/9 "2018-07-25T15:37:16Z")

</div>

Perhaps this previous #Internals & Design thread would be helpful for folks that want to dig in deeper as to why and how this occurs:

> [@Language restriction to solve 15276?](https://discourse.julialang.org/t/language-restriction-to-solve-15276/10625/30):
>
> Unfortunately inference can’t help us much here. The boxing is occurring at the syntax level. This is before Julia has access to inference. It’s before compilation. That’s what makes it so tricky. We’re in #development — let’s make it more #development-y. Here’s one of the simpler examples from the big #15276 thread: julia\> Meta.@lower function f() if true end r = 1 cb = ()-\>r cb() end [(output)](https://gist.github.com/mbauman/c914f1ac07a9da9a803231455714c434) There’s a lot going on there, and…

In short, it is a predictable syntactic transform (albeit with complicated rules). You don’t need any types or previous definitions (beyond macros) to see if it’ll occur. Just check `Meta.@lower` for `Box`es. I’d love to find some time to spend with linting — this is highly lintable and could be flagged by an editor.

IMO: Closures can be a challenging topic to teach. Focus on the behavior first. This performance snag is just going to further confuse things unless you’re very careful.

---

_[View the full topic](https://discourse.julialang.org/t/documenting-when-the-closure-bug-15276-binds-and-how-to-avoid-it-for-introductory-users/12642)._
