lua-users home
lua-l archive

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


Wim Couwenberg:
> Well circular module dependencies _may_ cause trouble and can therefore
> not easily be supported in general.
...
> Btw, generically speaking,  it will be possible to factor out the "common"
> stuff in cyclic dependencies, thereby breaking the cycles.  I think this
> should be the preferred method, though it may take some (tricky) redesign.

Hmm, I hadn't thought about circular require() but you have a point.

To help detect such errors perhaps _LOADED should have three states for a
library:
- unloaded
- partially loaded (set when require() starts).
- loaded (set when require() ends).

An attempt to require() a partially-loaded library will report an error
about circular library references (and will abort the load, even if the
error function choses to 'continue' processing).

That way we get circular-reference errors if we stuff up, and if someone
actually wants a certain circular reference then they can explicitly
override the error function around the require() call.

*cheers*
Peter Hill.