Skip to content
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

ToObject should specify what realm it uses #1104

Open
domenic opened this issue Feb 16, 2018 · 6 comments
Open

ToObject should specify what realm it uses #1104

domenic opened this issue Feb 16, 2018 · 6 comments

Comments

@domenic
Copy link
Member

domenic commented Feb 16, 2018

https://tc39.github.io/ecma262/#sec-toobject

Return a new Boolean object

Which Boolean constructor or %BooleanPrototype% should this use? The spec definitely means the current Realm, but it'd be nice to be explicit.

@ljharb
Copy link
Member

ljharb commented Apr 26, 2019

@domenic would you consider it sufficiently explicit if the table said return a new %Boolean% object? if not, do you have a suggestion for text? I'm happy to make the PR to update all the similar cases in that section.

@domenic
Copy link
Member Author

domenic commented Apr 26, 2019

Hmm. I think probably we should close this. I'm not sure why I filed this issue to pick on this one particular instance of "a new X object" in the spec as not being specific enough. But in general this is a widespread "problem" in the spec, which is probably not worth fixing piecemeal, and likely not worth fixing at all.

If there is a solution, it'd be more general; something like defining "new X object" (similar to https://heycam.github.io/webidl/#internally-create-a-new-object-implementing-the-interface), and stating that by default the realm used is always the current realm. But that's a big project with dubious payoff, so I'd be fine closing this over-specific issue.

@allenwb
Copy link
Member

allenwb commented Apr 26, 2019

All operations that don't explicitly reference a specific realm operate using the current realm. That's kind of implicit in the concept of a "current realm" but if you wanted to explicitly state it somewhere perhaps the into to Clause 7 would be a place to put it.

Note sure that mentioning %Boolean% etc. in ToObject would be appropriate as the intent isn't to actually call the constructor function. If you want to be more explicit then what is already in ToObject (a I'm not really sure that is necessary you should probably define Boolean, Number, and Symbol analogs to StringCreate ( value, prototype ) and use them in ToObject.

@ljharb
Copy link
Member

ljharb commented Apr 26, 2019

It sounds like there’s a few possible ways forward here:

  1. Close the issue, status quo
  2. Add text to Clause 7 that explicitly mentions that the current realm is implied
  3. Replace (presumably all) instances of “a new X object” with a call into an abstract operation that explicitly references the current realm.
  4. Explicitly define the phrase “a new X object” a la https://heycam.github.io/webidl/#internally-create-a-new-object-implementing-the-interface

2 can happen whether 3/4 does or not, of course.

I don’t feel too strongly about the direction; but i do think it’s worth doing something especially if the implicitness here is a pervasive occurrence.

cc @zenparsing

@allenwb
Copy link
Member

allenwb commented Apr 26, 2019

Note that the realm is only only used for choosing the value of the prototype object so passing a prototype as an argument to CreateXXX functions is sufficient.

But, I ssuggest just doing #2 so you have something to point at if this question is asked again.

@jmdyck
Copy link
Collaborator

jmdyck commented Apr 26, 2019

Explicitly define the phrase “a new X object” ...

Note that #1453 and #1460 have a lot to do with the phrase "a newly created [X] object", so we'd probably want efforts to co-ordinated.

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

No branches or pull requests

4 participants