[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: require and loops
- From: Roberto Ierusalimschy <roberto@...>
- Date: Mon, 20 Oct 2003 14:49:52 -0200
> 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:
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.