lua-users home
lua-l archive

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

On Fri, Jun 11, 2021 at 1:38 PM Andrew Starks <> wrote:
> I'm confused by your confusion. The manual is totally clear and says everything you said in fewer words.
> Undefined behavior means, in this case, adding a new key/value pair while traversing a table with `next` doesn't produce an error, but is incorrect because it may produce unpredictable results that are not defined by the language. There is nothing overly magical about it and the reason for this is self-evident — tables are not guaranteed to be stable and `next` cannot know the context in which it is called.

Well, this whole discussion exists because in some other contexts
"undefined behavior" means that when you do this the program is
permitted to email your boss some insults instead of returning a key
from the table or nil.