I'm using Luabind to bind C++ classes to Lua. From the Lua script, I can add arbitrary properties (key/value pairs) to the tables that represent my classes, even if I never told Luabind these properties exist:
cheese = Cheese()
cheese.type = "gouda"
cheese.age = 2
cheese.hippopotamus = "monkey" -- Oops! This member was not defined!
The hippopotamus line, though nonsensical, will execute without causing a Lua error.
How do I prevent these new properties? I know that when using just the Lua C API this can be accomplished using the __newindex metamethod, but is there a way to do this with Luabind?