[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: String equality?
- From: Ben Sunshine-Hill <sneftel@...>
- Date: Sat, 3 Dec 2005 10:27:10 -0800
On 12/3/05, Chris Marrin <email@example.com> wrote:
> will the pointer s always be equal to the pointer prop? In all the cases
> I have tried it is. But can I rely on this?
It certainly is in the current implementation. The VM relies on
pointer equality for string comparisons, so you can too. But I seem to
recall that the last time this came up, it was pointed out that this
is not part of the standard, and may change in future versions (though
it's hard to think how).
A method that would clearly be compliant would be to store the strings
themselves, rather than the pointers. Because all Lua strings are
interned, comparisons are constant time.