lua-users home
lua-l archive

Re: game developers?

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


David Jeske <jeske@chat.net> wrote:
> Solutions that seem useful to me would be:
> - allowing "0" to be considered false 
> - creating a "real false" value, which looks like nil, but takes
> up space.
How about a tagmethod for boolean:
----------
None = {}
noneTag = newtag()
settagmethod( noneTag, "boolean", function () return nil end)
settag(None, noneTag)
----------
Now when we have:
if aTable.a then
 ...
end
If "a" is None or nil, then the "if" evaluates a false
otherwise it evaluates to true. "None" could then be used
as the false boolean (unlike nil) can hold a place in a table.
Steve

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