Replies: 3 comments
-
I feel like |
Beta Was this translation helpful? Give feedback.
-
Per discussion in the Telegram chat, untangled values are rarely usable.
Disallowing enum extension would however prohibit deriving a trait later. What if a enum extension disallowed to define new elements, but only methods and static members?
Having an ability to derive from a trait implies the need to be able to operate on member ions within the original enum definition as well.
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
By default, a enum is a thin wrapper around
<SSize>
, which is the word size of target machine.An integral element token doesn't have a determined integral counterpart by default, it is defined during compilation.
Explicitly setting an element value entangles it with the outer world, mapping it 1:1 to the integral counterpart.
An attempt to construct a enum with a specific integer may throw if the value is untangled.
To allow members in a enum type, an element shall be defined in the manner similar to a field definition.
Keyword
erata
(https://en.wiktionary.org/wiki/erata) is used to define a element.The syntax enables methods for a enum type.
Within a enum method,
this
is a calller copy.By default, a enum defines
==(arg : self) : Bool
andnumeric() : Type
.A enum may inherit another enum of the same underyling type (conflicting element values would panic), or derive from one or more traits.
A enum instance may be switched upon its element token, which can be symbolized and then tokenized back.
A symbolized name may only be tokenized if its unambiguous in the context of the tokenization site (not on the caller site).
Alternatively, if a enum body begins with a token, then the whole body is expected to consist of comma-separated element definitions with
erata
keyword implied.Similar concept exists in struct-record difference.
A enum type may be defined with a
bitwise
keyword instead, which would ensure its tokens only have values of power of two.(TIP: Think of it as if it was
def integral enum
anddef bitwise enum
).A bitwise enum is implcitly
<USize>
by default.Bitwise arithmetic is defined for a bitwise enum type.
A enum type may also be used as literal restriction, whereas a enum token may be used as a template argument.
Beta Was this translation helpful? Give feedback.
All reactions