Skip to content

Clarify that key comparison is ordinal#993

Open
marzer wants to merge 3 commits into
toml-lang:mainfrom
marzer:ordinal-key-comparison
Open

Clarify that key comparison is ordinal#993
marzer wants to merge 3 commits into
toml-lang:mainfrom
marzer:ordinal-key-comparison

Conversation

@marzer

@marzer marzer commented Sep 27, 2023

Copy link
Copy Markdown
Contributor

@SnoopJ identified in #966 that the TOML spec does not specify how keys are compared. We've discussed the matter to death at this point, and if I never hear the word "normalization" again it'll be too soon 😅, but to recap:

  1. Requiring normalization imposes significant implementation burden, and shuts out people who may explicitly not want that behaviour
  2. Recommending (but not requiring) normalization creates ecosystem fragmentation and round-trip issues
  3. Not saying anything about it at all leaves an ambiguous hole in the spec

So I'm taking @eksortso's proposal in his comment in #966 and running with it. This is not intended to complete with @arp242's #990 - they're orthogonal, really. Regardless of what we decide RE normalization (or lack thereof), we should say something about how keys are treated during comparison.

This also somewhat strengthens the idea that keys are just strings. Since they can be specified using string syntax, there's really no argument to be made for treating them as anything else anyway, IMO. TOML isn't a programming language.

Closes #966

@arp242

This comment was marked as off-topic.

@marzer

This comment was marked as off-topic.

SnoopJ

This comment was marked as off-topic.

@arp242

This comment was marked as off-topic.

@marzer

This comment was marked as off-topic.

@arp242

This comment was marked as off-topic.

@marzer

This comment was marked as off-topic.

@arp242

This comment was marked as off-topic.

@arp242

This comment was marked as off-topic.

@erbsland-dev

This comment was marked as off-topic.

@arp242

This comment was marked as off-topic.

@erbsland-dev

This comment was marked as off-topic.

@arp242

This comment was marked as off-topic.

@erbsland-dev

This comment was marked as off-topic.

@arp242

This comment was marked as off-topic.

@erbsland-dev

This comment was marked as off-topic.

@arp242

This comment was marked as off-topic.

@marzer

This comment was marked as off-topic.

@arp242

This comment was marked as off-topic.

@erbsland-dev

This comment was marked as off-topic.

@SnoopJ

This comment was marked as off-topic.

@ChristianSi

This comment was marked as off-topic.

@arp242

This comment was marked as off-topic.

@marzer

This comment was marked as off-topic.

@arp242

This comment was marked as off-topic.

@marzer

This comment was marked as off-topic.

@arp242

This comment was marked as off-topic.

@marzer

This comment was marked as off-topic.

@arp242

This comment was marked as off-topic.

@pradyunsg pradyunsg changed the title Clarify that key comparison is ordinal (closes #966) Clarify that key comparison is ordinal Apr 19, 2025
@arp242 arp242 force-pushed the ordinal-key-comparison branch from 27cc1d4 to 7cee7df Compare June 29, 2026 15:44
Use the phrase "quoted keys", because currently none of this applies to
unquoted/bare keys .
@arp242

arp242 commented Jun 29, 2026

Copy link
Copy Markdown
Member

I rebased this on the current main, and added a few small changes. See commit log.

This fits with #1095: "TOML tables are intended to map to hash tables or dictionaries, as a consequence empty quoted keys are allowed". I think we can merge it?


Pretty much all of the above discussion went on about what to do about normalisation in the context of unicode bare keys, and the PR got stuck on that. That is currently not relevant, and was arguably it was off-topic in the first place. I've hidden all comments as "off topic". What we do or don't want to do with regard with normalisation for Unicode bare keys can be discussed (again...) once we add something for that to TOML again.

@SnoopJ SnoopJ left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still have no authority, but I also still approve of this changeset. The example here is reasonably illustrative and the note that this is DISCOURAGED is good to have.

@arp242

arp242 commented Jun 29, 2026

Copy link
Copy Markdown
Member

May want to add a "TOML tables are intended to map to hash tables or dictionaries, as a consequence [..]" line here by the way, similar to #1095. I'll see what comes out of that proposal before adding it here.

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

Successfully merging this pull request may close these issues.

Clarify that key uniqueness depends only on binary representation, recommend normalization

5 participants