;;;; Copyright 2002, Jonathan Bachrach.  See file TERMS.

(use goo/boot)
(use goo/fun)
(use goo/class)
(use goo/macros)
(use goo/types)
(use goo/cols/col)
(use goo/cols/seq)
(use goo/cols/flat)

;; 3.7.6.1 TUPLES

;;;;!! Interface
(exported
 ;; Defined in boot
 <tup>
 tup
)

;;;;!! Implementation

;;;; Collection protocol
(dm (len inline) (x|<tup> => <int>)
  (%ib (%tlen x)))

(dm elt-or (x|<tup> i|<int> default => <any>)
  (if (range-check? x i)
      (%telt x (%iu i)) ;; TODO: LOW-ELT
      default))

;; (dm elt-setter (z x|<tup> i|<int>)
;;   (range-check x i)
;;   (set (%telt x (%iu i)) z)) ;; TODO: LOW-ELT

(dm nul (c|(t= <tup>) => <tup>)
  %tnul)

(dm (fab inline) (x|(t= <tup>) s|<int> => <tup>)
  (%tup (%iu s) #f))


;;;; Misc stuff

(dm to-str (x|<tup> => <str>)
  (cat "#(" (vals-to-str x) ")"))

;;;; Undocumented
(dm (low-elt inline) (x|<tup> i|<int> => <any>)
  (%telt x (%iu i)))

(dm (fab-elt-setter inline) (z x|<tup> i|<int>)
  (set (%telt x (%iu i)) z))
