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

Naming bikeshed: "immutable" #2

Open
ljharb opened this issue Aug 5, 2022 · 7 comments
Open

Naming bikeshed: "immutable" #2

ljharb opened this issue Aug 5, 2022 · 7 comments

Comments

@ljharb
Copy link
Member

ljharb commented Aug 5, 2022

I think the word "immutable" is sufficiently overloaded that it'd cause confusion to use it.

All primitives are immutable, but so are frozen objects without internal slots that have no "non-immutable object" properties.

I'd love to gather suggestions of alternate names that can convey "produces Records and Tuples instead of Objects and Arrays" in a way that doesn't have nuances and edge cases. (I'll make my own suggestions in independent comments, as I come up with them, so they can be emoji-reacted to individually)

@hax
Copy link
Member

hax commented Aug 28, 2022

I raised the similar issue in original proposal: tc39/proposal-record-tuple#327

Here are the names I suggested: parsePrimitive or parseAsPrimitive

@ljharb
Copy link
Member Author

ljharb commented Aug 29, 2022

“Primitive” includes things that JSON doesn’t - symbols and undefined, in particular.

@hax
Copy link
Member

hax commented Aug 29, 2022

@ljharb Yeah, and JSON also don't include bigints and special float values (NaN, ±Infinity). But I think it's still correct to say it only generate primitives?

@OmarCastro
Copy link

OmarCastro commented Feb 16, 2023

Well, there is another option, JSON.parseConst. Since the value cannot be changed, it is effectively constant.

@ljharb
Copy link
Member Author

ljharb commented Feb 16, 2023

const in JS only has the connotation of "constant reference", which isn't the same as "immutable".

@chimericdream
Copy link

What about something like JSON.parseStatic or JSON.parseFinal?

@ljharb
Copy link
Member Author

ljharb commented Apr 24, 2024

what's dynamic or non-final about the existing parsing?

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