A native Assert function

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
milan1612
Addict
Addict
Posts: 894
Joined: Thu Apr 05, 2007 12:15 am
Location: Nuremberg, Germany
Contact:

A native Assert function

Post by milan1612 »

I really like the idea of having a native Assert function. The signature could look something like this:

Code: Select all

Assert(SizeOf(Integer) = 4)
Assert(OpenWindow(0, ...) <> 0)
Assert(*Ptr <> 0)
The assertion should be tested during compilation (where possible) and during runtime.
If the assertion failes, an error dialog should be displayed showing the exact location in the code,
and maybe some other information followed by an immediate call of the End function.

Would be very handy to develop much more reliable code in Purebasic :P
Windows 7 & PureBasic 4.4
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

The 'much reliable' stuff is out of context, as it's not a limitation to not have such simple macro build-in. And some (like me) hates the assert way to not be able to recover or finish properly in case of runtime errors.
milan1612
Addict
Addict
Posts: 894
Joined: Thu Apr 05, 2007 12:15 am
Location: Nuremberg, Germany
Contact:

Post by milan1612 »

Of course I can write my own macro for this and the lack of an Assert macro in
Purebasic is certainly not a limitation. It's just that I always prefer it the "native way"
so I don't need to roll up my own stuff :P. Well, fair enough...
Windows 7 & PureBasic 4.4
Post Reply