New syntax suggestion: catch with type specs

I don’t think that’s my argument but I’m gonna take care of some other things and maybe if this proposal picks up steam I’ll think about it again at that time.

1 Like

To be clear, Julia supports this just fine (via if statements in a catch block). It just doesn’t have a specialized syntax.

The question of whether specialized syntax is worth the cost (e.g. of complicating the language) depends on how widely it is used. Julia has been around for > 10 years — do we see a lot of real-world code that uses catch blocks with if statements to filter the exceptions, which could be simplified with specialized syntax? Should this pattern be used more frequently?

The fact that trycatch is not widely used for control flow in Julia (as opposed to e.g. Python), in part for performance reasons, is relevant here because it reduces the demand for a dedicated syntax.

7 Likes

The claim is just that using exceptions for control flow is a bad idea, and that’s worth mentioning because people who come from Python may be used to that style.

It’s mentioned because it’s common in Python. The judgement that it’s a bad idea is independent of Python.