[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [PROPOSAL] a new function: table.proto()
- From: Roberto Ierusalimschy <roberto@...>
- Date: Tue, 4 May 2010 14:16:59 -0300
> I have to admit I hadn't considered that exposing lua_createtable()
> might make performance *worse* rather than better. Is that just
> because overzealous newcomers might assume they have to preallocate
> all the time and overuse the function, or is it a more insiduous thing
> that can happen even if what you're doing seems initially sensible?
Both. For instance, if you swap both arguments when creating an array,
you end up with an array where all elements are stored in the hash
part. If you create the tables larger than needed, Lua will never shrink
them to more reasonable sizes. In any case, there is no visible bug to
warn you.
> Also, I seem to remember that one of the changes being considered for
> 5.2 was to (conceptually) break the debug library into two halves.
> Currently, in 5.1, the whole library is covered by the recommendation
> "you should *never* use any of these functions in real final code,
> *only* for debugging purposes". But in 5.2, the idea would be that
> *some* functions are still covered by that, but some would instead be
> "you *can* use these, in modules and such, but you can hurt yourself
> if you use them wrongly - be careful and make sure you know what you
> are doing". In other words, functions that are intended for more
> advanced/low-level stuff, rather than exclusively for debugging.
Actually the entire debug library will be in the second case. (Such
break would be both difficult to draw and complex to explain.)
-- Roberto