lua-users home
lua-l archive

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

> What I didn't ever see was a good reason given for making cyclic
> requires generate an error. What sort of errors is this supposed to
> protect against?

The "main" of a module may use functions from another required module.
Therefore, we should only run a module after running all its required
modules. Otherwise, the user may get some subtle errors, where it
clearly sees a `require "xuxu"' in a module but "xuxu" is not loaded yet:

  require "xuxu"
  error: attempt to index global `xuxu' (a nil value)

Some people argue that modules should not have cyclic dependencies.
I do not have a strong opinion about that.

-- Roberto