lua-users home
lua-l archive

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


On Tue, Aug 29, 2006 at 09:59:29PM -0300, Luiz Henrique de Figueiredo wrote:
> > I would like to hear a discussion about how the lua core can have some
> > of its assumptions about numbers loosened so that new number disciplines
> > like this can be implemented with minimal patching (preferably, none!)
> > of the core code
> 
> This is already (mostly?) possible using the luai_num* macros in
> luaconf.h. The next version will add the Lua state to those macros,
> which hopefully will allow all sorts of implementations for numbers.

There are some assumptions about the size of numeric types, things like
lua_pushfstring() assumes arguments for the %d format are of size int,
so you can't pass a lua_Integer to lua_pushfstring() if lua_Integer is
defined to be other than sizeof(int).

Also, I don't think its possible to choose multiple representations for
numbers, where representation is chosen during chunk compilation, with
promotion/demotion as necessary at runtime. You can chose the
representation, but it must correspond to a C type, perhaps one no
larger than double or int32.

For example, I don't think you can chose for TValue's Value.n to be

  union { double d; mpf_t f; mpz_t z; }

, with double being the default rep, but overflowing into mpz_t or mpf_t
(from GNU mp) as necessary.

Anyhow, enjoy the conversations over there, I wish I could listen in.

Cheers,
Sam