[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: assert() and local vars
- From: "Eric Ries" <eries@...>
- Date: Fri, 22 Jun 2001 11:09:44 -0700
Oops, my bad. Thanks *blush*
> -----Original Message-----
> From: owner-lua-l@tecgraf.puc-rio.br
> [mailto:owner-lua-l@tecgraf.puc-rio.br]On Behalf Of Curt Carpenter
> Sent: Friday, June 22, 2001 10:31 AM
> To: Multiple recipients of list
> Subject: RE: assert() and local vars
>
>
> What's wrong with the built-in assert?
>
> -----Original Message-----
> From: Eric Ries [mailto:eries@there.com]
> Sent: Friday, June 22, 2001 10:19 AM
> To: Multiple recipients of list
> Subject: assert() and local vars
>
>
> Hello all... I'm working on a wrapper for C-style asserts in Lua. I am
> wondering if something like this would work:
>
> function foo(a)
> local b
> b = a * 2
> ... etc
> LuaAssert( "a > b" )
> ... etc
> end
>
> function LuaAssert( cmd )
> local result = dostring( cmd )
> if result and result > 0 then
> c-style-assert( 0 )
> end
> end
>
> The problem is that the locals a and b are not defined in LuaAssert...
> is there some way to get around this?