It's became industry standart for the most languages how the scope of variable is determined. Passing as a parameter, if there are many parameters: creation of value classes, if there are many clients (readers) - we can always create global field.
Visibility of scope is becoming predictable by looking into nesting braces in the source code. That makes it easy to read and understand the code, but in some cases isn't enough for automations and doesn't abstract from non functional TODOs like - automated caching or transaction management, while context for the same should be passed across the whole flow as explicite parameter.