Merged
Conversation
One of the principles of PlatformScript is for there to be very little magic, and what magic there is should be confined to limited cases. This runs afoul of the "magical" values that are needed to make things actually work. These are the "magical" values like React constructors on the browser, or file system access on Unix systems. It is anticipated that PS will run in many different contexts and so we have to be able to swap out what is magically available without that process seeming magical. To do this, we make all magical values appear within a normal module. Instead of them just appearing in your scope, they are accessed by a special module called `--canon--`. The "canon" can be passed into the module loader and any module that requests the`--canon--` shall receive it. Eventually, we can use this canonical value to typecheck code that accesses the canon. The word canon was chosen because it refers to an established body of work that can be drawn upon to perform contemporty tasks. Like the canon of law, or the canon of prayer. Also because "env" was taken already and we want to reserve "context" for a runtime api.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
One of the principles of PlatformScript is for there to be very little magic, and what magic there is should be confined to limited cases. This runs afoul of the "magical" values that are needed to make things actually work. These are the "magical" values like React constructors on the browser, or file system access on Unix systems.
It is anticipated that PS will run in many different contexts and so we have to be able to swap out what is magically available without that process seeming magical.
Approach
To do this, we make all magical values appear within a normal module. Instead of them just appearing in your scope, they are accessed by a special module called
--canon--.The "canon" can be passed into the module loader and any module that requests the
--canon--shall receive it. Eventually, we can use this canonical value to typecheck code that accesses the canon.The word canon was chosen because it refers to an established body of work that can be drawn upon to perform contemporty tasks. Like the canon of law, or the canon of prayer. Also because "env" was taken already and we want to reserve "context" for a runtime api.
Alternate Designs
--env--, or--context--butenvis already in heavy use internally, andcontextwe want to reserve for another API.Other possibilities