mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-18 21:29:19 +02:00
array-freeze! also makes the underlying storage immutable
This commit is contained in:
parent
0516e62b0b
commit
2acef43da7
3 changed files with 19 additions and 0 deletions
|
@ -334,6 +334,7 @@
|
|||
|
||||
(define (array-freeze! array)
|
||||
(%array-setter-set! array #f)
|
||||
(make-immutable! (array-body array))
|
||||
array)
|
||||
|
||||
;; Indexing
|
||||
|
|
|
@ -46,4 +46,9 @@
|
|||
specialized-getter specialized-setter
|
||||
array-freeze!
|
||||
)
|
||||
(cond-expand
|
||||
(chibi
|
||||
(import (only (chibi) make-immutable!)))
|
||||
(else
|
||||
(begin (define-syntax make-immutable! (syntax-rules () ((_ x) #f))))))
|
||||
(include "base.scm"))
|
||||
|
|
|
@ -2188,6 +2188,19 @@
|
|||
(array-curry (list*->array 3 '(((4 7) (2 6)) ((1 0) (0 1))))
|
||||
2)
|
||||
0)))
|
||||
(let* ((A (array-copy
|
||||
(make-array (make-interval '#(0 0) '#(10 10))
|
||||
(lambda (i j) (inexact (+ (* i 10.) j))))
|
||||
f32-storage-class))
|
||||
(A3 (array-ref (array-curry A 1) 3)))
|
||||
(test 37. (array-ref A 3 7))
|
||||
(test 37. (array-ref A3 7))
|
||||
(array-set! A 0. 3 7)
|
||||
(test 0. (array-ref A 3 7))
|
||||
(test 0. (array-ref A3 7))
|
||||
(array-freeze! A)
|
||||
(test-error (array-set! A 1. 3 7))
|
||||
(test-error (array-set! A3 1. 7)))
|
||||
|
||||
;; (test-error
|
||||
;; (array-curry (make-array (make-interval '#(0 0) '#(1 1)) list) 0))
|
||||
|
|
Loading…
Add table
Reference in a new issue