lua-users home
lua-l archive

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



On 17-May-05, at 11:44 AM, Chris Marrin wrote:


What a pain.

I did a test to see if I could get strings to behave like atoms. I tried a short, 3 char string and a long, 35 char string. From the code it looks like strings above and below 32 chars are handled differently. I assume that is what everyone here has been talking about when saying "short strings".

No, we were discussing a possible improvement (or not) to Lua.

The difference between strings <= 32 and > 32 only has to do with hashing, not the string address.


I did 3 tests. I loaded the strings, got back their char* pointers, then put them into the registry and popped them. Then I forced a GC and loaded the strings in the registry onto the stack and checked their addresses. They matched. Then I loaded those same strings again with new pushstring() calls, and they matched. Then I executed these two functions, in turn:

function _getabc()
    return "abc"
end
function _getlongString()
    return "AVeryVeryVeryVeryVeryVeryLongString"
end

Looking at the returned string values, the first one matched and the second one didn't.


As far as I know, that can only mean that either the long string got gc'd somewhere along the way, or that you mistyped it in the _getlongString function.