Constrain protocol usage outside the module

I understand your point, but to be fair, that is not true at all. If this statement were true then public enums with no public API and with no cases would also be elided by the compiler. Yet we have Never in stdlib. At the point of the proposal of Never if closed protocols have existed already then who knows if we'd now have public protocol Never {} (closed is implied).

If you recall from the Never proposal:

public /*closed*/ enum Never {
  /* this space intentionally left blank */
}

Building on that, a Never protocol could probably become much easier the bottom type than an empty enum.

The usefulness of such a type is up to the library author and library user to debate. Since everyone is somehow a library author I can say, that having flexible even less discoverable but not harmful features in the language is only a pleasure compared to the status quo where one has to bend to language at different corners to achieve one simple thing and care the overhead cost around.

1 Like