evhub / coconut

Simple, elegant, Pythonic functional programming.
http://coconut-lang.org
Apache License 2.0
4.05k stars 120 forks source link

Error handling similar to Rust? #782

Closed MarkuBu closed 1 year ago

MarkuBu commented 1 year ago

I recently found Coconut and I think it is an interesting option for functional languages.

But I miss one Feature (at least I haven't found any hint for that). I'm looking for error handling similar to Rust with Result Type and Option Type.

In the factorial example in the interactive tutorial traditional exception handling is used for error handling (raise TypeError).

Did I miss something? If not, would it be a feature that should be added?

evhub commented 1 year ago

Yes; Coconut has this now! It was just added relatively recently, which is why it's not in the tutorial. What you're looking for is Coconut's safe_call function and Expected built-in.