REBOL3 tracker
  0.9.12 beta
Ticket #0001692 User: anonymous

Project:



rss
TypeWish Statustested Date20-Oct-2010 16:26
Versionalpha 107 CategoryMezzanine Submitted byBrianH
PlatformAll Severitymajor Priorityhigh

Summary Private modules (mixins, formerly unnamed modules)
Description The module system has something like this already, but it is time to formalize a proper model for private modules (also known as mixin modules).

When a module is declared as private with the 'private header option, its exports will not be imported into the system runtime library (lib). Instead, it will export to the calling context - whichever module referenced the module in its Needs header - or to the user context - either script Needs or IMPORT without /no-user (see #1680).

If the module has a name it can also be added to the system modules list. This will allow a premade private module to be found by other scripts or modules that want its exports.

When a private module is imported to a user script or to the user context directly, the user context is expanded with the exported words. This is unnecessary with regular modules because they expand the lib context instead, so subsequent user scripts will have access to the words that way. No expansion is needed to the contexts of modules that import other modules.

For modules the exported words of the private modules in their Needs block are collected into an object, which is then passed to MAKE module! (see #1682). For regular modules, the module code is bound to the object. For isolated modules, the values in the object are resolved into the private context and the object is discarded.

This is mostly similar to the behavior described in #1178, but there are some differences:
- The mixins object is passed into MAKE object! differently.
- Not naming a module doesn't turn it into a mixin module (yet).
- Mixin modules are added to the module list if they have a name.
- This allows mixins to be reused or shared without being rebuilt.
- If a module doesn't have a name it can't be imported, though it can be used without importing.
Example code
; The header option syntax
REBOL [type: module options: [private]] ...

Assigned ton/a Fixed inalpha 108 Last Update20-Oct-2010 17:00


Comments

Date User Field Action Change
20-Oct-2010 17:00 BrianH Priority Modified normal => high
20-Oct-2010 16:27 BrianH Fixedin Modified => alpha 108
20-Oct-2010 16:26 BrianH Summary Modified Private modules (mixins, formerly AKA unnamed modules) => Private modules (mixins, formerly unnamed modules)
20-Oct-2010 16:26 BrianH Description Modified -
20-Oct-2010 16:26 BrianH Code Modified -
20-Oct-2010 16:26 BrianH Status Modified submitted => tested
20-Oct-2010 16:26 BrianH Ticket Added -