Experiments with Racket

#lang racket


(define-struct posn (x y) #:transparent #:mutable)

(define p (posn 2 3))

p ; (posn 2 3)

(define x p)

x ; (posn 2 3)

(set-posn-x! p 4)

p ; (posn 4 3)

x ; (posn 4 3)


; This proves that defining one object as another
; passes the value by reference. So mutating the
; value of  p reflects in x