lua-users home
lua-l archive

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


On Jun 27, 2007, at 6:06 PM, Rici Lake wrote:
On 27-Jun-07, at 6:09 PM, Gavin Kistner wrote:
What do _you_ do when you need a simple, lightweight way to create some
unique values?

I use simple lower case strings, unless a better solution
occurs to me. In your example, I would might use "good", "sin",
"cos" and "sin".

Would you do:
  GOOD = "good"
  SIN = "sin"
  COS = "cos"
and use the 'constant' variable for assignments and comparisons? I realize the foolishness of that, but (even without a hack to holler if I read an undefined global) it somehow feels cleaner than just hardcoding the same literal strings in many places in the code.

Having said that, I might well choose to use math.sin and math.cos
for the operation, if those were appropriate. For example,
rather than using an enumeration of "BlendType"'s, I would be
tempted to use the actual blending functions.

For sure. That's not an option in my actual situation, though. I just liked the sin/sin comparison and reached hard to make something up :)