Replies: 4 comments 12 replies
-
|
Beta Was this translation helpful? Give feedback.
-
|
I agree. I have the feeling that modules in Rebol are trying to solve two problems at once that I think should be needed to treat separately - namespace handling and packaging. So removing version from modules (for now) seems like a good idea. IMO modules should be all about namespace separation and inclusion and packages from modules is a problem that needs to be solved separately. Packaging open whole new can full of different forms. Code signing, trust issues, how to prevent left-pad issue, how to prevent dependency hell, etc, etc. We won't solve it perfectly, because if it could be solved perfectly, it would be solved already, but at least we can learn from past mistakes. So that's why I believe it's a problem that should be solved separately. |
Beta Was this translation helpful? Give feedback.
-
|
If it helps, I have collected some old DocBase documents.. here is the one related to modules. |
Beta Was this translation helpful? Give feedback.
-
|
It would be nice to have some standard way for modules removal... for example now, when I want to test new console code update, I must first remove existing modules manually like here. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Two points of reference for this thread: Rebol 3 Modules, and How words are bound within a module.
Also one other point of note, there is a conceptual difference between the MODULE! datatype and the Module System designed to organize code. The MODULE! datatype is just a variation on OBJECT! with some subtle differences. Whereas the Module System determines how modules intended for reuse are created from source. A lot of the complexity around modules and code reuse stem from the the Module System and it is that I am addressing here, not the MODULE! type.
Note: I will likely revise this text as and when I have time to further elaborate on the details.
The Module System as-is largely serves two purposes, code isolation and organization. While it may seem intuitive that these go hand in hand, they do have a couple of divergent points. One is the use of unnamed modules to create scripts that run in an isolated namespace
Unnamed Modules as Temporaries:
Unnamed Modules
I believe this to break the intent of the Module System.
Type: moduleshould only relate to code that is intended for reuse, that would be an intuitive understanding of its purpose.Recommendation: scripts that are intended to be run this way should use
Type: private(the MODULE! type is still used in implementation, but the resultant value is discarded upon evaluation)
Example:
This provides a clear pathway to create scripts that are to be run for effect but run in a private namespace.
(disambiguates wish #14, no longer need #1178—exports from such a script don't make sense)
This also removes complexity about how
Type: modulefiles are processed by DO, paving the way for allType: modulescripts are stored insystem/modules. Which brings me to my second recommendation:Recommendation:
system/modulesbecomes a MAP! allowing for modules to be stored by name, file, and/or URLThis is exactly what URLs are designed to do: unambiguously differentiate between resources. Files can similarly be resolved (e.g.
to-real-file) and unambiguously refer to a module within the filesystem so that unnamed modules are not rerun (see recent thread for an example of where current behavior breaks intuitive understanding).(mostly solves #1175, #1176, #1187)
This also allows for:
Recommendation: DO of
%a-module.rebcreates a module if not already run, retrieves a module if it hasThere is no longer any ambiguity about how this works: DO plays nice with the module system. Modules no longer require names in order to be 'saved.' While names can still be used as a reference, they are not suited by themselves for an extensively used Module System. Per the Module definition in the old R3 Dev Wiki, Modules invoked with DO are not imported, but, they don't need to be reloaded if a subsequent IMPORT call is made.
(disambiguates wish #14)
Recommendation: MIXINs become the default word exchange mechanism for modules
Exported words are no longer added to LIB by default (if ever), they are only imported into the local context.
This doesn't fully answer the question of how IMPORT works outside of the NEEDS header (it may need to be localized for each module)(I may have a better answer for this). This means there's no surprises with unexpected imports from some deep part of the dependency chain; there should be some other mechanism for exporting to LIB.Consequences:
mod-a.rebmod-b.rebscript.rebother-script.reb(addresses wish #12)
Recommendation: A separate CORE module type that adds to LIB
I think there's value in having this non-mixin functionality, but having it as a distinct TYPE allows it to be handled differently. That may be purely semantic at this point, but it could potentially be used in substantive tracing/debugging.
a-core-module.rebRecommendation: Some alternative to SYSTEM/SCRIPT for modules
Modules should be able to access their own headers and neighboring file system.
Concept: Modules are evaluated apart from all other code.
a-module.rebRecommendation: Remove version checking from the Module System
Versions can be specified in Files and URLs, and if needed, by helper functions. In other systems, this is mostly handled by convention
(though may require a reconsideration of file vs. email lexical space):Recommendation: DO of a type other than NONE, MODULE, or PRIVATE does not evaluate the script directly
This doesn't directly pertain to the Module System, but makes good on Rebol's capacity to operate in different domains. As an example, DO of a script such as the following could conceptually be evaluated in a different context:
my-svg.rebWhile I don't have a recommendation on how this mechanism would work at this time, this is a feature that is a part of DO and should be part of design discussions at this stage. Part of the motivation for this is in consideration of the old Desktop Rebsite concept;
do %index.rebcould conceivably return a processed version of a Rebsite file.(posted on this topic long ago on the Ren-C forum: Using the Type Header)
Recommendation: rename LIB to RUNTIME
Having an essential concept have such a throwaway name isn't useful. LIB is often referred to as the Runtime Library, and RUNTIME isn't a common word in scripts. I believe this would help clarify the purpose of the Runtime Library in general.
I'd propose a renaming for SYS, but I don't have a good candidate at this time. Possibly INTERNALS:
These recommendations are designed to streamline the Module System and make modules more consistent for script and module authors. Important to note, this isn't the last word in Modules. It's possible to add further module types that may behave differently if the need for them emerges, they just won't be
Type: moduleAs an aside, I dislike the term 'mixin'—Rebol has EXPORTS and should similarly have IMPORTS. 'Mixin' is a niche term.
Beta Was this translation helpful? Give feedback.
All reactions