lua-users home
lua-l archive

Re: Avoiding string duplication

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


It was thus said that the Great Chris Smith once stated:
> 
> On 6 Nov 2019, at 19:05, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
> > 
> > For all these reasons, it seems very unlikely that Lua will ever
> > change to a copying collector. Maybe it is time to change the manual
> > and make official this behavior?
> 
> I would certainly like to see this made official. However, it does raise
> some other interesting points and questions:
> 
> - Strings are immutable in Lua, but not in C. C code can directly modify
> a Lua string 
 Only by casting away the const modifier. Also, you can't change the size
of the string (or bad things might happen). But sure, yeah, C can do that.
> - Is there any real difference between Userdata and String objects? Are
> Strings simply Userdata whose content is cached and on which string
> functions can be called?
> 
> - Do we need both types? Would it be useful to be able to convert between
> Userdata and String objects? That is, to explicitly uncache/duplicate a
> String object or to mark Userdata as containing String data?
 There was a long thread about this back in 2014:
	http://lua-users.org/lists/lua-l/2014-08/msg00657.html
 -spc

AltStyle によって変換されたページ (->オリジナル) /