(defun vectorp (x)
(and (arrayp x) (null (cdr (array-dimensions x)))))
+
+(defun aref (array index)
+ (unless (arrayp array)
+ (error "~S is not an array." array))
+ (storage-vector-ref array index))
+
+(defun aset (array index value)
+ (unless (arrayp array)
+ (error "~S is not an array." array))
+ (storage-vector-set array index value))
+
+
"v.push(" new ");" *newline*
"return v;"))
-(define-builtin aref (array n)
- (js!selfcall
- "var x = " "(" array ")[" n "];" *newline*
- "if (x === undefined) throw 'Out of range';" *newline*
- "return x;" *newline*))
-
-(define-builtin aset (array n value)
- (js!selfcall
- "var x = " array ";" *newline*
- "var i = " n ";" *newline*
- "if (i < 0 || i >= x.length) throw 'Out of range';" *newline*
- "return x[i] = " value ";" *newline*))
-
(define-builtin afind (value array)
(js!selfcall
"var v = " value ";" *newline*