-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
closes #183: evaluation(sourceText, options)
to support evaluating modules and scripts
#224
Conversation
<emu-clause id="sec-performRealmEvaluation" aoid="PerformRealmEvaluation"> | ||
<h1>PerformRealmEvaluation ( _x_, _evalRealm_ )</h1> | ||
|
||
<emu-clause id="sec-perform-realm-script-evaluation" aoid="PerformRealmScriptEvaluation"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just renaming things to match the new abstract operation for modules
1. Else if _sourceType_ is *"script"*, then | ||
1. Return ? PerformRealmScriptEvaluation(_sourceText_, _realm_). | ||
1. Else | ||
1. Throw a RangeError exception. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems better to keep it explicit, but at that point why have it in the options bag instead of as a required second argument?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good question! two main reasons that we have discussed:
evaluate()
is also a thing in evaluator/compartment, just with more stuff on it, like endowments.- maybe in the future we will have more options here, like strict or sloppy, etc.
But I'm fine either way. We can overload the arguments if we need more options in the future. @erights any opinion here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd generally expect options bags to only hold optional arguments; in the case of "evaluate", the parse goal it's evaluating in seems pretty first-class to me. In other words, I'd expect an optional options bag (now or in the future) to be the third argument.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
feedback from the SES meeting yesterday about this question:
- majority of the group will like to have a default value. I still think being explicit about this is a safer (it is more restrictive, and can be relaxed in the future).
- default value to
strict-script
, which is kinda a new concept, their argument was to not favor sloppy mode, which is still possible, but only viaeval
fromglobalThis
. No capability lost there, just less convenience. - if there is a default value, then it is better to have the options bag. which I believe all agree, but first lets get to some consensus about that first question.
- there was some discussion about tc53 use cases, and whether or not some folks will simply be able to throw when
type=module
is provided, we need more info about this use-case, and how that impact the API.
@erights did I miss anything?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@erights did I miss anything?
That's what I remember, yes. For reference, the mtg is at https://www.youtube.com/watch?v=hqKGKDw-FCY&list=PLzDw4TTug5O1jzKodRDp3qec8zl88oxGd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did the SES meeting consider
- Using separate method names, as these really have different types, and for the Promise vs not issue @zenparsing identified?
- Having an expression form, as @erights initially proposed at the start of the thread?
<h1>PerformRealmEvaluation ( _x_, _evalRealm_ )</h1> | ||
|
||
<emu-clause id="sec-perform-realm-script-evaluation" aoid="PerformRealmScriptEvaluation"> | ||
<h1>PerformRealmScriptEvaluation ( _sourceText_, _realm_ )</h1> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this operation must match https://tc39.es/ecma262/#sec-scriptevaluationjob
1. If _s_ is a List of errors, then | ||
1. Perform HostReportErrors(_s_). | ||
1. Return NormalCompletion(*undefined*). | ||
1. Return ? ScriptEvaluation(_s_). | ||
</emu-alg> | ||
</emu-clause> | ||
|
||
<emu-clause id="sec-perform-realm-module-evaluation" aoid="PerformRealmModuleEvaluation"> | ||
<h1>PerformRealmModuleEvaluation ( _sourceText_, _realm_ )</h1> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this operation must match https://tc39.es/ecma262/#sec-toplevelmoduleevaluationjob
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this should be taken as a requirement. That abstract operation is going away in https://github.com/tc39/ecma262/pull/1597/files#diff-3540caefa502006d8a33cb1385720803L24193 , which TC39 has reached consensus on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
once that's merged, we can adjust here I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wording seems fine to me, FWIW.
What's the motivation for this PR? |
Note, I think we'll need some host integration here. Right now, hosts can assume that all module evaluation starts with them (since currently, hosts have to provide modules to ES), so they have some time to set modules up and add appropriate metadata, e.g., so that dynamic |
f6e61b7
to
722a3dd
Compare
Part of addressing tc39#225 In HTML, this host hook would probably do something related to [setting up a window environment settings object](https://html.spec.whatwg.org/#set-up-a-window-environment-settings-object). I wouldn't propose that this would add properties to the global object in HTML. This PR makes a new host hook section, as another hook may be needed for new modules (in the context of tc39#224)
* Layering: Host hook to initialize new Realms Part of addressing #225 In HTML, this host hook would probably do something related to [setting up a window environment settings object](https://html.spec.whatwg.org/#set-up-a-window-environment-settings-object). I wouldn't propose that this would add properties to the global object in HTML. This PR makes a new host hook section, as another hook may be needed for new modules (in the context of #224) * Note the purpose of the hook
Rationale: To get to a minimal Realms MVP, the functionality can be accessed by `realm.globalThis.eval` (stash off to the side soon after creating realm to use reliably). Omitting this method for now would maximize the flexibility of the continued development of the Compartment/Evaluator API; that proposal could add an analogous method to Realm.prototype as part of the same proposal. Closes tc39#226 Alternative to tc39#224
closing in favor of #235 |
Rationale: To get to a minimal Realms MVP, the functionality can be accessed by `realm.globalThis.eval` (stash off to the side soon after creating realm to use reliably). Omitting this method for now would maximize the flexibility of the continued development of the Compartment/Evaluator API; that proposal could add an analogous method to Realm.prototype as part of the same proposal. Closes #226 Alternative to #224
No description provided.