Closed caridy closed 4 years ago
importMetaHook
is not specified? Implement the basic wiring for now.this
value be proxified? Yesadbf4b088b89c8aea1ed8f37e3d4dac604a7ec06 implements the intrinsics
option and the "inherit"
value for all hooks.
Experience with the realms shim shows that piecemeal control of inherit-vs-make on individual issues is not a coherent start point. Rather, we need an explicit distinction between "root realms" vs "compartments" as some realm concepts must be per-root-realm and some must be per-compartment.
A terrible way to customize as cross realm leakage is too accident prone. A better starting mechanism is to run shim strings within each root realm on initialization, as the shim now does. This does leave the residual problem of endowments coming on from the defenseless feral world, which still needs good support for taming. See @ihab 's taming membrane at https://github.com/google/caja/tree/master/src/com/google/caja/apitaming .
By the current design, realms does not deal directly with the issues of evaluating module code, but rather provides only a bridge to a separate module api. import.meta
can only appear in module code. Thus, the importMetaHook
should move from realms into this hypothetical but coupled module evaluation api.
Should be renamed directEvalHook
or something, so that it clearly applies only to direct eval. The current name caused much confusion. Also, the make should reflect that the hook is called to translate rather than to evaluate.
Just noting that none of these hooks can reasonably be implemented by the shim without an accurate parser, which would make the shim tremendously larger and more fragile. Rather, they should all be considered implementation limits of the shim as compared to the proposal. Nevertheless, without these, the shim is sufficient for most of the use cases that motivated the creations of the realms proposal.
Missed:
Since this applies only to the import expression as evaluated in non-module code, it should have a name that is less confusing.
Most of the information here is about hooks, which are now features of the evaluator.
Attendies: @dherman @erights @wycats @caridy
Notes
"use strict"
might be sufficient, and desirable because of the implications of evaluating sloppy code in strict mode, and the possible frustration of users when code misbehaves when forced to run in strict mode.The formalization of the realm concept (tiling process from @dherman):
Realm's Configuration:
global object configRealm's Responsibilities:
Realm's Features:
Examples
Some of the configuration
In the previous example, the Realm instance
r
is effectible a new scope since it will inherit all the hooks and all the intrinsics from the parent realm, but creates a new global object and a newthis
value, and allow evaluations bound to those values without introducing identity discontinuity, and delegating to the HOST behavior forimport()
calls.Similarity, each of those configurations can be customized:
intrinsics
is not specified, it will create a new set of intrinsicsimportHook
is not specified, it will throw on any import call. And if specified as a function, it will be used as the import hook as spec'd today.evalHook
is not specified, it will throw on any direct eval invocation. And if specified as a function, it will be used as the eval hook as spec'd today.isDirectEval
is not specified, it will run the default algo.Open questions
importMetaHook
is not specified?this
value be proxified?