lua-users home
lua-l archive

Re: Some enhancement requests

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


>From: Edgar Toernig <froese@gmx.de>
>1. Allow the $if/$ifnot statement to test if debugging is turned on
> so that one can add additional debugging code in lua programs.
The purpose of $debug is to enable better error messages, not to support
user-level debugging.
I think you could do what you want using a global variable, say DEBUG,
and then write:
$if DEBUG
 print("x.n=", getn(x))
 foreach(x, function(i,v) assert(type(i)=="number", "bad x") end)
$end
To enable this code using the standard standalone interpreter, you can simply
do	lua DEBUG=1 myfile.lua
>2. The second argument to the next() function should be optional so that
> next(foo, nil) is the same as next(foo). I use next() regularly to test
> if a table is empty (if next(tab) then print"not empty" end) and the 
> additional nil is disturbing and inconsistent.
Using "next" to test whether a table is empty is a clever idea, but it got me
thinking *why* you would want to do this.
Anyway, the request sounds reasonable to me. We'll see...
--lhf

AltStyle によって変換されたページ (->オリジナル) /