Log In  

I'm trying to do some table trickery with the __newindex() metamethod, but I can't actually create a new entry in the table from inside of it unless I nil-ify the __newindex key first, because it'll just recurse back into it when I try to set something.

Supposedly, we're meant to use rawset(t,k,v) to create keys safely while inside there, but we don't have access to that on pico.

@zep, is there any chance you could give us access to rawset() in the next version, so I can do this properly? Setting the metamethod to nil and then restoring it just feels horribly inefficient and klunky, since it triples the work needed when I first set vec.x=123. I hope this is just an oversight in the list of exported Lua features.

Edit: Apparently there's a rawget() too. I should probably ask for that as well.

Please? :)

PS: Also, since I'm being all greedy anyway, next() would be nice too. ;) But not as important.

P#43630 2017-08-26 03:31 ( Edited 2017-08-26 08:30)

I second this. I can't believe this feature isn't more requested! This is some of the most basic functionality of advanced Lua.

P#62542 2019-03-04 20:04

[Please log in to post a comment]