[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: RES: C++ Typecast - so far newbie question
- From: Patrick Donnelly <batrick@...>
- Date: Mon, 2 Jul 2007 15:08:37 -0600
> On 2-Jul-07, at 2:40 PM, SosCpdTerra wrote:
>
> > Did someone know a better way to typecast a const char * (that is about
> > lua_tostring(L, n)) into a char * then vector or c_str()? I'm fighting
> > with
> > that...
>
> Strings returned by lua_tostring *must not be modified*.
>
> So don't cast them to char* or evil things will happen.
I'm curious about the technical reasons/consequences for this. Naturally lua strings are meant to be immutable. I'm betting this has something to do with their hash value changing, and thus their index to the global environment (or whatever table they're in) being lost because the hash changes? I assume this would cause not only losing your string in the table but some segmentation faults if one attempts to access them? Would the garbage collector lose sight of these strings, or collect it almost immediately?
-Patrick Donnelly
"One of the lessons of history is that nothing is often a good thing to do and always a clever thing to say."
-Will Durant