5.2 Demo 2: at-expr
The at-expr pattern matching with before-expr and after-expr specification.
src2.rkt:
#lang racket (define x 10) (define counter 0) (define (inc-counter) (set! counter (add1 counter))) (define (inc x) (inc-counter) (+ x 1)) (define (g) (define x (inc 4)) (inc-counter) (+ x 1)) (g)
src2-medic.rkt:
#lang medic (layer layer1 (in #:module "src2.rkt" ; match two instances of (inc-counter) [at (inc-counter) [on-entry @log{[1] in @function-name : int-counter}]] ; match two instances of (+ x 1) [at (+ x 1) #:before (inc-counter) [on-entry @log{[2]in @function-name : (+ x 1)}]] ; only match (+ x 1) in g function [at (+ x 1) #:before (begin (define x (inc 4)) _) [on-entry @log{[3]in @function-name : (+ x 1)}]] [(g) [at (+ x 1) [on-entry @log{[4]in @function-name : (+ x 1)}]]] ; only match (inc-counter) in function g [at (inc-counter) #:before (define x (inc 4)) #:after (+ x 1) (on-entry @log{[5]in @function-name : (inc-counter)})] [at (inc-counter) #:before (define x (inc _)) #:after (+ x 1) (on-entry @log{[6]in @function-name : (inc-counter)})]))