[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: problem with string.format %d and very large integers
- From: Roberto Ierusalimschy <roberto@...>
- Date: Thu, 4 Aug 2011 13:23:38 -0300
> What are your thoughts about using int64? Not ANSI? Not performant?
Both. Moreover, it does not solve all cases. For instance, fseek is
limited to long in C.
> If the problem is widespread, I wouldn't argue that 'format' should
> get special privileges. With table indices, you did such a beautiful
> job providing "general semantics with good performance for ints" that
> I though this might be your goal everywhere.
As pointed out in the case of fseek, the big problem is the interface
with C. And documenting everything would be messy; the limits are not
even the same for every function (e.g., int x long x size_t).
Although it was me who came with the "widespread" argument, I guess it
is not that widespread in pragmatic terms. As Dirk pointed out, it is
rare (or impossible, in Lua) to have too large structures, so in real
programs seldom (or never) a real index will be larger than 2^31 or
whatever the limit. It may be more useful to collect real scenarios
where this problem actually happens (e.g., format, which applies to
generic numbers, not only indices or sizes) and try to solve them
(e.g., with error messages).