|
|
|
|
|
by __sdegutis
2854 days ago
|
|
It sounds closer to Haskell to me. ADTs are very similar to associated values that Swift has, although I think they're on a slightly higher type level. I haven't found Haskell too unreadable but that's probably because it ditched C-style syntax whereas Swift stuck with it. Maybe it's a trade-off worth making though, since sticking with familiar syntax lowers the bar. |
|
- they use this verbose syntax to access payloads "if case let .foo(bar) = baz { /* do something with bar */ }" The alternative being to do everything in a switch statement, and possibly create a local variable thanks to scope
- their payloads are not convertible to tuples, despite their cosmetic similarity
- they do not allow default values, despite their cosmetic similarity to swift function parameters (which do support default values)
- they aren't automatically Hashable and Equatable
- they aren't automatically included in the Enum's array of ".allCases"
The great thing about Swift is that all of these issues can be worked around using extensions. Unfortunately (the way I do things, anyways) that means a lot of the time in Swift, the Enum itself is maybe 5 lines long, while my extensions to work around the above limitations go on and on for another 30+ lines.