luabind icon indicating copy to clipboard operation
luabind copied to clipboard

Objective C++ support

Open rpavlik opened this issue 12 years ago • 3 comments
trafficstars

Saw this commit in the network: https://github.com/wuhao5/luabind/commit/7a3bdc51ac3edf853d9619a2e436d1f407f865a4

Objective C/C++ has "nil", so they rename it here to nil_. (the rest of the commit is unrelated test fixing). API breaking if you used nil, but seems prudent. Worth integrating?

rpavlik avatar Aug 14 '13 18:08 rpavlik

Actually I'm not sure if nil is needed altogether; is there a case where it behaves differently from an uninitialized (i.e. default constructed) object?

Oberon00 avatar Aug 14 '13 18:08 Oberon00

The docs indicate that it can be used to assign nil to a table element (or presumably any other luabind::object). It seems unused in the source code and tests aside from this.

rpavlik avatar Aug 14 '13 19:08 rpavlik

A uninitialized object can also be used to assign nil, but only because it ultimately does lua_rawgeti(LUA_REGISTRYINDEX, LUA_NOREF) and there is nothing at LUA_NOREF (-2) in the registry. The Lua Reference Manual states:

The integer keys in the registry are used by the reference mechanism, implemented by the auxiliary library, and by some predefined values. Therefore, integer keys should not be used for other purposes.

So I think one could say that this behaviour is "implicitly documented" in Lua.

Oberon00 avatar Aug 15 '13 07:08 Oberon00