lua-users home
lua-l archive

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


On Thu, Mar 01, 2007 at 05:15:42AM -0800, gary ng wrote:
> --- Eike Decker <eike@cube3d.de> wrote:
> 
> > You could also write a C userdata object that allows
> > you to create a buffer that you can manipulate. 
> Thanks. I thought about this before. However, it seems
> that lua string is the natural object to interface
> with other libraries(file, luasocket, curl, zlib , md5
> etc.) so if I create my own data type, I need to
> covert to/from string. And also the search, find etc.
> that is available for string.
> 
> If hash is the only concern, I can live with that as
> it would be a buffer that would not be used as key.

But lua can't live with it.. every string is immutable because it is
stored globally by hash value. If you change any chars inside it, you
will wreck havoc with lua.

	h = 'helo'
	l = 'helo'

lua has created only one string object, actually. But you can pretend
there are two independent objects. Since the object can't be changed,
you can't do anything to l that will effect h.

Sam