Skip to content

✨Introduce the --canon-- module#81

Merged
cowboyd merged 1 commit intomainfrom
env-module
Feb 16, 2023
Merged

✨Introduce the --canon-- module#81
cowboyd merged 1 commit intomainfrom
env-module

Conversation

@cowboyd
Copy link
Copy Markdown
Member

@cowboyd cowboyd commented Feb 15, 2023

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--.

$import:
  split, join: --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

  • We consider naming the module an emoji that conveyed "reaching through a portal" like 🌀, 🕳️, or ☯️
  • also --env--, or --context-- but env is already in heavy use internally, and context we want to reserve for another API.

Other possibilities

$import:
  split, join: --precedent--
$import:
  split, join: --axioms--

@cowboyd cowboyd requested a review from a team February 15, 2023 20:42
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.
Copy link
Copy Markdown
Member

@taras taras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@cowboyd cowboyd merged commit 46b514c into main Feb 16, 2023
@cowboyd cowboyd deleted the env-module branch February 16, 2023 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants