lua-users home
lua-l archive

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


> Such strings would not get hashed unless one used them as a table
> index, and they would not get unified or copied either unless
> necessary.

Define necessary.

My first impression is that this would break string comparison, unless
you make extensive changes in the core. String comparison in Lua is
simply a pointer comparison, because of string unification. From what I
understand of your proposal, for lazy strings this comparison would have
to be on the strings contents.

One way to avoid excessive string hashing from the C side is to use store
strings in the array part of a Lua table. You'll still need a map from
C strings to indices, but if you're willing to add a complication such as
lazy strings, then that map shouldn't be too bad. Again, my impression is
that you'll probably end up creating some sort of string unification...

> implementing this as a separate [...] library might also be an option.

I suggest you try it first as a library. I think there are one or two
"mutable string" libraries around, though I don't have a pointer handy
right now.

--lhf