Stream: beginners

Topic: why does Set.empty accept an argument?


view this post on Zulip Sven van Caem (Jul 17 2023 at 16:28):

I'm curious why both Set.empty and Dict.empty take {} as an argument? I'm guessing there's a technical reason for it.

view this post on Zulip Brendan Hansknecht (Jul 17 2023 at 18:48):

We don't have zero argument functions.

view this post on Zulip Brendan Hansknecht (Jul 17 2023 at 18:49):

They have to be functions due to a technical reason (can try to find the real doc later if you want). Essentially if they weren't functions, you would only ever be able to have one type of Dict or Set. You wouldn't be able to generate multiple kinds.

view this post on Zulip Ajai Nelson (Jul 17 2023 at 19:01):

I think this is the relevant doc? https://rwx.notion.site/Let-generalization-Let-s-not-742a3ab23ff742619129dcc848a271cf

view this post on Zulip Richard Feldman (Jul 17 2023 at 19:09):

yeah, there's a planned improvement which would let us remove them (so it would just be Dict.empty : Dict * *) but it's not a high priority at the moment because it only comes up in a couple of places, and it's just an extra {} to pass in :big_smile:

view this post on Zulip Sven van Caem (Jul 18 2023 at 12:57):

Ajai Nelson said:

I think this is the relevant doc? https://rwx.notion.site/Let-generalization-Let-s-not-742a3ab23ff742619129dcc848a271cf

Interesting read, thanks! That makes a lot of sense.

view this post on Zulip Sven van Caem (Jul 18 2023 at 12:58):

Richard Feldman said:

yeah, there's a planned improvement which would let us remove them (so it would just be Dict.empty : Dict * *) but it's not a high priority at the moment because it only comes up in a couple of places, and it's just an extra {} to pass in :big_smile:

Does there happen to be a document on this too? I'm curious what that would look like.

view this post on Zulip Richard Feldman (Jul 18 2023 at 13:43):

I don't think so - basically @Ayaz Hafiz has an idea to extend the same thing we're doing for numbers to lists and some other types

view this post on Zulip Richard Feldman (Jul 18 2023 at 13:44):

and since those data structures are built from lists, they'd be fine

view this post on Zulip Sven van Caem (Jul 18 2023 at 15:12):

Ahh, gotcha!


Last updated: Jul 06 2025 at 12:14 UTC