Wiki
Download
Manual
Eggs
API
Tests
Bugs
show
edit
history
You can edit this page using
wiki syntax
for markup.
Article contents:
== Outdated egg! This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for [[/eggref/5/debug|the CHICKEN 5 version of this egg]], if it exists. If it does not exist, there may be equivalent functionality provided by another egg; have a look at the [[https://wiki.call-cc.org/chicken-projects/egg-index-5.html|egg index]]. Otherwise, please consider porting this egg to the current version of CHICKEN. == debug Some trivial debugging macros [[toc:]] === Abstract According to [[http://books.google.com/books?id=nneBa6-mWfgC&lpg=PA227&ots=gEvyGdNW3u&dq=%22thou%20shalt%20put%20printf%22&pg=PA227#v=onepage&q=%22thou%20shalt%20put%20printf%22&f=false|Joe Armstrong]], "The great gods of programming said, 'Thou shalt put {{printf}} statements in your program at the point where you think it’s gone wrong, recompile, and run it.'" === Documentation ==== {{debug?}} <parameter>debug? → #t</parameter> `debug?' turns on or off debugging output, depending on whether it is set to #t or #f; respectively. <enscript highlight="scheme">(define debug? (make-parameter #t)) </enscript> ==== {{trace}} <syntax>(trace f) → unspecified</syntax> Trace the input to and output from a function. ; {{f}} : The function to be traced <enscript highlight="scheme">(define-syntax trace (er-macro-transformer (lambda (expression rename compare) (match-let (((_ f) expression)) (let ((%set! (rename 'set!)) (%lambda (rename 'lambda)) (%call-with-values (rename 'call-with-values)) (%apply (rename 'apply)) (%format (rename 'format)) (%values (rename 'values)) (%let (rename 'let)) (%f (rename 'f)) (%when (rename 'when)) (%debug? (rename 'debug?))) `(,%when (,%debug?) (,%let ((,%f ,f)) (,%set! ,f (,%lambda x (,%format (current-error-port) ";; Arguments to ~a: ~a~%" ',f x) (,%let ((return-values (,%call-with-values (,%lambda () (,%apply ,%f x)) (,%lambda x x)))) (,%format (current-error-port) ";; Values from ~a: ~a~%" ',f return-values) (,%apply ,%values return-values))))))))))) </enscript> ==== {{debug}} <syntax>(debug expressions) → unspecified</syntax> Debug the expressions to stderr by pretty-printing each expression and their evaluations. ; {{expressions}} : The expressions to be debugged <enscript highlight="scheme">(define-syntax debug (syntax-rules () ((_ x ...) (with-output-to-port (current-error-port) (lambda () (when (debug?) (pp `(,(if (or (boolean? 'x) (char? 'x) (number? 'x) (string? 'x) (vector? 'x)) x `(x => ,(handle-exceptions exn (let ((message ((condition-property-accessor 'exn 'message) exn)) (arguments ((condition-property-accessor 'exn 'arguments) exn))) (format "Error: ~a~a" message (if (null? arguments) "" (format ": ~a" (string-join (map ->string arguments) ", "))))) x))) ...)))))))) </enscript> ==== {{debug-priority}} <parameter>debug-priority → prio/debug</parameter> The priority associated with {{debug/syslog}} <enscript highlight="scheme">(define debug-priority (make-parameter prio/debug)) </enscript> ==== {{debug/syslog}} <syntax>(debug/syslog expressions) → unspecified</syntax> Debug to syslog. ; {{expressions}} : The expressions to debug (cf. `debug' supra) <enscript highlight="scheme">(define-syntax debug/syslog (ir-macro-transformer (lambda (expression rename inject) `(let ((port (make-syslog-port))) (with-error-output-to-port port (lambda () (when (debug?) (debug ,@(cdr expression)) (flush-output port)))))))) </enscript> === About this egg ==== Author [[/users/klutometis|Peter Danenberg]] ==== Repository [[https://github.com/klutometis/debug]] ==== License BSD ==== Dependencies * [[hahn]] * [[matchable]] * [[setup-helper]] * [[syslog]] ==== Versions ; [[https://github.com/klutometis/debug/releases/tag/0.1|0.1]] : Version 0.1 ; [[https://github.com/klutometis/debug/releases/tag/0.1.1|0.1.1]] : Version 0.1.1 ; [[https://github.com/klutometis/debug/releases/tag/0.1.2|0.1.2]] : BSD ; [[https://github.com/klutometis/debug/releases/tag/0.2|0.2]] : Add a `debug?'-parameter. ; [[https://github.com/klutometis/debug/releases/tag/0.3|0.3]] : Add exception-guard; document. ; [[https://github.com/klutometis/debug/releases/tag/0.3.1|0.3.1]] : Add "Error: ..." ; [[https://github.com/klutometis/debug/releases/tag/0.3.2|0.3.2]] : Add arguments in errors. ; [[https://github.com/klutometis/debug/releases/tag/0.3.3|0.3.3]] : Don't do arguments if we don't have to. ; [[https://github.com/klutometis/debug/releases/tag/0.3.4|0.3.4]] : With a note about cock-utils ; [[https://github.com/klutometis/debug/releases/tag/0.3.5|0.3.5]] : Add test-exit. ; [[https://github.com/klutometis/debug/releases/tag/0.3.6|0.3.6]] : Disable an offending test. ; [[https://github.com/klutometis/debug/releases/tag/0.3.7|0.3.7]] : Self-evaluating scalars ; [[https://github.com/klutometis/debug/releases/tag/0.3.8|0.3.8]] : Fix tests ; [[https://github.com/klutometis/debug/releases/tag/0.3.9|0.3.9]] : Fix debug/syslog. ; [[https://github.com/klutometis/debug/releases/tag/0.3.10|0.3.10]] : Default-priority -> debug-priority ; [[https://github.com/klutometis/debug/releases/tag/0.3.11|0.3.11]] : Use setup-helper-cock. ; [[https://github.com/klutometis/debug/releases/tag/0.3.12|0.3.12]] : Remove the dependency on setup-helper-cock. ; [[https://github.com/klutometis/debug/releases/tag/0.3.13|0.3.13]] : Drop setup-helper-cock. ; [[https://github.com/klutometis/debug/releases/tag/0.3.14|0.3.14]] : Use ports, don't merely import it. ; [[https://github.com/klutometis/debug/releases/tag/0.3.15|0.3.15]] : Use hahn. ==== Colophon Documented by [[/egg/hahn|hahn]].
Description of your changes:
I would like to authenticate
Authentication
Username:
Password:
Spam control
What do you get when you multiply 1 by 5?