lua-users home
lua-l archive

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


2014-02-06 1:45 GMT+02:00 Rena <hyperhacker@gmail.com>:
> This is a trick I saw in the Dolphin emulator. I'm a bit surprised it's not
> more known. (At least, I've never seen it elsewhere.)

Overloading __tostring for functions is one way to document them.

I prefer, though, to have one function that documents anything.
As follows:

$ lua
Lua 5.2.3  Copyright (C) 1994-2013 Lua.org, PUC-Rio
> help=require"ihelp"
> help(table.sort)
Precompiled C function
> help(table.sort,[[
>> table.sort (list [, comp])
>> If comp is given, then it must be a function that receives two list
>> elements and returns true when the first element must come before the
>> second in the final order. Default: sort non-decreasing.]])
> help(table.sort)
table.sort (list [, comp])
If comp is given, then it must be a function that receives two list
elements and returns true when the first element must come before the
second in the final order. Default: sort non-decreasing.

Available as a rock, or at:

https://github.com/dlaurie/lua-ihelp