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

Define an algorithm to create a Set from a List #659

Merged
merged 3 commits into from
Dec 19, 2024

Conversation

OrKoN
Copy link
Contributor

@OrKoN OrKoN commented Dec 18, 2024

In the WebDriver BiDi spec, there is a need to convert lists created from JSON messages into sets for internal algorithms. This PR adds a helper to define how the operation of creating a set from a list should be performed. The operation seems to be common and relatively straight-forward so it might make sense that the Infra standard defines it.


Preview | Diff

@OrKoN OrKoN force-pushed the orkon/set-from-list branch from 29f528e to 875a5f5 Compare December 18, 2024 17:59
@OrKoN OrKoN changed the title Define steps to create a Set from a List Define an algorithm to create a Set from a List Dec 18, 2024
@OrKoN OrKoN marked this pull request as ready for review December 18, 2024 18:26
Copy link
Member

@domenic domenic left a comment

Choose a reason for hiding this comment

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

Good idea!

infra.bs Outdated
@@ -1694,6 +1694,16 @@ unordered one, since interoperability requires that any developer-exposed enumer
contents be consistent between browsers. In those cases where order is not important, we still use
ordered sets; implementations can optimize based on the fact that the order is not observable.

<div algorithm>
<p>To <dfn export for=set>create a set</dfn>, given a [=/list=] |input|:
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, I'd prefer naming this either <dfn export>create a set from a list</dfn>, or <dfn export for="set">create</dfn>. The latter makes sense if we think there's no other reasonable input for creating a set, whereas the former is more specific.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Went for <dfn export for="set">create</dfn>. I think creating from other data structures is less common. Nevertheless, the create steps could accept a generic iterator instead of a list but since that is not currently specified it probably makes sense to just use the list.

infra.bs Outdated Show resolved Hide resolved
@OrKoN OrKoN force-pushed the orkon/set-from-list branch from 644f5a4 to 7182a7f Compare December 19, 2024 07:12
Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

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

I suppose we can always overload or chase down all callers using dontcallmedom's website in the worst case.

@annevk annevk merged commit ffebfb4 into whatwg:main Dec 19, 2024
2 checks passed
@annevk
Copy link
Member

annevk commented Dec 19, 2024

Thanks Alex!

@OrKoN OrKoN deleted the orkon/set-from-list branch December 19, 2024 07:26
@OrKoN
Copy link
Contributor Author

OrKoN commented Dec 19, 2024

Thanks for reviewing!

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

Successfully merging this pull request may close these issues.

3 participants