lua-users home
lua-l archive

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


John Belmonte wrote:
> 
> It's not much work, here are the current long references:
> 
>     include\lauxlib.h(62): #define luaL_check_long(L,n)
> ((long)luaL_check_number(L, n))
>     include\lauxlib.h(64): #define luaL_opt_long(L,n,d)
> ((long)luaL_opt_number(L, n,d))

Well these are macros for people that _want_ longs.  If you don't
want them don't use them.

>     src\llimits.h(49): typedef unsigned long lu_mem;

Looks sane too.  The lu_mem must be >= size_t.  And an int may be
to short.

>     src\llimits.h(52): typedef long ls_nstr;

That's basically the same as lu_mem.

>     src\llimits.h(85): union L_Umaxalign { double d; void *s; long l; };

This is just there to force a maximum alignment of strings and userdata
passed back to C.

>     src\llimits.h(95): typedef unsigned long Instruction;

IMHO this one is bogus.  unsigned int would be better.  If the int
is 16 bit you're probably running on a 16 bit system and want the
short instructions.  On anything else it's 32 bit - the common
size.  (And if your system has 64 bit ints you lose anyway ;-)

>     src\lundump.c(222): if ((long)f!=(long)tf)

Makes sure that the binary numbers in the precompiled file are similar
to that of the running system.  Maybe that could be converted to a
smaller value that fits in any (even 16 bit) int.  But it's only done
once per load...

>     src\lib\lbaselib.c(107): unsigned long n;

That's for strtoul.  If your longs are 64bit you want it here.

>     src\lib\liolib.c(378): long offset = luaL_opt_long(L, 3, 0);

File offsets for fseek & co are a long.

>     src\lib\lstrlib.c(21): typedef long sint32;

Hmm... size_t on your system is probably long too.  IMO the best
choice.

> With that I could finally remove an item from my Lua warts list  ;)

I think you got the wrong system if you really want to get rid of
all longs ;-)  These systems are made to deal with large files and
memory.  That's why they have 64 bit longs.

I'm glad they made the move to remove all doubles and changed it
the lua_Number.  It may give problems with libraries that were
compiled for different number types but I consider this flaw less
problematic then the implied use of doubles anywhere.

Btw, if read_number in iolib would get a scanf-fmt string from the
config file too it would be perfect ;-)

Ciao, ET.