Re:Go vs. Swift [pdf]
by tomjakubowski on Thursday January 19, 2017 @01:47AM
(#13433667)
> Rust copied 'if let' from Swift (~2 years ago) despite having decent pattern matching; community consensus today is that it's highly worthwhile as a feature.
Rust copied 'if let' and made it far nicer and more capable by allowing arbitrary fallible pattern matches to be the condition. Then Swift 2 copied that improvement back with 'if case'.
Re:Go vs. Swift [pdf]
by Ericson2314 on Wednesday January 18, 2017 @09:31PM
(#13432471)
? is bind for Either monad if you squint.
`context(e?)` becomes `e >>= \x -> context(x)`
You mean `e >>= context` ? ;)
Re:Go vs. Swift [pdf]
by Ericson2314 on Thursday January 19, 2017 @06:16PM
(#13440361)
Hah!
I should have been clear about CPSing things first so I didn't need to eta-expand :)
edit: FWIW, there's some overlap between '?' and 'guard let', but not that much. Using hypothetical Rust syntax, they'd overlap in this case:
better expressed as …but if you want to return something other than a Result, or the ADT being matched on is something custom rather than Option/Result, there's no good way to make '?' do the job.