Deceptively basic Lua tables question

General discussion about LÖVE, Lua, game development, puns, and unicorns.
User avatar
zac352
Party member
Posts: 496
Joined: Sat Aug 28, 2010 8:13 pm
Location: In your head.
Contact:

Re: Deceptively basic Lua tables question

Post by zac352 »

kikito wrote:Well, to each one his thing. Some people don't like Lua just because it isn't strongly typed :crazy: .
I'm getting a little crazy from the lack of OOP. Squirrel is simple, has OOP, has tables, ... :crazy:
Hello, I am not dead.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Deceptively basic Lua tables question

Post by kikito »

And it also has a nice and helpful forum. (may Ganesha forgive me)
When I write def I mean function.
User avatar
zac352
Party member
Posts: 496
Joined: Sat Aug 28, 2010 8:13 pm
Location: In your head.
Contact:

Re: Deceptively basic Lua tables question

Post by zac352 »

kikito wrote:And it also has a nice and helpful forum. (may Ganesha forgive me)
Don't worry, when I start on physibots again I'm putting in both Lua and Squirrel. Squirrel first (just because of the simplicity of implementing it. :P).
Hello, I am not dead.
User avatar
Xgoff
Party member
Posts: 211
Joined: Fri Nov 19, 2010 4:20 am

Re: Deceptively basic Lua tables question

Post by Xgoff »

kikito wrote:A nice solution would be having nil[whatever] return nil silently, without raising an error. I believe in Squirrel they do just that. I don't think it can be done in Lua.

Code: Select all

debug.setmetatable(nil, { __index = { } })
print((nil).test) --> nil
probably won't make some people very happy if they see it though
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Deceptively basic Lua tables question

Post by bartbes »

I mean, you can do anything with your code, nobody will take that away from you, but I would like to note that the debug library is not to be used in production code (as stated by the lua manual.. somewhere).
User avatar
Xgoff
Party member
Posts: 211
Joined: Fri Nov 19, 2010 4:20 am

Re: Deceptively basic Lua tables question

Post by Xgoff »

you're probably fairly safe as long as you're effectively sandboxing user code. the debug library may be less dangerous than allowing loading of bytecode (especially in 5.2), at least, which is something i bet a lot of people overlook
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest