You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* add new motivating usecases
* remove what seems like a leftover or a deviation from interface described earlier from the example
* add reference to importHook
In this example, only the entrypoint module for the DSL sees additional
143
142
globals.
144
-
The `source` adopts the import hook associatd with `dslGlobal` by
143
+
The `source` adopts the import hook associated with `dslGlobal` by
145
144
virtue of using the `dslGlobal`'s dynamic `import`.
146
145
Current DSLs cannot execute concurrently or depend on dynamic scope to track
147
146
the entrypoint that called each DSL verb.
@@ -172,6 +171,29 @@ TC53][tc53], do not have an origin on which to build a same-origin-policy, and
172
171
have elected to build their security model on isolated evaluators, through the
173
172
high-level Compartment interface.
174
173
174
+
### Isolating unreliable code
175
+
176
+
The way modern software is composed has already undermined the validity of the assumption that every author participating has their intentions well aligned for the benefit of the software working correctly. A whole new level of unreliability is now added with the popularity of _coding agents_ and _vibe coding_ where creating syntactically valid but effectively unpredictable JavaScript and integrating it into existing software to check whether it seems to implement the desired functionality is becoming a popular way of building software.
177
+
178
+
It is not an entirely new concern, as test runners have been concerned with isolating test cases to avoid them relying on global side-effects of other test cases. It is now a concern for a much wider audience with more at stake.
179
+
180
+
With `Global` constructor comes the ability to isolate fragments of the application in a way that unreliable code cannot rely on shared global state without the maintainer of the software knowing about it.
181
+
AI generated sources from independently working agents can come with colliding names for global variables to use and may need separate global scopes to collaborate or coexist. Similarly a misguided attempt at an inline polyfill by an AI or a package author could be prevented by freezing the contents of a new global in which the unreliable code subsequently runs.
182
+
Using a new global instead of a new Realm avoids the issues like identity discontinuity impeding the composition of software where function calls need to happen across the isolated and non-isolated code.
183
+
184
+
The isolation use case depends also on the interaction with `importHook` and `ModuleSource` as described in
There are tools that currently use much more complex and costly mechanisms (similar to the ones described in [Domain Specific Languages](#domain-specific-languages) among other) to provide the ability to execute fragments of JavaScript code in a very specific context of the tool.
192
+
193
+
That includes REPLs, inline code execution results in editors (eg. [Quokka.js](https://quokkajs.com/)) and various use cases of IDEs in the browser.
194
+
195
+
Maintaining the global state between executions of user-provided code snippets would benefit from a `Global` constructor.
196
+
175
197
## Intersection Semantics
176
198
177
199
### Shared Structs
@@ -184,7 +206,7 @@ share any undeniable mutable state.
184
206
185
207
## Design Questions
186
208
187
-
### prototype chain in the browser
209
+
### Prototype chain in the browser
188
210
189
211
`globalThis` in the browser has a non-trivial prototype chain for some Window
190
212
API functionality and events.
@@ -196,13 +218,13 @@ API functionality and events.
196
218
to invoke it.
197
219
198
220
```js
199
-
globalThis.constructor===Window
200
-
constg1=newGlobal()
221
+
globalThis.constructor===Window;
222
+
constg1=newGlobal();
201
223
202
-
g1.globalThis.constructor=== Global // would need to be true I suppose
203
-
g1.globalThis.constructor===g1.globalThis.Global// definitely not
0 commit comments