[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: 5.2: equality for closures
- From: steve donovan <steve.j.donovan@...>
- Date: Wed, 29 Jun 2011 09:57:05 +0200
On Wed, Jun 29, 2011 at 9:31 AM, Lorenzo Donati
> So why it is not deemed useful to have the possibility to define custom data
> types in this way directly in Lua (not using C API, I mean)?
It is very useful to have in the language - this is exactly what
LuaJIT's FFI is all about. Alien allows similar stuff with vanilla
Lua and allows you to manipulate buffers as userdata.
But it is tricky to bring such low-level stuff into a high-level
language. It's often easier just to do it in C, since the _actual
layout_ of a structure depends on so many things, endianness, word
size, alignment, and so forth. Something like Roberto's struct
library knows about this stuff and can be used to unpack a given bit
of binary data in Lua.
Things like fast binary arrays are possible but really belong in a library.