Re: debugging

new topic     » goto parent     » topic index » view thread      » older message » newer message

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

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu