lua-users home
lua-l archive

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


>From dmarks@dionysus.phs.uiuc.edu Tue Jun 23 01:46:43 1998
>
>I remember reading on the mailing list a while back that Lua
>3.1 was possibly going to make strings non null terminated so
>they could contain nulls.  
>
>I'm writing a way to code up GPIB drivers for our lab devices
>in lua, and some devices return null characters in data.  I was
>contemplating writing my own block-of-bytes data structure but
>since I figured it would be in the next version I'd just wait.

yes, please wait. 3.1 is going to be out real-soon-now.

>Will the implementation in lua still null terminate strings for
>compatibility's sake?  And will there be new API commands to
>get and push lua strings for the non null terminated strings?

yes and yes.

>Another thing is that I noticed that in lua when lua_getstring()
>is called, it seems to make a copy of the string that is retrieved,
>even if that string is in a variable that is passed as a parameter.
>I tried to change the value of a string by directly writing to
>the string but the changes do not take effect.  Is this true,
>and if so,

all strings sent to Lua are duplicated inside Lua.
so, there's not way to change a string, once it's in Lua.

>will there be a way to retrieve strings by reference,
>so they don't have to be copied (and possibly could be modified
>in place?).  Some strings would be rather long, and it would
>good to avoid copying them excessively, and also it would be useful
>to use a string as preallocated space to store information.

you can always store the pointer as userdata, but you won't be able to
use it as string without duplicating the string in Lua.
--lhf