[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: [ANN] typecheck 1.1 released
- From: "Gary V. Vaughan" <gary@...>
- Date: Fri, 7 Jul 2017 20:45:19 -0700
I am happy to announce release 1.1 of typecheck.
Typecheck's home page is at http://gvvaughan.github.io/typecheck
A Luaish run-time gradual type checking system, for argument and return
types at function boundaries with simple annotations that can be
disabled in production code. Its API and type mismatch errors are
modelled on the core Lua C-language `argcheck ()` API.
- _Luaish_: Type check failures show error messages in the same format
as Lua itself;
- _run time_: Without changing any library code, the application can
decide at run time whether to enable type checking as it loads the
library;
- _gradual_: Type checks can be introduced to the functions in your code
gradually, to as few or as many as seem useful;
- _type checking_: function argument types and return types are checked
against the specification, and raise an error on mismatch.
This is a light-weight library for Lua 5.1 (including LuaJIT), 5.2 and
5.3 written in pure Lua.
This code started life as the function argument and return type checking
system I wrote for lua-stdlib. I’m in the process of slimming down
lua-stdlib in preparation for the next release though, part of which
means that you can now use typecheck without requiring the installation
of all of stdlib.
## Noteworthy changes in release 1.1 (2017-07-07) [stable]
### New features
- Support type annotations with concat decorators.
```lua
local my_function = argscheck "my_function (int, int) => int" ..
function (a, b)
return a + b
end
```
- New `check` method for ensuring that a single value matches a given
type specifier.
- New "functor" type specifier for matching objects with a `__call`
metamethod - note, most `std.object` derived types will match
successfully against the "functor" specifier.
- New "callable" type specifier for matching both objects with a
`__call` metamethod, and objects for which Lua `type` returns "function"
- note, this is exactly what the "function" specifier used to do.
### Bug fixes
- `argerror` and `resulterror` pass level 0 argument through to
`error` to suppress file and line number prefix to error message.
### Incompatible changes
- The "function" (and "func") type specifiers no longer match objects
with a `__call` metamethod. Use the new "callable" type specifier to
match both types in the way that "function" used to, including most
`std.object` derived types.
- Rather than a hardcoded `typecheck._VERSION` string, install a
generated `typecheck.version` module, and autoload it on reference.
Install it with LuaRocks, using:
``` bash
luarocks install typecheck 1.1
```