lua-users home
lua-l archive

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


Yeah, Alexander's example is a good explanation of how the current definition can be used properly, much as how rand() is guaranteed to give the same successive results every time you seed it with the same value.

On Wed, 19 May 2010 07:25:15 -0700, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:

     Using # on tables with holes is what every other language manual
would describe as undefined behaviour.

Unfortunately, I think many other language manuals are not good examples
to follow.

In C ---which is a good example--- "undefined behaviour" really means
undefined behavior (e.g., "ignoring the situation completely with
unpredictable results"). Maybe you mean "unspecified behavior"?

But I think this is more related to expectations. As Cuero pointed out,
nobody considers that "random" has an unspecified behavior, even though
it can return anything. As another example, if you get the documentation
for Posix threads, there are very few garanties about anything. (Last
time I read even a single-threaded implementation could satisfy the
specifications.)

I think the main point is whether the result is useful or not. Most
people (not without reason) consider the result of #t on a table with
holes as useless (but Alexander found it useful ;).

-- Roberto