[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: RE: Lua hash algorithm
- From: "Jordan, Chuck" <CJordan@...>
- Date: Wed, 19 Jun 2002 13:02:09 -0700
> However, I cannot fathom why anyone would want to use
> floating point keys in a hash table. Integer indexes and
> string indexes make sense, but what is ` x[1.5] = "foo" '
> supposed to express?
In my case, it means that at 1:30 AM, a simulator in my game should have value "foo". (It maps a response curve based on time).
A couple of other examples; I could think of more if pressed:
x[0.5] = "foo" -- there's a 50% chance of picking "foo"
x[0.5] = "one half" -- translate common floats to human-readable forms
Part of what makes lua so simple and extensible is the concept of one single data structure that can hold *anything*. Even though it's more efficient to limit the language to integer-based arrays, that seems to me to be hobbling the power of the language for the sake of an implementation.