lua-users home
lua-l archive

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



> *From:* ÒÒÕñì³ <yizhenfei@gmail.com>
> *To:* <lua-l@lists.lua.org>
> *Date:* Tue, 23 Oct 2012 12:07:11 +0800
> 
> Without static type checking, we may send wrong parameters to a 
> function
> and we cannot find this mistake until the program crashes in run 
> time.
> But if it is a huge program, we are not able to cover 100% codes in 
> test,
> in this situation ,how can we prevent this problem?(say, pass wrong 
> type
> parameters to a function)
> 
> Sorry, I am a new comer with Lua, and it is the first time for me 
> to learn
> a dynamic language, forgive me if this problem is ridiculous. But 
> it really
> bothered me for a long time.
> 
> Regards,
> Zhenfei Yi.
> 
> 
> --
> *Included Files:*
> am2file:001-HTML_Message.html

I think you'll find this answer to a similar question I posed a couple of
weeks ago very relevant

====================== copy follows ========================
On Wed, Oct 3, 2012 at 3:08 PM, Thijs Schreijer <thijs@thijsschreijer.nl>
wrote:

> >
> > I suppose I could write a function "checkargs"
>
> iirc the Sierra Wireless folks did something like that.
>

Indeed we have, and usage proves that it's an excellent API documentation
(terse, readable, extensible, and you have to keep it up-to-date with the
code). Eventually I'd like to hack Eclipse's type inference system so
that
it could use it to gather hints.

Here it is, no dependency beyond lua.h:

https://github.com/SierraWireless/luasched/blob/master/c/checks.c

-- 
Fabien Fleutot
+---
| 33 chemin de Mange-Pommes
| 31520 Ramonville Saint-Agne -- France
| mobile: +33 6 28 06 09 97
| office: +33 5 61 00 06 49
| home: +33 5 61 75 05 67


--
*Included Files:*
am2file:001-HTML_Message.html