Can somebody explain, maybe with a concrete example of something where it poses a problem, why the syntactic ambiguity is actually an issue? The only case where the ambiguity comes up is if you are using
let ... else on something of type
(), which there is no imaginable reason to do and it doesn’t even work (doing the same with
if let errors out with “irrefutable if let pattern” and presumably this’d do likewise), so it’s absolutely clear that it should always be parsed the other way. There’s an ambiguity in theory, but not in practice.
I’m not saying we shouldn’t discuss it or anything, but it seems to be regarded as some kind of quasi-blocker and I don’t understand it.
I guess if you also allow
continue and also
throw if we ever add that… but
panic!() isn’t the only function with a return type of
!, e.g. in a small command line app I’d call the “print help and exit” function. (Of course you could do the same workaround but as you say, it’s weird.) I guess my point is that the ways to short-circuit/exit are more varied in practice than one might assume in theory, so special-casing the few built-in ones doesn’t feel as justified. Also e.g. macros with one of the control flow keywords inside them… (or the type inference fallback to
! that’s going to happen, so maybe something like
Err(x)? would work too…)