Replies: 4 comments
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
-
|
Beta Was this translation helpful? Give feedback.
0 replies
-
@danieldaeschle: OK, thanks. I edited the summary in light of that. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
In git we have:
if sum is T {/* sum is type T here */}
which shadowssum
in the block.if sum is T as var {
which safely unwrapssum
with the namevar
.Outside
if
,sum is T
produces a boolean. What ifsum is T
produced an optional everywhere? Ifsum
doesn't hold aT
thensum is T
would equalnone
. Then we could use optional handling with sum types:We could make
if opt {
valid with an optional value so thatif sum is T {
works naturally. That would be useful for shadow unwrapping an optional:Shadowing seems at least as useful for safe unwrapping of an optional variable as it is for sum type instance unwrapping.
opt or
could also work for shadow unwrapping an optional variable:All this unifies safe sum type unwrapping with optional handling in the language, for consistency.
Beta Was this translation helpful? Give feedback.
All reactions