;; -*-theme-d-*-

;; Copyright (C) 2014  Tommi Höynälänmaa
;; Distributed under GNU General Public License version 3,
;; see file doc/GPL-3.

;; Expected results: translation and running OK


(define-proper-program (tests test151)

  (import (standard-library core)
	  (standard-library list-utilities)
	  (standard-library console-io))

  (define-class <sequence> <object> #t #f #f public () ())

  (define-simple-method sequence-set-components! 
    (((seq <sequence>) (elements (:uniform-list <symbol>)))
     <none> nonpure)
    (raise 'abstract-method))

  (define-class <list-as-sequence> <sequence>
    #t #f #f public ()
    ((contents (:uniform-list <symbol>) module module)))

  (define-simple-method sequence-set-components! 
    (((seq <list-as-sequence>) (elements (:uniform-list <symbol>)))
     <none> nonpure)
    (field-set! seq 'contents elements))

  (define-simple-proc main (() <none> nonpure)
    (let* ((lst '(a b c d e))
	   (seq (make <list-as-sequence> lst)))
      (sequence-set-components! seq (list 'apples 'oranges 'bananas))
      (let* ((contents (field-ref seq 'contents))
	     (len (length contents)))
	(do ((i <integer> 0 (+ i 1))) ((>= i len))
	  (console-display (uniform-list-ref contents i))
	  (console-newline))))))
