lua-users home
lua-l archive

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


On Tue, Dec 14, 2010 at 12:40 AM, Mark Hamburg <mark@grubmah.com> wrote:
> 1. Define a new value type HOLE or NIL or NULL or whatever. It doesn't really
> matter what one calls it because it's purely an implementation detail as we'll see
> below. Values of this type will only appear in the value fields of tables.

Perhaps call it LUA_TNONE ("none"), which, like the vararg `...`
stuff, already exists in Lua, not as a first class value but rather as
a special concept.

Consider: What value of x makes `f(x)` equivalent to `f()`?  On a
runtime level, there is no such value, but on a lexical level, there
is a token `...` that you can substitute for x, making the two
equivalent.

Likewise, there may be no value of x such that `t[1] = x` makes t[1]
none, but we might allow some token to be used in place of x that
gives it that behavior, implemented via some special opcode.  A few
possible choices for that token may be ``, `()` and `...`:

  t[#t] = ;
  t[#t] = ()
  function f(...) t[#t] = ... end; f()

The third choice suggests a possible generalization, passing an
arbitrary list of values into f, but you'd probably prefer it in the
form of slices instead: `t[3:6] = ...` (i.e. replace elements 3
through 6 with the elements in the vararg list).