Can the compiler save me from my own stupidity?
BlitzMax Forums/BlitzMax Programming/Can the compiler save me from my own stupidity?
| ||
One of the problems I often encounter with writing any OOP code is that I write something like: Global objectVar:TList Then forget to actually create the object using the New operator (either directly or via another function). When you later call any list functions, this causes a somewhat bewildering "Unhandled Exception" error, which can be tricky to track down since the error often occurs in a completely different part of the code, or sometimes even a completely different module. Compilers like GCC / VC++ would print a warning in equivilent code that objectVar has not been initalised. Does anyone have any ways of dealing with this at the moment? Could any compiler features be implemented to protect me from my forgetfulness? |
| ||
I suspect it's a matter of waiting for the debugger. |
| ||
One simple thing would be for the variable to be initialized to a fixed known bad value and for the error to be flagged appropriately. This was the solution adopted for uninitialized handles by several Mac programming environments. |
| ||
some switches to enable detection of unused variables would be handy too! maybe different levels of strict strict flags flags could be unused vars non matching incbin to incbin:: potential leak warning case sensitive etc etc |
| ||
I must admit I'd love something that flagged up declared but otherwise unused variables. Over the course of a big project I tend to wind up with quite a few of those. |
| ||
I'd love blitz3d types to be honest. Blitzmax has me confused all the time. |
| ||
BlitzMAX types are the same as Blitz3D, just with a few extra features and no global type list. |