[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: TIOBE: Lua in the Top 20
- From: Tony Finch <dot@...>
- Date: Fri, 13 Jul 2007 19:38:50 +0100
On Thu, 12 Jul 2007, David Kastrup wrote:
> Tony Finch <email@example.com> writes:
> > On Thu, 12 Jul 2007, David Kastrup wrote:
> >> I'd still very much prefer a Lua variant which defaults to uninterned
> >> strings _until_ one uses them for indexing.
> > What would be the advantage of that?
Thanks for your interesting answer.
> It would open the possibility for later implementing compacting
> garbage collection of the string pool. It would also prevent cache
> poisoning (a principal feature of large hashes and string copying).
As I understand it, Lua guarantees that strings won't move while there's a
reference to them on the stack; if this restriction was removed or
weakened then there's no reason that it couldn't use a compacting
You can only avoid cache poisoning if the string is not copied when it is
handed to Lua, which implies that you'd need a memory ownership and
allocation/freeing convention. So I guess it would be useful for Lua to be
able to pass blobs around without copying, but any time you want to do
anything string-like with them (indexing a table, comparison, appending)
you need to scan the string and so you might as well intern it. But
userdata is effectively a blob so you should be able to do what already.
f.a.n.finch <firstname.lastname@example.org> http://dotat.at/
SOUTHEAST ICELAND: NORTHEASTERLY 5 OR 6, OCCASIONALLY 7. SLIGHT OR MODERATE.
RAIN. MODERATE OR GOOD, OCCASIONALLY POOR.