lua-users home
lua-l archive

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


It was thus said that the Great Lorenzo Donati once stated:
>
> BTW, I have also wondered why (full) userdata creation is only possible 
> from C API. Wouldn't it be possible to devise a safe way to define and 
> manage userdata from Lua? It could be useful for lots of things (maybe a 
> bit advanced, but no more than those of "goto"), without resorting to C, 
> therefore pushing farther the boundary where Lua could be used instead 
> of C (leaving C only for high performance tasks or very tight system 
> integration/communication).

  Could you give an example of what you mean?  From my perspective, a
userdata is typically a C structure, alignment of fields dependant upon the
architecture.  A structure like:

	struct foo
	{
	  char c;
	  int  i;
	  char *s;
	}

  could be anywhere from 5 bytes (say, from a C compiler for a 6809 or 8088)
to 24 bytes (a modern 64-bit system), with each field at a different offset
from the base address of the structure.

  -spc (In other words, I don't quite understand what you're asking for)