[racket] `immutable?` for `struct`s?
> You can use struct-info and struct-type-info to get at that information,
> though it's a bit indirect -- you have to add together the numbers of
> initialized and automatic fields, and compare that to the length of the list
> of immutable field indices.
Thanks!
So IIUC that would be the following, which works for the few test
cases I've thrown at it so far:
(define (immutable-struct? v)
(define-values (st _) (struct-info v))
(define-values (name init-field-cnt auto-field-cnt
accessor-proc mutator-proc
immutable-k-list
super-type skipped?) (struct-type-info st))
;; A structure is immutable if all its fields are immutable
(= (+ init-field-cnt auto-field-cnt)
(length immutable-k-list)))