tc39 / proposal-json-parseimmutable

JSON.parseImmutable for creating Records and Tuples from JSON strings
https://tc39.es/proposal-json-parseimmutable/
MIT License
36 stars 1 forks source link

Naming bikeshed: "immutable" #2

Open ljharb opened 2 years ago

ljharb commented 2 years ago

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 commented 2 years ago

I raised the similar issue in original proposal: https://github.com/tc39/proposal-record-tuple/issues/327

Here are the names I suggested: parsePrimitive or parseAsPrimitive

ljharb commented 2 years ago

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

hax commented 2 years ago

@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 commented 1 year ago

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

ljharb commented 1 year ago

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

chimericdream commented 5 months ago

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

ljharb commented 5 months ago

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