[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: How can a module intentionally fail to load?
- From: Frank Kastenholz <fkastenholz@...>
- Date: Thu, 9 Aug 2018 07:23:46 -0400
> On Aug 8, 2018, at 1:00 PM, Gé Weijers <ge@weijers.org> wrote:
>
> I don't see a whole lot of use for this, if a module fails to load retrying is not going to help much in almost all use cases, except where you're loading components on demand. In that case I would suggest writing a wrapper around 'require' to get the behavior needed.
In a previous life I wrote a system where the lua app could require a particular module and, if the require failed, request that the module be loaded from a depot and then re-require it.
The download-and-install functionality was in a separate module - we did not modify the require code in the PUC-Rio lua source due to project requirements.
It could have been a wrapper encapsulating the “require/install/re-require” logic ... but that only would have made life a bit easier for our application developers —- we would have still needed to re-require
> Another downside of returning 'false' is that you have to test the return value of each 'require',
Isn’t it good programming practice to always check return values?
Frank