-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed
Labels
acceptedThis proposal is planned.This proposal is planned.proposalThis issue suggests modifications. If it also has the "accepted" label then it is planned.This issue suggests modifications. If it also has the "accepted" label then it is planned.
Milestone
Description
A non-exhaustive enum is an enum that may have other unknown members.
This can help create APIs that may be extended in future. This sort of thing frequently comes up in data formats, network protocols, and even C APIs.
Possible syntax:
- a non-exhaustive enum is created by including
_
as a trailing field.
Semantics:
- A non-exhaustive enum must have the size specified:
enum(u5) { X, Y, Z, _ }
- If you specify
_
when an enum is already "full" (e.g. if it'su2
and you specify 4 values followed by a_
), then there is a compiler error. - When
switch
-ed on, anelse
clause is always required @intToEnum
can never fail withhas no tag matching integer value
builtin.Enum
gains a new boolean fieldis_exhaustive
Related
emekoi, fengb, raulgrell, Beefster09, ikskuh and 8 more
Metadata
Metadata
Assignees
Labels
acceptedThis proposal is planned.This proposal is planned.proposalThis issue suggests modifications. If it also has the "accepted" label then it is planned.This issue suggests modifications. If it also has the "accepted" label then it is planned.