lua-users home
lua-l archive

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


In message <5EC08AEC9A25D746ABB7341DCE1E7A6090B2A2@mx.ellipsbv.local> you wrote:

> My naive solution would be simple: Iterate over the array, add the
> string
> length of its members, add the required storage for any supplied
> separator,
> allocate the target string to the right, and memcpy() the array members
> (and
> any separators) over to their final location.

You are presuming that Lua strings are stored in arrays, as a consecutive
sequence of bytes, as in C. They are not. The reason why is very
interesting, but I leave to those who are more expert to explain.
Both methods of storage have their own advantages and disadvantages,
but the tradeoff chosen for Lua is an important aspect of what makes
Lua Lua, I believe. You cannot talk of the "location" of a Lua string
in the same way that you can for C.


-- 
Gavin Wraith (gavin@wra1th.plus.com)
Home page: http://www.wra1th.plus.com/