(define (fresh) (define-record-type local (fields x)) (list (record-type-descriptor local) (lambda () (record-type-descriptor local)) make-local local-x)) (define first (fresh)) (define second (fresh)) (write (list (eq? (car first) (car second)) (eq? ((cadr first)) ((cadr second))) ((cadddr first) ((caddr first) 42)))) (newline) (define (one) (define-record-type (shared make-shared shared?) (nongenerative shared-uid) (fields x) (protocol (lambda (p) (lambda (x) (p (+ x 1)))))) (list (record-type-descriptor shared) (record-constructor-descriptor shared) make-shared shared-x (lambda () (record-constructor-descriptor shared)))) (define (two) (define-record-type (shared make-shared shared?) (nongenerative shared-uid) (fields x) (protocol (lambda (p) (lambda (x) (p (+ x 2)))))) (list (record-type-descriptor shared) (record-constructor-descriptor shared) make-shared shared-x (lambda () (record-constructor-descriptor shared)))) (define a (one)) (define b (two)) (write (list (eq? (car a) (car b)) (eq? (cadr a) (cadr b)) ((cadddr a) ((caddr a) 10)) ((cadddr b) ((caddr b) 10)) (eq? ((car (cddddr a))) ((car (cddddr b)))))) (newline)