stevedonovan / luar

luar is a Go package for conveniently working with the luago Lua bindings. Arbitrary Go functions can be registered
MIT License
301 stars 55 forks source link

table should return nil if key does not exist #8

Closed hirochachacha closed 11 years ago

hirochachacha commented 11 years ago

Hi, thanks for updating 1.2! I currently use map to table conversion in my project. But I find if map__index raise error, I can't check key existence.

if foo["bar"] == nil then -- just want to check key ("bar") existence, but raised

end
stevedonovan commented 11 years ago

This would definitely be the most Lua-like behaviour, and Go maps work the same way as Lua tables if the key is the correct type. A more complete solution would raise an error if the key was not correct, but I agree with you that this is the way to go for now!

hirochachacha commented 11 years ago

I agree, I think add strict conversion option to LuaToGo is one solution.