# What is local in locally scoped scratches?

**URL:** <https://discourse.gohugo.io/t/what-is-local-in-locally-scoped-scratches/29338>\
**Category:** support\
**Created:** [November 10, 2020, 2:12pm UTC](https://discourse.gohugo.io/t/what-is-local-in-locally-scoped-scratches/29338 "2020-11-10T14:12:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidsneighbour](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/davidsneighbour/32/24507_2.png) [@davidsneighbour](https://discourse.gohugo.io/u/davidsneighbour)\
**Post date:** [November 10, 2020, 2:12pm UTC](https://discourse.gohugo.io/t/what-is-local-in-locally-scoped-scratches/29338/1 "2020-11-10T14:12:58Z")

</div>

I am slightly confused by the _eversame_ description of `newScratch` as “locally scoped”. What exactly counts as locally scoped? I know that it means, that this variable (scratch) is available only within that “location”, but what can define such a border or local restriction?

- is it local in a partial (I guess yes)
- is it local in a range (in sense of not available outside of the range?)
- is it “hyper local” in a range (in sense of available only inside of each single run of that range to that exactly run? meaning I range through `slice(1,2,4)` and inside of that range the 1-range has it’s own defined scratch which is not available in the 2-range?)
- is it local inside of if/else “loops”?
- is it local inside of shortcodes? (it is, just adding that)
- any more places that can create local scopes?

I need a dummy explanation 😉 The only way I know scopes is from PHP where “local” is inside of methods and functions.

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [November 10, 2020, 3:36pm UTC](https://discourse.gohugo.io/t/what-is-local-in-locally-scoped-scratches/29338/2 "2020-11-10T15:36:38Z")

</div>

I’m not sure how to explain it or if the original description of it makes sense … But I think it makes most sense comparing it to Page.Scratch

- $m := newScratch shares the scope of $m – so if you pass $m into a partial, you extend its scope, else it dies at the end of the template where its defined
- .Scratch is shared between every template that uses it – which sometimes has some unexpected side-effects in a parallel universe where the order of things isn’t guaranteed.
