lua-users home
lua-l archive

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

On Fri, Jun 28, 2013 at 6:09 PM, Tim Hill <> wrote:
> My current work-around is pretty much as you describe; it's a light userdata
> holding a C (void*)0 pointer. It has all the attributes I need, and it works
> just fine. But without someone saying "if you need to create an "holding
> place" within an array, use "xxx", everyone will come up with different ways
> to do this, and we have chaos.

on one side, i think Roberto's position is the only one sensible from
a language-theoretical point of view for a language that strives for

on the other side, a theoretically pure language could be too
cumbersome to use, so one have to balance with practical approaches.
(of course going too far in that direction you find Python, which is
so practical, but so 'dirty'... but that's OT)

so, I'm curious about the real, specific objections to current
practices.  One point that you mention is the diversity of options,
which reflects the lack of a single "right" solution.  But as I see
it, there are different choices because there are different
situations.  From the top of my head, i recognize these:

A: if there are fixed length arrays, i just use nil.

B: if I create a list, set or table of values and need a placeholder,
just use false, unless it's a list of booleans, of course.

C: if i store values that come from other libraries (or modules
developed independently), i want to use a value that no other library
could use, so i use a unique empty table as the 'nothing' value.  in
that case, it must be a private value, handled only by the container
code.  even if i have different container modules (say, a heap and an
ordered dict), each one has it's own 'nothing'.  in most cases, i
avoid returning the 'nothing' value.  presence/absence is signaled
'offline' or replaced with nils if appropriate.

in my opinion, these are not workarounds for the lack of a 'nothing'
value.  these are different uses, so they need different solutions.
having a single extra value would be the same in A, a little more
'semantic' in the B case and less adequate on the C case.

as you can see, i don't agree with the idea that "this is just policy,
create a global 'nothing' and use everywhere",  but my own Lua
experience is mostly from lots and lots (and lots) of small and medium
scripts, very few large and complex systems, so i'm honestly curious
how having an extra language-defined 'empty' value could help in your

Are you thinking of a different case besides those three? or do you
disagree they're so different?