lua-users home
lua-l archive

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


2014-08-02 9:26 GMT+02:00 Tim Hill <drtimhill@gmail.com>:

> math.tointeger
> string.dumpint

> I think the names are fine as-is: load/dump is a common idiom, and matches
> the “low-level” concept of the new APIs. Whereas “tointeger” is a
> conversion, hence the name.

But it is not string.loadint, it is string.undumpint. Say that a few times
out loud. Undumpint. Undumpint. Undumpint.

I still like my previous suggestion of bformat and bscan, which
can do several numbers in one go, but would not be unhappy with

string.dumpnum(num,spec)
string.loadnum(num,spec)

where "spec" is the concatenation of size and optional endianness.
You lose the default argument, but save two functions. And avoid
having to undump.