diff --git a/pkgs/plai/scribblings/mutator2.scrbl b/pkgs/plai/scribblings/mutator2.scrbl index 92c3e3d82e..b9bb4e668a 100644 --- a/pkgs/plai/scribblings/mutator2.scrbl +++ b/pkgs/plai/scribblings/mutator2.scrbl @@ -268,6 +268,39 @@ of random mutators: } +Example: +@racketblock[(save-random-mutator "tmp.rkt" "mygc.rkt" #:gc2? #t)] +will write to @filepath{tmp.rkt} with a program like this one: +@codeblock{ +#lang plai/gc2/mutator +(allocator-setup "mygc.rkt" 200) +(define (build-one) + (let* ((x0 1) + (x1 (cons #f #f)) + (x2 + (lambda (x) + (if (= x 0) + x0 + (if (= x 1) x0 (if (= x 2) x1 (if (= x 3) x1 x0)))))) + (x3 1) + (x4 (cons x3 x3)) + (x5 (lambda (x) (if (= x 0) x4 (if (= x 1) x1 x2))))) + (set-first! x1 x2) + (set-rest! x1 x3) + x5)) +(define (traverse-one x5) (= 1 (first (x5 0)))) +(define (trigger-gc n) + (if (zero? n) 0 (begin (cons n n) (trigger-gc (- n 1))))) +(define (loop i) + (if (zero? i) + 'passed + (let ((obj (build-one))) + (trigger-gc 200) + (if (traverse-one obj) (loop (- i 1)) 'failed)))) +(loop 200) +} + + @defproc[(find-heap-values [input (or/c path-string? input-port?)]) (listof heap-value?)]{ Processes @racket[input] looking for occurrences of @racket[heap-value?]s in