distinct type aliasing
This commit is contained in:
@@ -127,7 +127,12 @@
|
||||
|
||||
7. enums (native and c interop) (see below)
|
||||
|
||||
8. distinct types (see below)
|
||||
8. distinct types (implemented; see below)
|
||||
- nominal declarations preserve identity across packages and reuse the backing runtime representation
|
||||
- construction uses `Type(value)` with exactly one value of the exact backing type
|
||||
- no implicit conversion to or from the backing type
|
||||
- backing-type operators and reverse explicit conversions remain deferred
|
||||
- concrete runtime backing types are supported; unresolved, `int`, `void`, function, and opaque backings are rejected
|
||||
|
||||
## A word on multi-unwrap
|
||||
|
||||
@@ -204,7 +209,7 @@ Distinct types are considered distinct from their backing type. They do not impl
|
||||
UserID :: distinct u32
|
||||
|
||||
# instantiate distinct type
|
||||
my_id UserId :: UserID(42) # value must be of to backing type
|
||||
my_id UserID :: UserID(42) # value must have the exact backing type
|
||||
```
|
||||
|
||||
# A word on enums
|
||||
|
||||
Reference in New Issue
Block a user