[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: integer Lua 4.0
- From: Nick Porcino <npporcino@...>
- Date: Thu, 9 Nov 2000 10:15:09 -0800
I would like to vote in favour of having a block something like the
following code block (but more complete of course). This way the only thing
we have to do to get a particular kind of lua build is to change a single
#define in lua.h. Furthermore, if we need to add more types for whatever
reason (new hardware platforms, etc) there would be a single place to do it
and all would be well.
#define LUA_NUM_TYPE_IS_INTEGRAL
//#define LUA_NUM_TYPE_IS_FLOAT
//#define LUA_NUM_TYPE_IS_DOUBLE
#if !defined(LUA_NUM_TYPE_IS_INTEGRAL) && !defined(LUA_NUM_TYPE_IS_FLOAT) &&
!defined(LUA_NUM_TYPE_IS_DOUBLE)
#error Must define a LUA_NUM_TYPE
#endif
#if defined(LUA_NUM_TYPE_IS_INTEGRAL)
#define lua_str2number(s,p) strtol((s), (p))
#define NUMBER_FMT "%ld" /* LUA_NUMBER */
#elsif defined(LUA_NUM_TYPE_IS_DOUBLE)
#define lua_str2number(s,p) strtod((s), (p))
#define NUMBER_FMT "%.16g" /* LUA_NUMBER */
#elsif defined(LUA_NUM_TYPE_IS_FLOAT)
etc. etc.
#endif
Thankyou for you consideration,
Nick Porcino
Lucas Learning
> LUA_NUM_TYPE_IS_INTEGRAL
> to decide which one to use.
>
> I hope that in 4.1 this can be formalised, so you really can
> change Lua to
> integer use just by changing LUA_NUM_TYPE (and perhaps my suggested
> LUA_NUM_TYPE_IS_INTEGRAL).