lua-users home
lua-l archive

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

* Reuben Thomas:

> I would ask, could one reimplement the C to Javascript translator
> Emscripten with a Lua backend using this library?

That depends on what optimizations Emscripten needs from the
Javascript environment to achieve good performance.  If it's just
compact, mutable byte arrays, then the proposed library should be good

> And see Javascript typed arrays. That seems a good model.

Including aliasing between different representations and strided
arrays?  It would certainly complicate the C API and add another

Perhaps adding functions such as {get,put}{16,32}{le,be} enough which
access the byte array at specified positions, using a specified width
and endianness.  A DNS header could be parsed like this:

  local txnid, flags, qcount, ancount, nscount, adcount =
    bytes.get16be(b, 1, 6)

This seems more attractive to me in Lua than Javascript because there
are multiple return values.