5.1 Demo 1: border-expr and at-expr
Basic module-level and function-level insertion of some debugging code.
src1.rkt:
#lang racket (define z 2) (define n 9) (define (f x) (define z 5) (define n 4) (if (zero? x) 1 (* x (sub1 x)))) (f 3)
src1-medic.rkt:
#lang medic (layer layer1 (in #:module "src1.rkt" ; module-level border-expr [on-entry (define x 1) (define y 2)] [on-exit (log "module exit: expect y = 2") (log y)] ; module-level at-expr [at (define n 9) [on-exit (log "module at: expect n = 9") (log n)]] ; function-level at-expr and border-expr [(f) [at (* x (sub1 _)) [on-entry (log "else branch: expect n = 4") (log n)]] [on-entry (define y 30) (log "function entry: expect y = 30") (log x) (log y)] [on-exit (log "function exit: expect n = 4") (log n)]]))