lua-users home
lua-l archive

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



On 17-May-05, at 7:08 AM, Mike Pall wrote:

Mutable strings (plain buffers or buffer lists/trees) may be a better
solution. However this must be a core data type: you need a C API
to access the raw buffer and not just a __tostring metamethod.
Otherwise you loose all advantages since every C function needs to
convert them to/from immutable strings (which is exactly what we
want to avoid). And indexing tables is tricky, too.

That's a completely different issue. However, it's also interesting.

It would indeed have to be a core datatype, and you would therefore
need both a C API and Lua operators in order to gain the benefit.
I think that you should not expect that a stringbuffer would be
equal to a string with the same characters from the point of
view of table indexing; a mutable object needs to be keyed by
object equality, not by value equality. That would probably be
too confusing for normal use.

Actually, I'd probably implement a stringbuffer as a generalization
of file objects, rather than as pseudostrings.