Stream: ideas

Topic: ✔ Set.size


view this post on Zulip Isaac Van Doren (Feb 01 2025 at 05:18):

Is there a reason we don't have a Set.size? I'm happy to create an issue for it if that is the name we want.

view this post on Zulip Brendan Hansknecht (Feb 01 2025 at 05:34):

Set.len it exists https://www.roc-lang.org/builtins/Set#len

view this post on Zulip Isaac Van Doren (Feb 01 2025 at 05:49):

Wow. How did I miss that. I literally looked at the docs :face_with_peeking_eye:. Alright, thanks :sweat_smile:

view this post on Zulip Notification Bot (Feb 01 2025 at 05:49):

Isaac Van Doren has marked this topic as resolved.

view this post on Zulip Brendan Hansknecht (Feb 01 2025 at 05:52):

Might be smart to put the word size in the doc comments so searching for length or size finds the correct item.

view this post on Zulip Isaac Van Doren (Feb 01 2025 at 06:05):

I wonder if it would make sense to rename it to Set.size. Length is not a property that I usually think of sets having.

view this post on Zulip Isaac Van Doren (Feb 01 2025 at 06:06):

Same for dictionaries

view this post on Zulip Brendan Hansknecht (Feb 01 2025 at 06:07):

I really dislike it being different from lists. So I think we should change all or none

view this post on Zulip Brendan Hansknecht (Feb 01 2025 at 06:08):

Also, weirdly, I think of dictionaries having lengths, but less so sets. Maybe just cause I almost never use sets and have interacted with them more though math, but I use maps and dictionaries way more often so am more used to length.

view this post on Zulip Isaac Van Doren (Feb 01 2025 at 06:09):

I would be happy with List.size

view this post on Zulip Isaac Van Doren (Feb 01 2025 at 06:10):

Also, weirdly, I think of dictionaries having lengths, but less so sets.

I agree. Maybe it's because the physical analogy of a dictionary is definitely ordered. Whereas sets (as presented in math) are very much definitely not ordered by themselves.

view this post on Zulip Richard Feldman (Feb 01 2025 at 12:51):

I agree that the name should be consistent between collections, but I think making a separate topic to discuss size seems reasonable. We've never talked about it before!


Last updated: Jun 16 2026 at 16:19 UTC