lua-users home
lua-l archive

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


> Tables and hashes aren't easily comparable.
Whether you are implementing a package distribution service, or just
loading a file as a client, you will have read access to the file
contents anyway. A string equality comparison of a hexadecimal hash is
the most deterministic way to assert identity, and pure Lua hashing
implementations are available.[1] In vivo, self reported version
numbers tend to merely be additional non-determinstic "description"
bits.[2]
If the problem is not one of uniqueness, but of temporal sequencing,
my second suggestion is to use a "os.time()" timestamp property. If
the actual property one desires to compare is comparable, then
bikeshedding over meta-information can be avoided.

[1] http://lua-users.org/wiki/SecureHashAlgorithm
[2] https://lkml.org/lkml/2011/5/29/204
On Thu, Nov 10, 2011 at 2:45 AM, HyperHacker <hyperhacker@gmail.com> wrote:
> On Thu, Nov 10, 2011 at 01:44, David Hollander <dhllndr@gmail.com> wrote:
>> If the present goal is "unique id", instead of:
>> (file name, version protocol) --> unique id
>>
>> why not just do:
>> (file name, sha2 hash of content) --> unique id
>>
>> A protocol for versions is itself subject to versions, whereas a SHA2
>> hash is not.
>>
>> - David
>>
>> On Thu, Nov 10, 2011 at 1:12 AM, Michael Richter <ttmrichter@gmail.com> wrote:
>>> D'oh!  Sorry.  Hit "send" by accident.
>>>
>>> On 10 November 2011 15:06, Michael Richter <ttmrichter@gmail.com> wrote:
>>>>
>>>> I'm finding all this string- and float-fetish here a bit odd.  Is there
>>>> some reason we can't just have version tables like this:
>>>
>>> M1._version = { 1, 2, 3 }   // equivalent to version 1.2.3
>>> M2._version = { 4, 5 }      // equivalent to version 4.5
>>> M3._version = { 3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 8 }
>>>                             // equivalent to version dotted-pi
>>>
>>> We could then have a standard module version metatable (initially a de facto
>>> standard, but later perhaps even officially blessed) that provides natural
>>> comparison semantics (so that 4.5 is greater than 1.2.3, for example), that
>>> provides a default printing format, both long-form and short-form even if
>>> you'd like and provides other versioning services.
>>> --
>>> "Perhaps people don't believe this, but throughout all of the discussions of
>>> entering China our focus has really been what's best for the Chinese people.
>>> It's not been about our revenue or profit or whatnot."
>>> --Sergey Brin, demonstrating the emptiness of the "don't be evil" mantra.
>>>
>>
>>
>
> Tables and hashes aren't easily comparable.
>
> --
> Sent from my toaster.
>
>