I think I understand how to use them, but I don't have the first clue why they're useful. The example in the documentation is just about ( barely ) enough to figure out how to use them, but it's not even close to justifying the use of them.
Great. This does the same thing.
The only advantage to the former is that you don't have to keep a track of which exception function you're going to throw. Although it's swings and roundabouts because you might end up with some pretty complex nests of Try and EndTry blocks which are just about as much work as keeping track of which throw function to use.
So there has to be more than this to it, or it wouldn't be there. But having read the docs and searched the forums, I can't find anything.
Perhaps the people writing the docs would understand the issue better if I compared this to pointers. I always knew what pointers were. I always knew how to use them. It just took me bloody ages to figure out WHY I should use them. It's the same here. I'm sure that C# and Java programmers just picked it up and ran with it, but I'm not one, and it might be nice to have some idea of the *real* purpose.
Rem Throw generates a BlitzMax exception. End Rem Try repeat a:+1 print a if a>20 throw "chunks" forever Catch a$ print "caught exception "+a$ EndTry
Great. This does the same thing.
Rem Throw generates a BlitzMax exception. End Rem repeat a:+1 print a if a>20 ThrowException("chunks") forever Function ThrowException(ex:string) print "caught exception "+ex End Function
The only advantage to the former is that you don't have to keep a track of which exception function you're going to throw. Although it's swings and roundabouts because you might end up with some pretty complex nests of Try and EndTry blocks which are just about as much work as keeping track of which throw function to use.
So there has to be more than this to it, or it wouldn't be there. But having read the docs and searched the forums, I can't find anything.
Perhaps the people writing the docs would understand the issue better if I compared this to pointers. I always knew what pointers were. I always knew how to use them. It just took me bloody ages to figure out WHY I should use them. It's the same here. I'm sure that C# and Java programmers just picked it up and ran with it, but I'm not one, and it might be nice to have some idea of the *real* purpose.