Re: new except syntax in interim release 656
Paul Prescod <[email protected]>
| Newsgroups | gmane.comp.lang.prothon.user |
|---|---|
| Message-ID | <[email protected]> |
Mark Hahn wrote: > I've changed the except syntax to fix a wart that Paul has complained about. > Let me know if you think the fix is worse than the wart. This change plus a > number of bug fixes and the "late evaluation of formal params" is in the > interim release 656 at http://prothon.org. Cool. > Some except syntax examples ... > > except Exception: > > except label = Exception: > > except label = (ExceptionObject1, ExceptionObject2): > > except ExceptionObject: > > except (ExceptionObject1, ExceptionObject2): Pretty good. But did you consider: except label = ExceptionObject1 or ExceptionObject2 Or how about try: ~ ... except ExceptionObject1 or ExceptionObject2 as label: ~ ... I kind of like that! Two things always struck me as a little weird about Python's exceptions (beyond the blatant warts that you've fixed). First, it is the only place in the language that does pattern matching. Python doesn't even have a switch statement to say nothing of ML-style pattern matching. I'm not proposing anything concrete but it is interesting to think of where you might generalize this syntax. Second, in languages that are not supposed to care about types much (especially Prothon but also Python) isn't it a little funny to match on type? It all works okay because inheritance structures for exceptions tend to be simple and you usually don't use random objects as exceptions. But it doesn't jibe entirely with my intuitions... I'm not proposing to change anything: just provoke thought. Paul Prescod