The _global symbol_ is in fact a context parameter that is used to call various
API. Instead of passing it as a parameter to all templates, it is defined in a
macro and then used by all templates. I've tried to replicate in my small
example with the value `a` that I used in the loop.
type
Melon = object
template pairs*(m: Melon): tuple[key: int, val: int] =
iterator pairs(m: Melon): tuple[key: int, val: int] =
for i in a .. 10:
yield (key: i, val: i * i)
block:
let a = 2
var m = Melon()
for k, v in m:
echo "k=", k, "; v=", v
Run