lua-users home
lua-l archive

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


Writing Lua libraries that target several Lua implementations can be a frustrating exercise in working around lots of small differences in APIs and semantics they share (or rename, or omit). This library provides the means to simply access deterministic implementations of those APIs preserving the the same semantics across all supported host Lua implementations. Each function is as thin and fast an implementation as is possible within that host Lua environment, evaluating to the Lua C implementation with no overhead where host semantics allow.

I am happy to announce release 1.0.2 of std.normalize.

Most of these functions started life in lua-stdlib, or one of the recent offshoots.

### Noteworthy changes in release 1.0.2 (2017-07-07) [stable]


#### New features


- `pack` sets a `__len` metamethod on its result so that `len` returns the actual number of arguments packed (including `nil`s).


- `unpack`ing a `pack`ed sequence returns the original sequence without requiring an explicit `to_index` argument, even if the original sequence contains `nil`s:


```lua a, b, c = unpack(pack(1, nil, 3)) assert(a == 1 and b == nil and c == 3, "require 'std.normalize' first!") ```


- `str` uses C-like escape sequences \a, \b, \t, \n, \v, \f, \r and \\ to render the associated bytes.


#### Bug fixes


- `getmetamethod` no longer raises an argerror for nil-valued initial argument.


- `ipairs` and `opairs` now diagnose all non-table valued arguments correctly.


- `str` now only skips consecutive integer keys in proper sequences.


### Incompatible changes


- `ipairs` now respects the `__len` metamethod, such as the one set by `pack`.


Install it with LuaRocks using:

``` bash
    luarocks install std.normalize 1.0.2
```