Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane

From: Andreas Stenius <kaos <at> explosive.se>
Subject: Re: Lua 5.1 Token Filters
Newsgroups: gmane.comp.lang.lua.general
Date: Wednesday 6th September 2006 15:32:55 UTC (over 12 years ago)
I'm feeling evil too.. so here goes a type check implementation with 
token filters ;o)

Attached is type_check.lua which does the work -- needs the 
dsilver-token-filter-patch -- and a type_test.lua to demonstrate it's 
use.. sample output follows:

./lua -ltype_check -ltype_test
Test... true
I now know this is a number:    123
OK
Test... false
OK      ./type_test.lua:3: bad argument #1 to 'basic_number' (number 
expected, got string)
Test... true
Oh, it's not nil anyway:        45.6
OK
Test... true
Oh, it's not nil anyway:        not a number either
OK
Test... false
OK      ./type_test.lua:7: bad argument #1 to 'num_or_string' (number or 
string expected, got table)
Test... true
Alot of options here, in order:         still a string  nil 
function: 0x52aec0      nil
OK
Test... true
Alot of options here, in order:         table: 0x52b0a0 333 
function: 0x52a0e0      nil
OK
Test... false
OK      ./type_test.lua:11: bad argument #4 to 'a_bit_more_complex' 
(userdata or nil expected, got function)
Test... true
I now have exactly two args passed.. oh well, the third could be an 
attempted arg as well, but it was nil any way
OK
Test... false
OK      ./type_test.lua:15: bad argument #3 to 'enforce_num_args' (nil 
expected, got string)
Test... false
OK      ./type_test.lua:15: bad argument #2 to 'enforce_num_args' 
(string expected, got nil)

I'm not feeling guilty enough yet to be sorry..

enjoy!

//Andreas

Ps.
And thanks to the Organizers and all other Oh-Six participants for a 
great workshop! (no names, or I'd feel I left ppl out)


[email protected] skrev:
> 
> Me, too :)    Not as productive as Daniel, but I did finish this late 
> last night, so here goes...
> 
> Ref: checking Lua function usage, and return values.
> 
> -asko
> 
>  
> 
> On Tue, 05 Sep 2006 22:38:39 +0200
>  Daniel Silverstone  wrote:
>> As per my agreement with lhf and various others at the Lua workshop this
>> year, I hereby confess my sins:
>> http://blog.digital-scurf.org/tech/lua-with-macros.html
>>
>> I'm sorry.
>>
>> D.
>>
>
 
CD: 21ms