Quantcast
Channel: ReScript Forum - Latest posts
Viewing all articles
Browse latest Browse all 2592

Proposing new syntax for zero-cost unwrapping options/results

$
0
0

I don’t think it’ll be good without more explicitness. it’s not clear that let Ok(x) = fn() is going to return on Error. why not just generalize the already pattern-matched left-side to allow for an else statement that will complement the pattern match?

let Ok(x) = fn() else { ... }? and then also add let? for automatic returns. maybe if we supported both, it would make more sense to allow let? x = fn(), that is, without pattern match? and allow return keyword inside else:

let Ok(x) = fn() else { return Error("fail") } (ensure that else has either return or panic, like rust?)
and also
let? x = fn() which would automatically early-return the error (or None)


Viewing all articles
Browse latest Browse all 2592

Trending Articles