NIL.StrictGlobal(onoff) - jpbubble/NIL-isn-t-Lua GitHub Wiki

This function can make NIL more delicate, but it can also help to make bugs easier to track down.

NIL.StrictGlobal(true)
global int b
b = 4      // will work
b = 5      // will work
b = "five" // will crash

Why is it that that 'b = "five"' will not crash without calling NIL.StrictGlobal() first? This has been done to ensure that if you use third party additions written in "pure Lua" will not be incompatible, as you should know NIL.StrictGlobal() affects the entire 'state' or 'VM' or what-you-wanna-name-it, and although third party stuff written in some kind of "clean code" (since 'rules' is a dirty word for Lua scripters) it should still work, since this function only affects global variables declared in NIL, conflicts are still possible, and if they occur at least you can make sure they won't happen by simply not using NIL.StrictGlobal()

Also note that this only affects globals, and not locals, and global variables defined in "pure Lua" will be seen as "variant" or "var" and therefore accept any type.

Please note, class and group properties are not affected by these as NIL already protects them from the start! And also note that this document assumes that you imported NIL into Lua as a global in the variable NIL.

== NOTE! In the future of NIL, this function should also protect global functions, classes and groups from being overwritten. In that case this will work

delegate a
a = void()
  print("Hi")
end
a = void()
  print("Hello")
end

But this will not

void a()
  print("Hi")
end
a = void()
  print("Hello")
end