lua-users home
lua-l archive

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


> Why would I want to compare a table to a string if I've got the tables?

The primary advantage of comparisons using a hash string over a
_VERSION table is it works regardless of whether or not the source of
the module is trusted. It also always works for everything, rather
than a subset of code with _VERSION set to a table faithfully and only
shared via HTTPS\SSH. If the fundamental reason for version identity
is to prevent unknown state\non-determinism, the additional advantage
of a hash string comparison is that it can also be performed before
executing the module in question.

The primary advantage of a number time timestamp being set upon
redistribution over a _VERSION table, is that it is a metric
containing more information. It signals "recentness" in addition to >,
<, ==, and can be re-displayed in a variety of formats and orderings
without changing the underlying information.

- David


On Thu, Nov 10, 2011 at 4:32 AM, Michael Richter <ttmrichter@gmail.com> wrote:
> On 10 November 2011 18:02, Duncan Cross <duncan.cross@gmail.com> wrote:
>>
>> >> Tables and hashes aren't easily comparable.
>> > They are if you provide the metatable with comparison operators.
>>
>> The comparison metamethods are only consulted if both values are of
>> the same basic type, so even with those you cannot make a table == a
>> string.
>
> And we're back to the string fetish. Why would I want to compare a table to
> a string if I've got the tables?  (And, of course, if I absolutely
> must compare to a string, surely a function to convert from the table to the
> string could be added…)
> --
> "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.
>