This is Chapter 20 in the text. Since this is the pro section, I include details you would not usually see.
#lang racket
allows some advanced features at a cost of
some complexity.#:transparent
. This is best explained as a
design mistake in the Racket language.struct-copy
or follow the examples below.#lang racket
(require lang/posn)
(define-struct m (pos vel color) #:transparent)
(define example-1
(make-m (make-posn 5 12)
(make-posn 2 -1)
(make-color 255 100 0)))
(define example-2
(struct-copy m example-1 [vel (make-posn -3 4)]))
In #lang racket
you need to do checks using the
rackunit
module.
You need to use check-equal?
or do what I do and create an alias for check-expect
.
(require rackunit)
(define check-expect check-equal?)