Re: debugging
- Posted by "Carl W." <euphoria at cyreksoft.yorks.com> Jul 22, 2002
- 404 views
10963508 at europeonline.com wrote: > It would be good if we could be able to find out if type_check is on > or off, like a debug variable. something like: > > if type_check then > ... do debugging checks > end if That might be a useful construct, but only in terms of debugging. If you're debugging you may as well assign a sequence to an atom and see if the program crashes. If not, type_checking is off. ;) > Also, assert() statement would be usefull: > > assert (debug_function ()) This isn't quite as informative as the C/C++ equivalent, but it serves its purpose... type bool(object b) if integer(b) and b = 1 or b = 0 then return 1 end if return 0 end type global bool ASSERT ASSERT = 1 -- set to 0 to turn assert()s off global type assert(bool x) if ASSERT then return x = 1 end if return 1 end type with trace atom b integer a a = 5 b = 2.2 * sqrt(a) trace(3) -- check the manual assert(a > b) -- passes b *= 1.1 assert(a > b) -- fails Carl