[*]: Ahh, new idea: Unit testing using examples in the docstring ...
Am 25.04.2013 08:29 schröbte Geoff Leyland:
Hi!I think those tools have more chances of being successful if they reuse information that is already there or at least has other benefits besides type checking. It increases the motivation to actually write annotations, and maybe you can even detect outdated documentation during unit testing[*]. So reusing LDoc comments is a good idea, IMHO.
On 25/04/2013, at 10:02 AM, Philipp Janda <email@example.com> wrote:
Hello fellow Lua users!<snip>
Do you like Python's docstrings or their Lua equivalent?
Do you want your Lua function definitions to look like this ...
... to get type checking for function arguments and/or return values?
 does a similar argument-checking thing. It parses special LDoc comments (that LDoc now supports) and uses a hook, rather than a decorator (hooks are unfortunately very slow, but at least optional).
There is also this wiki page, and some time ago I implemented the typecheck decorator outlined here. But what upset me was that none of my attempts at type checking could even handle the Lua standard library (especially table.insert( table, [pos,] value ) was #$!%..., and return values are not that easy either (e.g. somevalue _or_ nil,errormessage)). Btw., that's also the reason why I'm not entirely convinced that Luadoc's/LDoc's current comment format is the best fit for Lua.
Comment syntax is inspired by , which is also an argument checker, and there was a conversation about argument checking last year 
I already knew about checks, and I like it because it requires little code, and probably is faster than most other attempts (although I would have merged the checks function and the checkers table into one functable and returned it via require without setting a global). The custom type functions for checks and annotate should be compatible.
Philipp[*]: Ahh, new idea: Unit testing using examples in the docstring ...