[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Argument checking in Lua?
- From: Chris Marrin <chris@...>
- Date: Wed, 01 Feb 2006 12:30:37 -0800
Doug Rogers wrote:
Chris Marrin wrote:
It would be easy to write such things, of course, by doing type(),
checking against nil and throwing errors. But is there any "standard"
way to do this? I have not been able to find anything...
I don't know of a standard way. Below is the way that I do it for a
couple of my projects (5.0). Note that I register my own types and use
Object.type() rather than the built-in type(). But the system below
doesn't require the registration of types - just change 'typefunc or
Object.type' to 'typefunc or type'. I usually use Object.types3()
because it results in shorter argument lists.
...
Wow, that seems like a lot of work. Has anyone done a library to make
any of this simpler?
--
chris marrin ,""$,
chris@marrin.com b` $ ,,.
mP b' , 1$'
,.` ,b` ,` :$$'
,|` mP ,` ,mm
,b" b" ,` ,mm m$$ ,m ,`P$$
m$` ,b` .` ,mm ,'|$P ,|"1$` ,b$P ,` :$1
b$` ,$: :,`` |$$ ,` $$` ,|` ,$$,,`"$$ .` :$|
b$| _m$`,:` :$1 ,` ,$Pm|` ` :$$,..;"' |$:
P$b, _;b$$b$1" |$$ ,` ,$$" ``' $$
```"```'" `"` `""` ""` ,P`
"As a general rule,don't solve puzzles that open portals to Hell"'