

Link: http://codepad.org/Z2oV03SO raw code | output | fork ]



Lua , pasted on Dec 31:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 function pack (...) return {...} end function AFCWrap ( Func , Packer , Unpacker , CollectedArgs ) return function (...) local CollArgs = CollectedArgs or {} local PackedArgs = {...} if ( # PackedArgs == 0 ) then return Func (( Unpacker or unpack )( CollArgs )) elseif ( # PackedArgs == 1 ) then table.insert ( CollArgs , PackedArgs [ 1 ]) else table.insert ( CollArgs ,( Packer or pack )(...)) end return AFCWrap ( Func , Packer , Unpacker , CollArgs ) end end function A ( B ) return function (...) print ( B ,...) return B ,... end end Class = AFCWrap ( A ( " Class" )) Method = AFCWrap ( A ( " Method" )) TypeCheck = AFCWrap ( A ( " TypeCheck" )) Class ( Method " A" ( TypeCheck " string" " number" ()) ( function ( str , num ) dostuff ( str , num ) end ) () ) ( Method " B" ( TypeCheck " string" " string" ()) ( function ( stra , strb ) return stra .. strb end ) () ) ()



Output: 1 2 3 4 5 TypeCheck string number Method A table: 0x8070da8 function: 0x806ee78 TypeCheck string string Method B table: 0x8070450 function: 0x806ab30 Class table: 0x806fa18 table: 0x806a3f0