-
Notifications
You must be signed in to change notification settings - Fork 16
/
enum.theory.txt
26 lines (21 loc) · 2.38 KB
/
enum.theory.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
ENUM
ENUMS ==> #Type whose:
# - key is among a set of possible exclusive keys
# - value is unspecified to the user
# - the compiler/interpreter usually represents it using either:
# - a compact solution, e.g. bitstring
# - a simple solution, e.g. same as key
#Enums can be:
# - either exclusive or not, in which case they can or'd bitwise ("flags")
# - either ordered or not
#They are an evolution over just using another type (integer or string) with exclusive values
#to simulate that purpose:
# - more self-documenting
# - more efficient representation
# - restrict possible operations
# - enforce stricter typing
UNIT TYPE ==> #Enum with single value.
#Enums can also be thought as union of unit types.
#Examples: null and undefined in JavaScript