lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Tue, Apr 22, 2014 at 12:34 AM, Ross Bencina
<rossb-lists@audiomulch.com> wrote:

> Yep, or a hash table.
>
> Or you could use spare bits of the C pointer as was suggested earlier.
>
> Or if your objects are allocated from a slab you can do a pointer range
> check.

I do like this proposal but from what Philipp said it seems
inappropriate for the range of architectures Lua has to be portable
for.

Anyway, I don't see how a hash table of the pointer addresses would be
better.  Because they're just numbers a binary search to do an
existence check would seem appropriate, but I'd love to know how a
hash table would be better suited :>  I'm still trying to get a
mastery on data structures so...

A range check for an address returned by a slab allocator would be cool :D

Kinda-almost-relatedly I wish we had a debug.userdump() to stringify
userdata, so then you could check from Lua if the contents of the
lightuserdata is an address that matches the type you're expecting.
Wouldn't be more efficient than this patch, but I'm just brainstorming
~