[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Documenting Lua gotchas for newbies.
- From: Michal Kottman <k0mpjut0r@...>
- Date: Thu, 02 Dec 2010 00:32:46 +0100
On Wed, 2010-12-01 at 21:53 +0100, Lorenzo Donati wrote:
> Pierre-Yves Gérardy wrote:
> > Following the floating point discussion, I tried to look for a
> > compilation of the various gotchas Lua beginners encounter, but I
> > couldn't find one, so I decided to compile one...
> >
>
> Very commendable initiative! :-)
>
> If these could be considered gotchas:
>
> 1. I discovered "late in the game" that the most efficient way to append
> an item to an array was
> a[#a+1]=item
> and not
> table.insert(a,item)
>
>
> 2. (this is more on the "someone tell me the rationale" side)
> I was really puzzled that no library copy operation existed (ie.
> table.copy).
> After all the only data structure in Lua are tables, and making shallow
> or deep copies of them is not something one should consider an
> infrequent operation. Only after a while I began to understand the
> minimalistic "philosophy" of Lua.
>
Maybe http://snippets.luacode.org/ (work in progress) could serve as a
good starting point for beginners...