I don't know if I posted this before, but it's really important for me! I
would like to have Try-Catch implemented in PureBasic because for
real error-handling, there is no alternative! Look at the example:
Code: Select all
Procedure dangerous()
Dim a.l(50)
NewList k.l()
For z = 0 To 99999
AddElement(k())
Next
CopyMemory(1, 1, 1)
EndProcedure
OnErrorGoto(?error)
MessageRequester("Start", "Start the test.") ;2667KB
If #True;TryError()
dangerous()
Else
error:
MessageRequester("Error", "There was an error!") ;5080KB
EndIf; : EndTryError()
grows while calling the procedure (see comments after MessageReq.()).
When an error occurs and the error handler jumps out of the procedure
the memory of the local lists and arrays won't be freed and you shouldn't
run the program any longer as this could create some errors. Furthermore
there isn't a safe variant of CopyMemory(), that means, I cannot be sure
if there is also some unfreed memory used by CopyMemory(), I would
like to have a CopyMemorySafe() function.
What I would like to have is, that I could use SetErrorNumber() in a
procedure without needing to have the error-handling within that procedure (like Try-Catch, not OnErrorGoSub()).
The PB-compiler should just have a "safe" mode in which the compiler
jumps to the end of the procedure when an exception occurs to free all
the unused memory and only then jump to the Catch-section.
Yes, I know this won't be implemented soon as it could be a big job if you
want it to work the right way (and you surely want). Just a wish...

greetz
Remi