Print debugging statement: Difference between revisions

m (→‎{{header|REXX}}: added zkl header)
(→‎{{header|zkl}}: added code)
Line 345:
 
=={{header|zkl}}==
Print debugging is similar to C. The _debug_ keyword conditionally compiles
<lang zkl></lang>
code (ie the debug code isn't compiled unless debugging is turned on).
<lang zkl></lang>
<lang zkl>fcn ds(line=__LINE__){
println("This is line %d of file %s compiled on %s"
.fmt(line,__FILE__,__DATE__));
}();
_debug_{
ds(__LINE__); println("Debug level is ",__DEBUG__);
vm.stackTrace().println();
<lang zkl>}</lang>
{{out}}
<pre>
Run with debugging turned off:
 
$ zkl rs
This is line 39 of file rs.zkl compiled on 2019-08-28
 
Run with debugging turned on:
Due to some brain deadness, we need to set the debug level (-d), compile the
file (-c) then run it and quit out of the REPL:
 
$ zkl -dc rs --run --quit
Compiled Class(rs) (0.0 seconds, ??? lines/sec)
This is line 44 of file rs.zkl compiled on 2019-08-28
This is line 49 of file rs.zkl compiled on 2019-08-28
Debug level is 1
Stack trace for VM#1 ():
rs.__constructor@stackTrace addr:25 args(0) reg(0)
startup.__constructor@__constructor addr:1767 args(0) reg(22) R
</pre>
Anonymous user