During the last monthly call I was reminded of the fact that Fortran does not support exceptions. While I cannot judge the complexities that are involved in implementing such a feature, I thought I could do some experimenting with the typical coding patterns you see in other languages. This has resulted in a repository on Github with a simple example. I would call it a form of cooperative exception handling, as it simply transforms try-catch-throw “statements” into regular Fortran code, but that relies on all the code being preprocessed. (That is probably avoiding all the difficulties a true exception handling feature must face.)
So a very limited and perhaps laughable attempt, but it might inspire someone - and it was fun to set up.
Nice! I realised that I would need to use a labelled do-loop to jump out of the right loop in case of nesting. But using a block construct is much more elegant.
I was writing up something on how the deprecated but useful alternate return has allowed for some of this for a long time, but then saw the link to just such a discussion in more length than I had written. I like the style the preprocessor lets you produce. Nice.
Things are starting to fall in place with these discussions! The past discussions are archived and we are building upon them by referencing them. Finally we are not starting from scratch with every new idea. I am personally very happy about that, that is exactly what I was hoping to achieve by starting the “incubator repository” (GitHub - j3-fortran/fortran_proposals: Proposals for the Fortran Standard Committee).