[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Virgin tables
- From: steve donovan <steve.j.donovan@...>
- Date: Thu, 30 Dec 2010 10:28:38 +0200
On Thu, Dec 30, 2010 at 8:26 AM, Mark Hamburg <mark@grubmah.com> wrote:
> A simpler answer is to provide an array namespace....arrays have an explicit length (stored somewhere) and appropriate metamethods to maintain it.
It's a question of using the appropriate data structure for the job.
[1] is a reasonably robust array with bounds-checking, where setting
nil is prohibited so that no holes can happen. It uses newproxy() to
make the object so that the table functions cannot be used on it.
With a little work this can also be made a type-safe array, so one can
approach the Platonic Ideal of a Pascal array.
OK, so it obviously is going to be less efficient. But the old Irish
programming principle applies: Slow but sure, and fail noisily!
steve d.
[1] https://gist.github.com/759589 [2]
[2] Yes, I should use http://snippets.luacode.org/, but it barfed at
this code. [3]
[3] I have complained to the maintainer, who happens to be myself.