What is local in locally scoped scratches?

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 :wink: The only way I know scopes is from PHP where “local” is inside of methods and functions.

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.
2 Likes