Closed gambiteer closed 6 months ago
Not sure what you mean? These are record accessors so of course throw an appropriate error if the argument is not of the desired record type.
For example, with this macro
(define-syntax define-storage-class
(syntax-rules ()
((define-storage-class name ref set elt? make len default)
(define name
(make-storage-class
ref set elt? make
(lambda (to at from start end)
(let ((limit (min end (+ start (- (len to) at)))))
(if (<= at start)
(do ((i at (+ i 1)) (j start (+ j 1)))
((>= j limit))
(set to i (ref from j)))
(do ((i (+ at (- end start 1)) (- i 1)) (j (- limit 1) (- j 1)))
((< j start))
(set to i (ref from j))))))
len default (lambda (data) #t) (lambda (data) data))))))
and this usage
(define-storage-class s8-storage-class
s8vector-ref s8vector-set! s8? make-s8vector s8vector-length 0)
((storage-class-data? s8-storage-class) 'a)
returns #t
and ((storage-class-data->body s8-storage-class) 'a)
returns 'a
, which is invalid for that storage class.
s8-storage-class
should have s8vector?
as the second storage-class-data?
slot, and I would recommend
(lambda (data)
(assert (s8vector? data))
data)
as the last slot.
Would you like some error checking here?