lua-users home
lua-l archive

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

What's wrong with the built-in assert?

-----Original Message-----
From: Eric Ries [] 
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

function LuaAssert( cmd )
   local result = dostring( cmd )
   if result and result > 0 then
      c-style-assert( 0 )

The problem is that the locals a and b are not defined in LuaAssert...
is there some way to get around this?