I'm trying to use SRFI 57 (the extended record types). According to the documentation, SRFI 57 is supported and indeed it appears to be built in to Racket. This is with #lang racket
and (require srfi/57)
as preamble.
SRFI 57 provides functional updates. The following works in the REPL (an MWE I pulled from the SRFI document proper):
(define-record-type point (make-point x y) point?
(x get-x set-x!)
(y get-y set-y!))
(define p (make-point 1 2))
Now, if I declare that in the REPL, I can do the following just fine:
(record-update p point (x 7))
But if I define the first portion in a racket source document, use enter!
and try my record-update
command in the REPL on the record instance p
, I get an error like so:
cdr: contract violation
expected: pair?
given: #f
[,bt for context]
What I don't understand is what the difference could possibly be. It seems like a bug to me. point?
holds for this p
object in the REPL, so it isn't like how struct types when redefined don't refer to the same object as older objects defined as one.