Fortran is a bit outdated, to say the least...sje wrote:"Dear Father, forgive me for I have sinned. Decades ago I taught the evil that is Fortran, just because I needed the money. I deeply regret this and promise never to do it again."Ajedrecista wrote:I made a Fortran parser with the help of Internet
"My son, you are forgiven. You must say ten Our Fathers and ten Hail Marys as a penance. Further, you will never again use the Devil's goto statement no matter how alluring it might be. And if you fear the fires of Hell, you won't even consider the mortal sins of setjmp()/longjmp()."
Perhaps I'm mistaken, but does your program count promotion moves if there are more than one promotion move per text line?
But goto and setjmp()/longjmp() are not evil at all. They are extremely useful. However, in the hands of incompetent programmers, they lead to obscure and unmaintainable code. Then people put the blame on goto instead of the incompetent programmer who writes messy code...
In good quality code gotos are rare, but everytime they are present they simplify code and make it more readable (avoid complicated artificial crap to break out of nested loops for example). You will be surprised to see that even Stockfish has a few goto!
setjmp() and longjmp() are the C equivalent of C++ exceptions. For me they are exactly the same, and using C++ exceptions is not cleaner or prettier than doing these evil "cross function goto". The only difference is that C++ exceptions calls destructors of objects allocated on the stack before the throw statement (stack unwinding). But since destructors are an addition of C++ and do not exist in C, the C++ exception is exactly the same as setjmp() and longjmp(), only with a slight tweak to make it compatible with C++.
So it's neither goto, not setjmp()/longjmp() that are ugly. It's just code written by incompetent programmers that is ugly, and they can write ugly code with or without goto.