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

Expose initial JSON.parse as %JSONParse% #1012

Closed
annevk opened this Issue Sep 28, 2017 · 7 comments

Comments

Projects
None yet
4 participants
@annevk
Contributor

annevk commented Sep 28, 2017

That way Fetch and XMLHttpRequest can use it more directly (and other web platform entry points that need JSON parsing). Alternative is an abstract operation, which might be a little clearer usage wise.

Any preference?

@annevk

This comment has been minimized.

Show comment
Hide comment
@annevk

annevk Sep 28, 2017

Contributor

I missed that %JSON% already exists. Could I write something like

Return ? Invoke(%JSON%, "parse", « jsonSource »).

then?

Contributor

annevk commented Sep 28, 2017

I missed that %JSON% already exists. Could I write something like

Return ? Invoke(%JSON%, "parse", « jsonSource »).

then?

@michaelficarra

This comment has been minimized.

Show comment
Hide comment
@michaelficarra

michaelficarra Sep 28, 2017

Member

I'd prefer we just name the intrinsic so you can call it directly.

Member

michaelficarra commented Sep 28, 2017

I'd prefer we just name the intrinsic so you can call it directly.

@ljharb

This comment has been minimized.

Show comment
Hide comment
@ljharb

ljharb Sep 28, 2017

Member

With the Invoke, you'd be calling whatever I happened to install on the JSON object under "parse"; it definitely would need a direct name.

Member

ljharb commented Sep 28, 2017

With the Invoke, you'd be calling whatever I happened to install on the JSON object under "parse"; it definitely would need a direct name.

@annevk

This comment has been minimized.

Show comment
Hide comment
@annevk

annevk Sep 28, 2017

Contributor

Thanks, I'll work on a PR. How would I end up using it in prose afterwards? Just

Return ? %JSONParse%( jsonSource )

or something more involved?

Contributor

annevk commented Sep 28, 2017

Thanks, I'll work on a PR. How would I end up using it in prose afterwards? Just

Return ? %JSONParse%( jsonSource )

or something more involved?

@ljharb

This comment has been minimized.

Show comment
Hide comment
@ljharb

ljharb Sep 28, 2017

Member

That seems right to me!

Member

ljharb commented Sep 28, 2017

That seems right to me!

annevk added a commit to annevk/ecma262 that referenced this issue Sep 28, 2017

@domenic

This comment has been minimized.

Show comment
Hide comment
@domenic

domenic Sep 28, 2017

Member

Return ? %JSONParse%( jsonSource )

No, that's not correct. That's only correct if it's an abstract operation ("JSONParse", no %s), which indeed is neater.

If we expose it as a named intrinsic, we'd need

Return ? Call(%JSONParse%, undefined, « jsonSource »).

I think an abstract operation would be nicer if we can get away with it.

If we do that we can also make it encompass only steps 2-6 of the JSON.parse function.

Member

domenic commented Sep 28, 2017

Return ? %JSONParse%( jsonSource )

No, that's not correct. That's only correct if it's an abstract operation ("JSONParse", no %s), which indeed is neater.

If we expose it as a named intrinsic, we'd need

Return ? Call(%JSONParse%, undefined, « jsonSource »).

I think an abstract operation would be nicer if we can get away with it.

If we do that we can also make it encompass only steps 2-6 of the JSON.parse function.

bterlson added a commit that referenced this issue Sep 28, 2017

Editorial: Add %JSONParse% for Fetch et al (#1013)
* Add %JSONParse% for Fetch et al

Fixes #1012.

* add <dfn>
@annevk

This comment has been minimized.

Show comment
Hide comment
@annevk

annevk Sep 28, 2017

Contributor

Okay, I think we can just add an abstraction in Infra to make the difficulty go away for everyone else in the web platform. (And maybe also require UTF-8 there at the same time when the input is bytes.)

Contributor

annevk commented Sep 28, 2017

Okay, I think we can just add an abstraction in Infra to make the difficulty go away for everyone else in the web platform. (And maybe also require UTF-8 there at the same time when the input is bytes.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment