lua-users home
lua-l archive

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


On Fri, Jun 28, 2013 at 7:01 AM, Enrico Colombini <erix@erix.it> wrote:
> On 28/06/2013 13.03, Tim Hill wrote:
>>
>> There are plenty of cases where being able to "mark" an array entry
>> as done/dead/empty etc is useful as part of an algorithm. In many
>> cases you can do that using a sentinel value that is outside the
>> normal range of expected array types and/or values, but it's all very
>> domain specific (can I use an empty string? -1? false? auxiliary
>> state?). I'm basically arguing that "empty" allows you to do this in
>> a nice, clean, self-documenting, portable manner. I don't really see
>> anything heretical in that.
>
>
> empty = {}
>
> --
>   Enrico
>

I think that Tim's point is not that there is not a workable solution.
It is that there are many workable solutions and since there is no
clear one way to solve the problem, it is likely to cause a mess
when/if there are libraries solving it in different ways.

Do I have that premise correctly stated?

Personally, I have never run into this issue, but I don't claim to be
that experienced, either. Furthermore, if it is an issue, it must be
miles down the list from "Hey, why isn't there a standard way to do
OOP?"

Some guy said it best, "Lua is not Perl." It's also probably why there
are relatively few (by JS or Ruby or Python standards) standard
libraries. I like to think of Lua as scripting starter kit for my
applications. The language and libraries are whatever I want them to
be. So,as suggested, you're kind of a light userdata value away from
exactly what you want, IF you scope your question to, "My version of
Lua should elegantly and efficiently solve this use case..."

If you long for a wider scope, then you're unlikely to be satisfied.
As demonstrated by the previous posts, there usually isn't a whole lot
of support behind adding new "things" to the language, especially when
they're "policy" things.

That is, there are many mechanisms in the language to accomplish
exactly what you want. You want a policy, which is not really what Lua
has traditionally been about.

-Andrew