Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Interesting, it looks like you can use ´global myvar’ now, as compared to ´myvar’ implicit globals, say from back in 5.1, or ´local myvar’.

It’s worth noting that global is a reserved keyword now, so environments that had a ´global()´ function for escaping environments will now need to rename their helper function.





But.. why ? Globals are just variables that reside in the wrapping env table that also contain the C functions. If a closures is a onion of table lookups out of the function context from local -> function scope -> global scope is simply the last lookup before a not found variable with nil is declared?

Module exports with side effects, and setting environments doesn’t guarantee global access.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: