lua-users home
lua-l archive

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


> Mark Hamburg wrote:
>> The purpose of supporting modules that can only be imported by specific other modules is to allow subsystems to be built in a modular fashion while only exposing a subset of the interfaces to the rest of the world. In particular, when building subsystems out of a mixture of native code and Lua, it's very useful to only expose the Lua code while having the native code exposed just to the other pieces of the subsystem. For example, this allows one to handle all of the interface niceties and safety precautions in Lua and go with the simplest possible interface on the native code side.
>> 
>> 

On Aug 7, 2010, at 2:20 PM, Everett L Williams II wrote:

> Mark,
> 
> I understand and agree with your point, but I would like to see a less structurally dependent way of accomplishing it. A file system in a limited environment may be essentially flat, not allowing multiple folders/directories.
> 
> Everett L.(Rett) Williams II

One could certainly also use naming patterns. For example: require "_Public_Private" is only allowed within the module Public.

And I don't know that I would build this into the language. It's just that if there were efforts to add features to the package system, this is probably something that would be much further up my list than some of the other suggestions on this thread.

The base implementation could simply provide a standard hook point for constructing the environment for a module when it is being loaded though implementations can also just write their own implementation of require. The benefit of having something in the standard is that it would ease code exchange.

Mark