[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lightweight Lua Enumerations
- From: Rici Lake <lua@...>
- Date: Thu, 28 Jun 2007 11:03:18 -0500
On 28-Jun-07, at 10:23 AM, Gavin Kistner wrote:
It's not, and I grok the stringness of variable names. It just somehow
/feels/ cleaner :)
(Except, as parenthetically noted above, that I could have _G holler on
__index and it would tell me about a typo that wouldn't be so readily
identifiable if the typo was in a string literal. But...I never ever do
that.
That's a fair point. On the other hand, an enumeration value
should always be checked when it's used, no? That is, at
some point you're going to do something with the value, and
at that point you must validate it.
if opcode == "sin" then do_sin()
else -- assume it's "cos" ?????? bad, bad, bad
I've had more debugging issues with tables used as keyword
parameters. Those are a lot harder to validate:
function do_it(options)
-- ...
if options.opcode then ....
-- ...
end
do_it{OpCode = "sin"} -- ooops
That's one of the reasons I always use lower case :)