Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upExpose initial JSON.parse as %JSONParse% #1012
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
annevk
Sep 28, 2017
Contributor
I missed that %JSON% already exists. Could I write something like
Return ? Invoke(%JSON%, "parse", « jsonSource »).
then?
|
I missed that %JSON% already exists. Could I write something like
then? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
michaelficarra
Sep 28, 2017
Member
I'd prefer we just name the intrinsic so you can call it directly.
|
I'd prefer we just name the intrinsic so you can call it directly. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
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.
|
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. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
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?
|
Thanks, I'll work on a PR. How would I end up using it in prose afterwards? Just
or something more involved? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
That seems right to me! |
added a commit
to annevk/ecma262
that referenced
this issue
Sep 28, 2017
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
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.
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
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
closed this
in
#1013
Sep 28, 2017
added a commit
that referenced
this issue
Sep 28, 2017
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
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.)
|
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.) |
annevk commentedSep 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?